sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
def response(self, code, xml, force_list=None):
"""Cria um dicionário com os dados de retorno da requisição HTTP ou
lança uma exceção correspondente ao erro ocorrido.
Se a requisição HTTP retornar o código 200 então este método retorna o
dicionário com os dados da resposta.
Se a requisição HTTP retornar um código diferente de 200 então este método
lança uma exceção correspondente ao erro.
Todas as exceções lançadas por este método deverão herdar de NetworkAPIClientError.
:param code: Código de retorno da requisição HTTP.
:param xml: XML ou descrição (corpo) da resposta HTTP.
:param force_list: Lista com as tags do XML de resposta que deverão ser transformadas
obrigatoriamente em uma lista no dicionário de resposta.
:return: Dicionário com os dados da resposta HTTP retornada pela networkAPI.
"""
if int(code) == 200:
# Retorna o map
return loads(xml, force_list)['networkapi']
elif int(code) == 500:
code, description = self.get_error(xml)
return ErrorHandler.handle(code, description)
else:
return ErrorHandler.handle(code, xml) | Cria um dicionário com os dados de retorno da requisição HTTP ou
lança uma exceção correspondente ao erro ocorrido.
Se a requisição HTTP retornar o código 200 então este método retorna o
dicionário com os dados da resposta.
Se a requisição HTTP retornar um código diferente de 200 então este método
lança uma exceção correspondente ao erro.
Todas as exceções lançadas por este método deverão herdar de NetworkAPIClientError.
:param code: Código de retorno da requisição HTTP.
:param xml: XML ou descrição (corpo) da resposta HTTP.
:param force_list: Lista com as tags do XML de resposta que deverão ser transformadas
obrigatoriamente em uma lista no dicionário de resposta.
:return: Dicionário com os dados da resposta HTTP retornada pela networkAPI. | entailment |
def inserir(self, id_script_type, script, model, description):
"""Inserts a new Script and returns its identifier.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:param script: Script name. String with a minimum 3 and maximum of 40 characters
:param description: Script description. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'script': {'id': < id_script >}}
:raise InvalidParameterError: The identifier of Script Type, script or description is null and invalid.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise NomeRoteiroDuplicadoError: Script already registered with informed.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
script_map = dict()
script_map['id_script_type'] = id_script_type
script_map['script'] = script
script_map['model'] = model
script_map['description'] = description
code, xml = self.submit({'script': script_map}, 'POST', 'script/')
return self.response(code, xml) | Inserts a new Script and returns its identifier.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:param script: Script name. String with a minimum 3 and maximum of 40 characters
:param description: Script description. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'script': {'id': < id_script >}}
:raise InvalidParameterError: The identifier of Script Type, script or description is null and invalid.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise NomeRoteiroDuplicadoError: Script already registered with informed.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def alterar(self, id_script, id_script_type, script, description, model=None):
"""Change Script from by the identifier.
:param id_script: Identifier of the Script. Integer value and greater than zero.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:param script: Script name. String with a minimum 3 and maximum of 40 characters
:param description: Script description. String with a minimum 3 and maximum of 100 characters
:return: None
:raise InvalidParameterError: The identifier of Script, script Type, script or description is null and invalid.
:raise RoteiroNaoExisteError: Script not registered.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise NomeRoteiroDuplicadoError: Script already registered with informed.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_script):
raise InvalidParameterError(u'The identifier of Script is invalid or was not informed.')
script_map = dict()
script_map['id_script_type'] = id_script_type
script_map['script'] = script
script_map['model'] = model
script_map['description'] = description
url = 'script/edit/' + str(id_script) + '/'
code, xml = self.submit({'script': script_map}, 'PUT', url)
return self.response(code, xml) | Change Script from by the identifier.
:param id_script: Identifier of the Script. Integer value and greater than zero.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:param script: Script name. String with a minimum 3 and maximum of 40 characters
:param description: Script description. String with a minimum 3 and maximum of 100 characters
:return: None
:raise InvalidParameterError: The identifier of Script, script Type, script or description is null and invalid.
:raise RoteiroNaoExisteError: Script not registered.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise NomeRoteiroDuplicadoError: Script already registered with informed.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def remover(self, id_script):
"""Remove Script from by the identifier.
:param id_script: Identifier of the Script. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Script is null and invalid.
:raise RoteiroNaoExisteError: Script not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_script):
raise InvalidParameterError(
u'The identifier of Script is invalid or was not informed.')
url = 'script/' + str(id_script) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Remove Script from by the identifier.
:param id_script: Identifier of the Script. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Script is null and invalid.
:raise RoteiroNaoExisteError: Script not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def listar_por_tipo(self, id_script_type):
"""List all Script by Script Type.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{‘script’: [{‘id’: < id >,
‘tipo_roteiro': < id_tipo_roteiro >,
‘nome': < nome >,
‘descricao’: < descricao >}, ...more Script...]}
:raise InvalidParameterError: The identifier of Script Type is null and invalid.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_script_type):
raise InvalidParameterError(
u'The identifier of Script Type is invalid or was not informed.')
url = 'script/scripttype/' + str(id_script_type) + '/'
code, map = self.submit(None, 'GET', url)
key = 'script'
return get_list_map(self.response(code, map, [key]), key) | List all Script by Script Type.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{‘script’: [{‘id’: < id >,
‘tipo_roteiro': < id_tipo_roteiro >,
‘nome': < nome >,
‘descricao’: < descricao >}, ...more Script...]}
:raise InvalidParameterError: The identifier of Script Type is null and invalid.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def listar_por_equipamento(self, id_equipment):
"""List all Script related Equipment.
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{script': [{‘id’: < id >,
‘nome’: < nome >,
‘descricao’: < descricao >,
‘id_tipo_roteiro’: < id_tipo_roteiro >,
‘nome_tipo_roteiro’: < nome_tipo_roteiro >,
‘descricao_tipo_roteiro’: < descricao_tipo_roteiro >}, ...more Script...]}
:raise InvalidParameterError: The identifier of Equipment is null and invalid.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_equipment):
raise InvalidParameterError(
u'The identifier of Equipment is invalid or was not informed.')
url = 'script/equipment/' + str(id_equipment) + '/'
code, map = self.submit(None, 'GET', url)
key = 'script'
return get_list_map(self.response(code, map, [key]), key) | List all Script related Equipment.
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{script': [{‘id’: < id >,
‘nome’: < nome >,
‘descricao’: < descricao >,
‘id_tipo_roteiro’: < id_tipo_roteiro >,
‘nome_tipo_roteiro’: < nome_tipo_roteiro >,
‘descricao_tipo_roteiro’: < descricao_tipo_roteiro >}, ...more Script...]}
:raise InvalidParameterError: The identifier of Equipment is null and invalid.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def get_rule_by_id(self, rule_id):
"""Get rule by indentifier.
:param rule_id: Rule identifier
:return: Dictionary with the following structure:
::
{'rule': {'environment': < environment_id >,
'content': < content >,
'custom': < custom >,
'id': < id >,
'name': < name >}}
:raise UserNotAuthorizedError: User dont have permition.
:raise InvalidParameterError: RULE identifier is null or invalid.
:raise DataBaseError: Can't connect to networkapi database.
"""
url = "rule/get_by_id/" + str(rule_id)
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml, ['rule_contents', 'rule_blocks']) | Get rule by indentifier.
:param rule_id: Rule identifier
:return: Dictionary with the following structure:
::
{'rule': {'environment': < environment_id >,
'content': < content >,
'custom': < custom >,
'id': < id >,
'name': < name >}}
:raise UserNotAuthorizedError: User dont have permition.
:raise InvalidParameterError: RULE identifier is null or invalid.
:raise DataBaseError: Can't connect to networkapi database. | entailment |
def create_networks(self, ids, id_vlan):
"""Set column 'active = 1' in tables redeipv4 and redeipv6]
:param ids: ID for NetworkIPv4 and/or NetworkIPv6
:return: Nothing
"""
network_map = dict()
network_map['ids'] = ids
network_map['id_vlan'] = id_vlan
code, xml = self.submit(
{'network': network_map}, 'PUT', 'network/create/')
return self.response(code, xml) | Set column 'active = 1' in tables redeipv4 and redeipv6]
:param ids: ID for NetworkIPv4 and/or NetworkIPv6
:return: Nothing | entailment |
def add_network(self, network, id_vlan, id_network_type,
id_environment_vip=None, cluster_unit=None):
"""
Add new network
:param network: IPV4 or IPV6 (ex.: "10.0.0.3/24")
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:param id_network_type: Identifier of the NetworkType. Integer value and greater than zero.
:param id_environment_vip: Identifier of the Environment Vip. Integer value and greater than zero.
:return: Following dictionary:
::
{'network':{'id': <id_network>,
'rede': <network>,
'broadcast': <broadcast> (if is IPv4),
'mask': <net_mask>,
'id_vlan': <id_vlan>,
'id_tipo_rede': <id_network_type>,
'id_ambiente_vip': <id_ambiente_vip>,
'active': <active>} }
:raise TipoRedeNaoExisteError: NetworkType not found.
:raise InvalidParameterError: Invalid ID for Vlan or NetworkType.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise IPNaoDisponivelError: Network address unavailable to create a NetworkIPv4.
:raise NetworkIPRangeEnvError: Other environment already have this ip range.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
network_map = dict()
network_map['network'] = network
network_map['id_vlan'] = id_vlan
network_map['id_network_type'] = id_network_type
network_map['id_environment_vip'] = id_environment_vip
network_map['cluster_unit'] = cluster_unit
code, xml = self.submit(
{'network': network_map}, 'POST', 'network/add/')
return self.response(code, xml) | Add new network
:param network: IPV4 or IPV6 (ex.: "10.0.0.3/24")
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:param id_network_type: Identifier of the NetworkType. Integer value and greater than zero.
:param id_environment_vip: Identifier of the Environment Vip. Integer value and greater than zero.
:return: Following dictionary:
::
{'network':{'id': <id_network>,
'rede': <network>,
'broadcast': <broadcast> (if is IPv4),
'mask': <net_mask>,
'id_vlan': <id_vlan>,
'id_tipo_rede': <id_network_type>,
'id_ambiente_vip': <id_ambiente_vip>,
'active': <active>} }
:raise TipoRedeNaoExisteError: NetworkType not found.
:raise InvalidParameterError: Invalid ID for Vlan or NetworkType.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise IPNaoDisponivelError: Network address unavailable to create a NetworkIPv4.
:raise NetworkIPRangeEnvError: Other environment already have this ip range.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def edit_network(self, id_network, ip_type, id_net_type, id_env_vip=None, cluster_unit=None):
"""
Edit a network 4 or 6
:param id_network: Identifier of the Network. Integer value and greater than zero.
:param id_net_type: Identifier of the NetworkType. Integer value and greater than zero.
:param id_env_vip: Identifier of the Environment Vip. Integer value and greater than zero.
:param ip_type: Identifier of the Network IP Type: 0 = IP4 Network; 1 = IP6 Network;
:return: None
:raise TipoRedeNaoExisteError: NetworkType not found.
:raise InvalidParameterError: Invalid ID for Vlan or NetworkType.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise IPNaoDisponivelError: Network address unavailable to create a NetworkIPv4.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
net_map = dict()
net_map['id_network'] = id_network
net_map['ip_type'] = ip_type
net_map['id_net_type'] = id_net_type
net_map['id_env_vip'] = id_env_vip
net_map['cluster_unit'] = cluster_unit
code, xml = self.submit({'net': net_map}, 'POST', 'network/edit/')
return self.response(code, xml) | Edit a network 4 or 6
:param id_network: Identifier of the Network. Integer value and greater than zero.
:param id_net_type: Identifier of the NetworkType. Integer value and greater than zero.
:param id_env_vip: Identifier of the Environment Vip. Integer value and greater than zero.
:param ip_type: Identifier of the Network IP Type: 0 = IP4 Network; 1 = IP6 Network;
:return: None
:raise TipoRedeNaoExisteError: NetworkType not found.
:raise InvalidParameterError: Invalid ID for Vlan or NetworkType.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise IPNaoDisponivelError: Network address unavailable to create a NetworkIPv4.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def get_network_ipv4(self, id_network):
"""
Get networkipv4
:param id_network: Identifier of the Network. Integer value and greater than zero.
:return: Following dictionary:
::
{'network': {'id': < id_networkIpv6 >,
'network_type': < id_tipo_rede >,
'ambiente_vip': < id_ambiente_vip >,
'vlan': <id_vlan>
'oct1': < rede_oct1 >,
'oct2': < rede_oct2 >,
'oct3': < rede_oct3 >,
'oct4': < rede_oct4 >
'blocK': < bloco >,
'mask_oct1': < mascara_oct1 >,
'mask_oct2': < mascara_oct2 >,
'mask_oct3': < mascara_oct3 >,
'mask_oct4': < mascara_oct4 >,
'active': < ativada >,
'broadcast':<'broadcast>, }}
:raise NetworkIPv4NotFoundError: NetworkIPV4 not found.
:raise InvalidValueError: Invalid ID for NetworkIpv4
:raise NetworkIPv4Error: Error in NetworkIpv4
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_network):
raise InvalidParameterError(
u'O id do rede ip4 foi informado incorretamente.')
url = 'network/ipv4/id/' + str(id_network) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Get networkipv4
:param id_network: Identifier of the Network. Integer value and greater than zero.
:return: Following dictionary:
::
{'network': {'id': < id_networkIpv6 >,
'network_type': < id_tipo_rede >,
'ambiente_vip': < id_ambiente_vip >,
'vlan': <id_vlan>
'oct1': < rede_oct1 >,
'oct2': < rede_oct2 >,
'oct3': < rede_oct3 >,
'oct4': < rede_oct4 >
'blocK': < bloco >,
'mask_oct1': < mascara_oct1 >,
'mask_oct2': < mascara_oct2 >,
'mask_oct3': < mascara_oct3 >,
'mask_oct4': < mascara_oct4 >,
'active': < ativada >,
'broadcast':<'broadcast>, }}
:raise NetworkIPv4NotFoundError: NetworkIPV4 not found.
:raise InvalidValueError: Invalid ID for NetworkIpv4
:raise NetworkIPv4Error: Error in NetworkIpv4
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def get_network_ipv6(self, id_network):
"""
Get networkipv6
:param id_network: Identifier of the Network. Integer value and greater than zero.
:return: Following dictionary:
::
{'network': {'id': < id_networkIpv6 >,
'network_type': < id_tipo_rede >,
'ambiente_vip': < id_ambiente_viṕ >,
'vlan': <id_vlan>
'block1': < rede_oct1 >,
'block2': < rede_oct2 >,
'block3': < rede_oct3 >,
'block4': < rede_oct4 >,
'block5': < rede_oct4 >,
'block6': < rede_oct4 >,
'block7': < rede_oct4 >,
'block8': < rede_oct4 >,
'blocK': < bloco >,
'mask1': < mascara_oct1 >,
'mask2': < mascara_oct2 >,
'mask3': < mascara_oct3 >,
'mask4': < mascara_oct4 >,
'mask5': < mascara_oct4 >,
'mask6': < mascara_oct4 >,
'mask7': < mascara_oct4 >,
'mask8': < mascara_oct4 >,
'active': < ativada >, }}
:raise NetworkIPv6NotFoundError: NetworkIPV6 not found.
:raise InvalidValueError: Invalid ID for NetworkIpv6
:raise NetworkIPv6Error: Error in NetworkIpv6
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_network):
raise InvalidParameterError(
u'O id do rede ip6 foi informado incorretamente.')
url = 'network/ipv6/id/' + str(id_network) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Get networkipv6
:param id_network: Identifier of the Network. Integer value and greater than zero.
:return: Following dictionary:
::
{'network': {'id': < id_networkIpv6 >,
'network_type': < id_tipo_rede >,
'ambiente_vip': < id_ambiente_viṕ >,
'vlan': <id_vlan>
'block1': < rede_oct1 >,
'block2': < rede_oct2 >,
'block3': < rede_oct3 >,
'block4': < rede_oct4 >,
'block5': < rede_oct4 >,
'block6': < rede_oct4 >,
'block7': < rede_oct4 >,
'block8': < rede_oct4 >,
'blocK': < bloco >,
'mask1': < mascara_oct1 >,
'mask2': < mascara_oct2 >,
'mask3': < mascara_oct3 >,
'mask4': < mascara_oct4 >,
'mask5': < mascara_oct4 >,
'mask6': < mascara_oct4 >,
'mask7': < mascara_oct4 >,
'mask8': < mascara_oct4 >,
'active': < ativada >, }}
:raise NetworkIPv6NotFoundError: NetworkIPV6 not found.
:raise InvalidValueError: Invalid ID for NetworkIpv6
:raise NetworkIPv6Error: Error in NetworkIpv6
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def deallocate_network_ipv4(self, id_network_ipv4):
"""
Deallocate all relationships between NetworkIPv4.
:param id_network_ipv4: ID for NetworkIPv4
:return: Nothing
:raise InvalidParameterError: Invalid ID for NetworkIPv4.
:raise NetworkIPv4NotFoundError: NetworkIPv4 not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_network_ipv4):
raise InvalidParameterError(
u'The identifier of NetworkIPv4 is invalid or was not informed.')
url = 'network/ipv4/' + str(id_network_ipv4) + '/deallocate/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Deallocate all relationships between NetworkIPv4.
:param id_network_ipv4: ID for NetworkIPv4
:return: Nothing
:raise InvalidParameterError: Invalid ID for NetworkIPv4.
:raise NetworkIPv4NotFoundError: NetworkIPv4 not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def add_network_ipv6(
self,
id_vlan,
id_tipo_rede,
id_ambiente_vip=None,
prefix=None):
"""
Add new networkipv6
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:param id_tipo_rede: Identifier of the NetworkType. Integer value and greater than zero.
:param id_ambiente_vip: Identifier of the Environment Vip. Integer value and greater than zero.
:param prefix: Prefix.
:return: Following dictionary:
::
{'vlan': {'id': < id_vlan >,
'nome': < nome_vlan >,
'num_vlan': < num_vlan >,
'id_tipo_rede': < id_tipo_rede >,
'id_ambiente': < id_ambiente >,
'rede_oct1': < rede_oct1 >,
'rede_oct2': < rede_oct2 >,
'rede_oct3': < rede_oct3 >,
'rede_oct4': < rede_oct4 >,
'rede_oct5': < rede_oct4 >,
'rede_oct6': < rede_oct4 >,
'rede_oct7': < rede_oct4 >,
'rede_oct8': < rede_oct4 >,
'bloco': < bloco >,
'mascara_oct1': < mascara_oct1 >,
'mascara_oct2': < mascara_oct2 >,
'mascara_oct3': < mascara_oct3 >,
'mascara_oct4': < mascara_oct4 >,
'mascara_oct5': < mascara_oct4 >,
'mascara_oct6': < mascara_oct4 >,
'mascara_oct7': < mascara_oct4 >,
'mascara_oct8': < mascara_oct4 >,
'broadcast': < broadcast >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'ativada': < ativada >}}
:raise TipoRedeNaoExisteError: NetworkType not found.
:raise InvalidParameterError: Invalid ID for Vlan or NetworkType.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise IPNaoDisponivelError: Network address unavailable to create a NetworkIPv6.
:raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
vlan_map = dict()
vlan_map['id_vlan'] = id_vlan
vlan_map['id_tipo_rede'] = id_tipo_rede
vlan_map['id_ambiente_vip'] = id_ambiente_vip
vlan_map['prefix'] = prefix
code, xml = self.submit(
{'vlan': vlan_map}, 'POST', 'network/ipv6/add/')
return self.response(code, xml) | Add new networkipv6
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:param id_tipo_rede: Identifier of the NetworkType. Integer value and greater than zero.
:param id_ambiente_vip: Identifier of the Environment Vip. Integer value and greater than zero.
:param prefix: Prefix.
:return: Following dictionary:
::
{'vlan': {'id': < id_vlan >,
'nome': < nome_vlan >,
'num_vlan': < num_vlan >,
'id_tipo_rede': < id_tipo_rede >,
'id_ambiente': < id_ambiente >,
'rede_oct1': < rede_oct1 >,
'rede_oct2': < rede_oct2 >,
'rede_oct3': < rede_oct3 >,
'rede_oct4': < rede_oct4 >,
'rede_oct5': < rede_oct4 >,
'rede_oct6': < rede_oct4 >,
'rede_oct7': < rede_oct4 >,
'rede_oct8': < rede_oct4 >,
'bloco': < bloco >,
'mascara_oct1': < mascara_oct1 >,
'mascara_oct2': < mascara_oct2 >,
'mascara_oct3': < mascara_oct3 >,
'mascara_oct4': < mascara_oct4 >,
'mascara_oct5': < mascara_oct4 >,
'mascara_oct6': < mascara_oct4 >,
'mascara_oct7': < mascara_oct4 >,
'mascara_oct8': < mascara_oct4 >,
'broadcast': < broadcast >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'ativada': < ativada >}}
:raise TipoRedeNaoExisteError: NetworkType not found.
:raise InvalidParameterError: Invalid ID for Vlan or NetworkType.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise IPNaoDisponivelError: Network address unavailable to create a NetworkIPv6.
:raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def add_network_ipv6_hosts(
self,
id_vlan,
id_tipo_rede,
num_hosts,
id_ambiente_vip=None):
"""
Add new networkipv6
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:param id_tipo_rede: Identifier of the NetworkType. Integer value and greater than zero.
:param num_hosts: Number of hosts expected. Integer value and greater than zero.
:param id_ambiente_vip: Identifier of the Environment Vip. Integer value and greater than zero.
:return: Following dictionary:
::
{'vlan': {'id': < id_vlan >,
'nome': < nome_vlan >,
'num_vlan': < num_vlan >,
'id_tipo_rede': < id_tipo_rede >,
'id_ambiente': < id_ambiente >,
'rede_oct1': < rede_oct1 >,
'rede_oct2': < rede_oct2 >,
'rede_oct3': < rede_oct3 >,
'rede_oct4': < rede_oct4 >,
'rede_oct5': < rede_oct4 >,
'rede_oct6': < rede_oct4 >,
'rede_oct7': < rede_oct4 >,
'rede_oct8': < rede_oct4 >,
'bloco': < bloco >,
'mascara_oct1': < mascara_oct1 >,
'mascara_oct2': < mascara_oct2 >,
'mascara_oct3': < mascara_oct3 >,
'mascara_oct4': < mascara_oct4 >,
'mascara_oct5': < mascara_oct4 >,
'mascara_oct6': < mascara_oct4 >,
'mascara_oct7': < mascara_oct4 >,
'mascara_oct8': < mascara_oct4 >,
'broadcast': < broadcast >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'ativada': < ativada >}}
:raise TipoRedeNaoExisteError: NetworkType not found.
:raise InvalidParameterError: Invalid ID for Vlan or NetworkType.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise IPNaoDisponivelError: Network address unavailable to create a NetworkIPv6.
:raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
vlan_map = dict()
vlan_map['id_vlan'] = id_vlan
vlan_map['id_tipo_rede'] = id_tipo_rede
vlan_map['num_hosts'] = num_hosts
vlan_map['id_ambiente_vip'] = id_ambiente_vip
code, xml = self.submit({'vlan': vlan_map}, 'PUT', 'network/ipv6/add/')
return self.response(code, xml) | Add new networkipv6
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:param id_tipo_rede: Identifier of the NetworkType. Integer value and greater than zero.
:param num_hosts: Number of hosts expected. Integer value and greater than zero.
:param id_ambiente_vip: Identifier of the Environment Vip. Integer value and greater than zero.
:return: Following dictionary:
::
{'vlan': {'id': < id_vlan >,
'nome': < nome_vlan >,
'num_vlan': < num_vlan >,
'id_tipo_rede': < id_tipo_rede >,
'id_ambiente': < id_ambiente >,
'rede_oct1': < rede_oct1 >,
'rede_oct2': < rede_oct2 >,
'rede_oct3': < rede_oct3 >,
'rede_oct4': < rede_oct4 >,
'rede_oct5': < rede_oct4 >,
'rede_oct6': < rede_oct4 >,
'rede_oct7': < rede_oct4 >,
'rede_oct8': < rede_oct4 >,
'bloco': < bloco >,
'mascara_oct1': < mascara_oct1 >,
'mascara_oct2': < mascara_oct2 >,
'mascara_oct3': < mascara_oct3 >,
'mascara_oct4': < mascara_oct4 >,
'mascara_oct5': < mascara_oct4 >,
'mascara_oct6': < mascara_oct4 >,
'mascara_oct7': < mascara_oct4 >,
'mascara_oct8': < mascara_oct4 >,
'broadcast': < broadcast >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'ativada': < ativada >}}
:raise TipoRedeNaoExisteError: NetworkType not found.
:raise InvalidParameterError: Invalid ID for Vlan or NetworkType.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise IPNaoDisponivelError: Network address unavailable to create a NetworkIPv6.
:raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def deallocate_network_ipv6(self, id_network_ipv6):
"""
Deallocate all relationships between NetworkIPv6.
:param id_network_ipv6: ID for NetworkIPv6
:return: Nothing
:raise InvalidParameterError: Invalid ID for NetworkIPv6.
:raise NetworkIPv6NotFoundError: NetworkIPv6 not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_network_ipv6):
raise InvalidParameterError(
u'The identifier of NetworkIPv6 is invalid or was not informed.')
url = 'network/ipv6/' + str(id_network_ipv6) + '/deallocate/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Deallocate all relationships between NetworkIPv6.
:param id_network_ipv6: ID for NetworkIPv6
:return: Nothing
:raise InvalidParameterError: Invalid ID for NetworkIPv6.
:raise NetworkIPv6NotFoundError: NetworkIPv6 not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def remove_networks(self, ids):
"""
Set column 'active = 0' in tables redeipv4 and redeipv6]
:param ids: ID for NetworkIPv4 and/or NetworkIPv6
:return: Nothing
:raise NetworkInactiveError: Unable to remove the network because it is inactive.
:raise InvalidParameterError: Invalid ID for Network or NetworkType.
:raise NetworkIPv4NotFoundError: NetworkIPv4 not found.
:raise NetworkIPv6NotFoundError: NetworkIPv6 not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
network_map = dict()
network_map['ids'] = ids
code, xml = self.submit(
{'network': network_map}, 'PUT', 'network/remove/')
return self.response(code, xml) | Set column 'active = 0' in tables redeipv4 and redeipv6]
:param ids: ID for NetworkIPv4 and/or NetworkIPv6
:return: Nothing
:raise NetworkInactiveError: Unable to remove the network because it is inactive.
:raise InvalidParameterError: Invalid ID for Network or NetworkType.
:raise NetworkIPv4NotFoundError: NetworkIPv4 not found.
:raise NetworkIPv6NotFoundError: NetworkIPv6 not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def add(self, networkipv4_id, ipv4_id):
"""List all DHCPRelayIPv4.
:param: networkipv4_id, ipv4_id
:return: Following dictionary:
{
"networkipv4": <networkipv4_id>,
"id": <id>,
"ipv4": {
"oct4": <oct4>,
"oct2": <oct2>,
"oct3": <oct3>,
"oct1": <oct1>,
"ip_formated": "<string IPv4>",
"networkipv4": <networkipv4_id>,
"id": <ipv4_id>,
"descricao": "<string description>"
}
:raise NetworkAPIException: Falha ao acessar fonte de dados
"""
data = dict()
data['networkipv4'] = networkipv4_id
data['ipv4'] = dict()
data['ipv4']['id'] = ipv4_id
uri = 'api/dhcprelayv4/'
return self.post(uri, data=data) | List all DHCPRelayIPv4.
:param: networkipv4_id, ipv4_id
:return: Following dictionary:
{
"networkipv4": <networkipv4_id>,
"id": <id>,
"ipv4": {
"oct4": <oct4>,
"oct2": <oct2>,
"oct3": <oct3>,
"oct1": <oct1>,
"ip_formated": "<string IPv4>",
"networkipv4": <networkipv4_id>,
"id": <ipv4_id>,
"descricao": "<string description>"
}
:raise NetworkAPIException: Falha ao acessar fonte de dados | entailment |
def list(self, networkipv4=None, ipv4=None):
"""List all DHCPRelayIPv4.
:param: networkipv4: networkipv4 id - list all dhcprelay filtering by networkipv4 id
ipv4: ipv4 id - list all dhcprelay filtering by ipv4 id
:return: Following dictionary:
[
{
"networkipv4": <networkipv4_id>,
"id": <id>,
"ipv4": {
"oct4": <oct4>,
"oct2": <oct2>,
"oct3": <oct3>,
"oct1": <oct1>,
"ip_formated": "<string IPv4>",
"networkipv4": <networkipv4_id>,
"id": <ipv4_id>,
"descricao": "<string description>"
},
{...}
]
:raise NetworkAPIException: Falha ao acessar fonte de dados
"""
uri = 'api/dhcprelayv4/?'
if networkipv4:
uri += 'networkipv4=%s&' % networkipv4
if ipv4:
uri += 'ipv4=%s' % ipv4
return self.get(uri) | List all DHCPRelayIPv4.
:param: networkipv4: networkipv4 id - list all dhcprelay filtering by networkipv4 id
ipv4: ipv4 id - list all dhcprelay filtering by ipv4 id
:return: Following dictionary:
[
{
"networkipv4": <networkipv4_id>,
"id": <id>,
"ipv4": {
"oct4": <oct4>,
"oct2": <oct2>,
"oct3": <oct3>,
"oct1": <oct1>,
"ip_formated": "<string IPv4>",
"networkipv4": <networkipv4_id>,
"id": <ipv4_id>,
"descricao": "<string description>"
},
{...}
]
:raise NetworkAPIException: Falha ao acessar fonte de dados | entailment |
def add(self, networkipv6_id, ipv6_id):
"""List all DHCPRelayIPv4.
:param: Object DHCPRelayIPv4
:return: Following dictionary:
{
"networkipv6": <networkipv4_id>,
"id": <id>,
"ipv6": {
"block1": <block1>,
"block2": <block2>,
"block3": <block3>,
"block4": <block4>,
"block5": <block5>,
"block6": <block6>,
"block7": <block7>,
"block8": <block8>,
"ip_formated": "<string IPv6>",
"networkipv6": <networkipv6_id>,
"id": <ipv6_id>,
"description": "<string description>"
}
:raise NetworkAPIException: Falha ao acessar fonte de dados
"""
data = dict()
data['networkipv6'] = networkipv6_id
data['ipv6'] = dict()
data['ipv6']['id'] = ipv6_id
uri = 'api/dhcprelayv6/'
return self.post(uri, data=data) | List all DHCPRelayIPv4.
:param: Object DHCPRelayIPv4
:return: Following dictionary:
{
"networkipv6": <networkipv4_id>,
"id": <id>,
"ipv6": {
"block1": <block1>,
"block2": <block2>,
"block3": <block3>,
"block4": <block4>,
"block5": <block5>,
"block6": <block6>,
"block7": <block7>,
"block8": <block8>,
"ip_formated": "<string IPv6>",
"networkipv6": <networkipv6_id>,
"id": <ipv6_id>,
"description": "<string description>"
}
:raise NetworkAPIException: Falha ao acessar fonte de dados | entailment |
def list(self, networkipv6=None, ipv6=None):
"""List all DHCPRelayIPv6.
:param: networkipv6: networkipv6 id - list all dhcprelay filtering by networkipv6 id
ipv6: ipv6 id - list all dhcprelay filtering by ipv6 id
:return: Following dictionary:
[
{
"networkipv6": <networkipv4_id>,
"id": <id>,
"ipv6": {
"block1": <block1>,
"block2": <block2>,
"block3": <block3>,
"block4": <block4>,
"block5": <block5>,
"block6": <block6>,
"block7": <block7>,
"block8": <block8>,
"ip_formated": "<string IPv6>",
"networkipv6": <networkipv6_id>,
"id": <ipv6_id>,
"description": "<string description>"
},
{...}
]
:raise NetworkAPIException: Falha ao acessar fonte de dados
"""
uri = 'api/dhcprelayv6/?'
if networkipv6:
uri += 'networkipv6=%s&' % networkipv6
if ipv6:
uri += 'ipv6=%s' % ipv6
return self.get(uri) | List all DHCPRelayIPv6.
:param: networkipv6: networkipv6 id - list all dhcprelay filtering by networkipv6 id
ipv6: ipv6 id - list all dhcprelay filtering by ipv6 id
:return: Following dictionary:
[
{
"networkipv6": <networkipv4_id>,
"id": <id>,
"ipv6": {
"block1": <block1>,
"block2": <block2>,
"block3": <block3>,
"block4": <block4>,
"block5": <block5>,
"block6": <block6>,
"block7": <block7>,
"block8": <block8>,
"ip_formated": "<string IPv6>",
"networkipv6": <networkipv6_id>,
"id": <ipv6_id>,
"description": "<string description>"
},
{...}
]
:raise NetworkAPIException: Falha ao acessar fonte de dados | entailment |
def search(self, **kwargs):
"""
Method to search ipv6's based on extends search.
:param search: Dict containing QuerySets to find ipv6'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 ipv6's
"""
return super(ApiIPv6, self).get(self.prepare_url('api/v3/ipv6/',
kwargs)) | Method to search ipv6's based on extends search.
:param search: Dict containing QuerySets to find ipv6'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 ipv6's | entailment |
def delete(self, ids):
"""
Method to delete ipv6's by their ids
:param ids: Identifiers of ipv6's
:return: None
"""
url = build_uri_with_ids('api/v3/ipv6/%s/', ids)
return super(ApiIPv6, self).delete(url) | Method to delete ipv6's by their ids
:param ids: Identifiers of ipv6's
:return: None | entailment |
def update(self, ipv6s):
"""
Method to update ipv6's
:param ipv6s: List containing ipv6's desired to updated
:return: None
"""
data = {'ips': ipv6s}
ipv6s_ids = [str(ipv6.get('id')) for ipv6 in ipv6s]
return super(ApiIPv6, self).put('api/v3/ipv6/%s/' %
';'.join(ipv6s_ids), data) | Method to update ipv6's
:param ipv6s: List containing ipv6's desired to updated
:return: None | entailment |
def create(self, ipv6s):
"""
Method to create ipv6's
:param ipv6s: List containing vrf desired to be created on database
:return: None
"""
data = {'ips': ipv6s}
return super(ApiIPv6, self).post('api/v3/ipv6/', data) | Method to create ipv6's
:param ipv6s: List containing vrf desired to be created on database
:return: None | entailment |
def search(self, **kwargs):
"""
Method to search ipv4's based on extends search.
:param search: Dict containing QuerySets to find ipv4'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 ipv4's
"""
return super(ApiIPv4, self).get(self.prepare_url('api/v3/ipv4/',
kwargs)) | Method to search ipv4's based on extends search.
:param search: Dict containing QuerySets to find ipv4'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 ipv4's | entailment |
def delete(self, ids):
"""
Method to delete ipv4's by their ids
:param ids: Identifiers of ipv4's
:return: None
"""
url = build_uri_with_ids('api/v3/ipv4/%s/', ids)
return super(ApiIPv4, self).delete(url) | Method to delete ipv4's by their ids
:param ids: Identifiers of ipv4's
:return: None | entailment |
def update(self, ipv4s):
"""
Method to update ipv4's
:param ipv4s: List containing ipv4's desired to updated
:return: None
"""
data = {'ips': ipv4s}
ipv4s_ids = [str(ipv4.get('id')) for ipv4 in ipv4s]
return super(ApiIPv4, self).put('api/v3/ipv4/%s/' %
';'.join(ipv4s_ids), data) | Method to update ipv4's
:param ipv4s: List containing ipv4's desired to updated
:return: None | entailment |
def create(self, ipv4s):
"""
Method to create ipv4's
:param ipv4s: List containing ipv4's desired to be created on database
:return: None
"""
data = {'ips': ipv4s}
return super(ApiIPv4, self).post('api/v3/ipv4/', data) | Method to create ipv4's
:param ipv4s: List containing ipv4's desired to be created on database
:return: None | entailment |
def search(self, **kwargs):
"""
Method to search object group permissions general based on extends search.
:param search: Dict containing QuerySets to find object group permissions general.
: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 object group permissions general
"""
return super(ApiObjectGroupPermissionGeneral, self).get(self.prepare_url('api/v3/object-group-perm-general/',
kwargs)) | Method to search object group permissions general based on extends search.
:param search: Dict containing QuerySets to find object group permissions general.
: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 object group permissions general | entailment |
def delete(self, ids):
"""
Method to delete object group permissions general by their ids
:param ids: Identifiers of object group permissions general
:return: None
"""
url = build_uri_with_ids('api/v3/object-group-perm-general/%s/', ids)
return super(ApiObjectGroupPermissionGeneral, self).delete(url) | Method to delete object group permissions general by their ids
:param ids: Identifiers of object group permissions general
:return: None | entailment |
def update(self, ogpgs):
"""
Method to update object group permissions general
:param ogpgs: List containing object group permissions general desired to updated
:return: None
"""
data = {'ogpgs': ogpgs}
ogpgs_ids = [str(ogpg.get('id')) for ogpg in ogpgs]
return super(ApiObjectGroupPermissionGeneral, self).put('api/v3/object-group-perm-general/%s/' %
';'.join(ogpgs_ids), data) | Method to update object group permissions general
:param ogpgs: List containing object group permissions general desired to updated
:return: None | entailment |
def create(self, ogpgs):
"""
Method to create object group permissions general
:param ogpgs: List containing vrf desired to be created on database
:return: None
"""
data = {'ogpgs': ogpgs}
return super(ApiObjectGroupPermissionGeneral, self).post('api/v3/object-group-perm-general/', data) | Method to create object group permissions general
:param ogpgs: List containing vrf desired to be created on database
:return: None | entailment |
def search(self, **kwargs):
"""
Method to search ipv6's based on extends search.
:param search: Dict containing QuerySets to find ipv6'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 ipv6's
"""
return super(ApiV4IPv6, self).get(self.prepare_url('api/v4/ipv6/',
kwargs)) | Method to search ipv6's based on extends search.
:param search: Dict containing QuerySets to find ipv6'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 ipv6's | entailment |
def delete(self, ids):
"""
Method to delete ipv6's by their ids
:param ids: Identifiers of ipv6's
:return: None
"""
url = build_uri_with_ids('api/v4/ipv6/%s/', ids)
return super(ApiV4IPv6, self).delete(url) | Method to delete ipv6's by their ids
:param ids: Identifiers of ipv6's
:return: None | entailment |
def create(self, ipv6s):
"""
Method to create ipv6's
:param ipv6s: List containing vrf desired to be created on database
:return: None
"""
data = {'ips': ipv6s}
return super(ApiV4IPv6, self).post('api/v4/ipv6/', data) | Method to create ipv6's
:param ipv6s: List containing vrf desired to be created on database
:return: None | entailment |
def add(self, tipo_opcao, nome_opcao_txt):
"""Inserts a new Option VIP 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:
::
{'option_vip': {'id': < id >}}
: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.
"""
optionvip_map = dict()
optionvip_map['tipo_opcao'] = tipo_opcao
optionvip_map['nome_opcao_txt'] = nome_opcao_txt
code, xml = self.submit(
{'option_vip': optionvip_map}, 'POST', 'optionvip/')
return self.response(code, xml) | Inserts a new Option VIP 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:
::
{'option_vip': {'id': < id >}}
: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 alter(self, id_option_vip, tipo_opcao, nome_opcao_txt):
"""Change Option VIP from by the identifier.
:param id_option_vip: Identifier of the Option VIP. 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 VIP identifier is null and invalid.
:raise InvalidParameterError: The value of tipo_opcao or nome_opcao_txt is invalid.
:raise OptionVipNotFoundError: Option VIP not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_option_vip):
raise InvalidParameterError(
u'The identifier of Option VIP is invalid or was not informed.')
optionvip_map = dict()
optionvip_map['tipo_opcao'] = tipo_opcao
optionvip_map['nome_opcao_txt'] = nome_opcao_txt
url = 'optionvip/' + str(id_option_vip) + '/'
code, xml = self.submit({'option_vip': optionvip_map}, 'PUT', url)
return self.response(code, xml) | Change Option VIP from by the identifier.
:param id_option_vip: Identifier of the Option VIP. 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 VIP identifier is null and invalid.
:raise InvalidParameterError: The value of tipo_opcao or nome_opcao_txt is invalid.
:raise OptionVipNotFoundError: Option VIP 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_vip):
"""Remove Option VIP from by the identifier.
:param id_option_vip: Identifier of the Option VIP. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: Option VIP identifier is null and invalid.
:raise OptionVipNotFoundError: Option VIP not registered.
:raise OptionVipError: Option VIP associated with environment vip.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_option_vip):
raise InvalidParameterError(
u'The identifier of Option VIP is invalid or was not informed.')
url = 'optionvip/' + str(id_option_vip) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Remove Option VIP from by the identifier.
:param id_option_vip: Identifier of the Option VIP. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: Option VIP identifier is null and invalid.
:raise OptionVipNotFoundError: Option VIP not registered.
:raise OptionVipError: Option VIP associated with environment vip.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def get_option_vip(self, id_environment_vip):
"""Get all Option VIP by Environment Vip.
:return: Dictionary with the following structure:
::
{‘option_vip’: [{‘id’: < id >,
‘tipo_opcao’: < tipo_opcao >,
‘nome_opcao_txt’: < nome_opcao_txt >}, ... too option vips ...] }
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise DataBaseError: Can't connect to networkapi database.
:raise XMLError: Failed to generate the XML response.
"""
url = 'optionvip/environmentvip/' + str(id_environment_vip) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml, ['option_vip']) | Get all Option VIP by Environment Vip.
:return: Dictionary with the following structure:
::
{‘option_vip’: [{‘id’: < id >,
‘tipo_opcao’: < tipo_opcao >,
‘nome_opcao_txt’: < nome_opcao_txt >}, ... too option vips ...] }
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise DataBaseError: Can't connect to networkapi database.
:raise XMLError: Failed to generate the XML response. | entailment |
def associate(self, id_option_vip, id_environment_vip):
"""Create a relationship of OptionVip with EnvironmentVip.
:param id_option_vip: Identifier of the Option VIP. Integer value and greater than zero.
:param id_environment_vip: Identifier of the Environment VIP. Integer value and greater than zero.
:return: Following dictionary
::
{'opcoesvip_ambiente_xref': {'id': < id_opcoesvip_ambiente_xref >} }
:raise InvalidParameterError: Option VIP/Environment VIP identifier is null and/or invalid.
:raise OptionVipNotFoundError: Option VIP not registered.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise OptionVipError: Option vip is already associated with the environment vip.
:raise UserNotAuthorizedError: User does not have authorization to make this association.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_option_vip):
raise InvalidParameterError(
u'The identifier of Option VIP is invalid or was not informed.')
if not is_valid_int_param(id_environment_vip):
raise InvalidParameterError(
u'The identifier of Environment VIP is invalid or was not informed.')
url = 'optionvip/' + \
str(id_option_vip) + '/environmentvip/' + str(id_environment_vip) + '/'
code, xml = self.submit(None, 'PUT', url)
return self.response(code, xml) | Create a relationship of OptionVip with EnvironmentVip.
:param id_option_vip: Identifier of the Option VIP. Integer value and greater than zero.
:param id_environment_vip: Identifier of the Environment VIP. Integer value and greater than zero.
:return: Following dictionary
::
{'opcoesvip_ambiente_xref': {'id': < id_opcoesvip_ambiente_xref >} }
:raise InvalidParameterError: Option VIP/Environment VIP identifier is null and/or invalid.
:raise OptionVipNotFoundError: Option VIP not registered.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise OptionVipError: Option vip is already associated with the environment vip.
:raise UserNotAuthorizedError: User does not have authorization to make this association.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def buscar_timeout_opcvip(self, id_ambiente_vip):
"""Buscar nome_opcao_txt das Opcoes VIp quando tipo_opcao = 'Timeout' pelo environmentvip_id
:return: Dictionary with the following structure:
::
{‘timeout_opt’: ‘timeout_opt’: <'nome_opcao_txt'>}
:raise InvalidParameterError: Environment VIP identifier is null and invalid.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: finalidade_txt and cliente_txt is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_ambiente_vip):
raise InvalidParameterError(
u'The identifier of environment-vip is invalid or was not informed.')
url = 'environment-vip/get/timeout/' + str(id_ambiente_vip) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Buscar nome_opcao_txt das Opcoes VIp quando tipo_opcao = 'Timeout' pelo environmentvip_id
:return: Dictionary with the following structure:
::
{‘timeout_opt’: ‘timeout_opt’: <'nome_opcao_txt'>}
:raise InvalidParameterError: Environment VIP identifier is null and invalid.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: finalidade_txt and cliente_txt is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def buscar_rules(self, id_ambiente_vip, id_vip=''):
"""Search rules by environmentvip_id
:return: Dictionary with the following structure:
::
{'name_rule_opt': [{'name_rule_opt': <name>, 'id': <id>}, ...]}
:raise InvalidParameterError: Environment VIP identifier is null and invalid.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: finalidade_txt and cliente_txt is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
url = 'environment-vip/get/rules/' + \
str(id_ambiente_vip) + '/' + str(id_vip)
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Search rules by environmentvip_id
:return: Dictionary with the following structure:
::
{'name_rule_opt': [{'name_rule_opt': <name>, 'id': <id>}, ...]}
:raise InvalidParameterError: Environment VIP identifier is null and invalid.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: finalidade_txt and cliente_txt is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def buscar_healthchecks(self, id_ambiente_vip):
"""Search healthcheck by environmentvip_id
:return: Dictionary with the following structure:
::
{'healthcheck_opt': [{'name': <name>, 'id': <id>},...]}
:raise InvalidParameterError: Environment VIP identifier is null and invalid.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: id_ambiente_vip is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
url = 'environment-vip/get/healthcheck/' + str(id_ambiente_vip)
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml, ['healthcheck_opt']) | Search healthcheck by environmentvip_id
:return: Dictionary with the following structure:
::
{'healthcheck_opt': [{'name': <name>, 'id': <id>},...]}
:raise InvalidParameterError: Environment VIP identifier is null and invalid.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: id_ambiente_vip is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def buscar_idtrafficreturn_opcvip(self, nome_opcao_txt):
"""Search id of Option VIP when tipo_opcao = 'Retorno de trafego'
:return: Dictionary with the following structure:
::
{‘trafficreturn_opt’: ‘trafficreturn_opt’: <'id'>}
:raise InvalidParameterError: Environment VIP identifier is null and invalid.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: finalidade_txt and cliente_txt is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
trafficreturn_map = dict()
trafficreturn_map['trafficreturn'] = nome_opcao_txt
url = 'optionvip/trafficreturn/search/'
code, xml = self.submit({'trafficreturn_opt':trafficreturn_map }, 'POST', url)
return self.response(code, xml) | Search id of Option VIP when tipo_opcao = 'Retorno de trafego'
:return: Dictionary with the following structure:
::
{‘trafficreturn_opt’: ‘trafficreturn_opt’: <'id'>}
:raise InvalidParameterError: Environment VIP identifier is null and invalid.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: finalidade_txt and cliente_txt is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def listar_por_marca(self, id_brand):
"""List all Model by Brand.
:param id_brand: Identifier of the Brand. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{‘model’: [{‘id’: < id >,
‘nome’: < nome >,
‘id_marca’: < id_marca >}, ... too Model ...]}
:raise InvalidParameterError: The identifier of Brand is null and invalid.
:raise MarcaNaoExisteError: Brand not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
if not is_valid_int_param(id_brand):
raise InvalidParameterError(
u'The identifier of Brand is invalid or was not informed.')
url = 'model/brand/' + str(id_brand) + '/'
code, map = self.submit(None, 'GET', url)
key = 'model'
return get_list_map(self.response(code, map, [key]), key) | List all Model by Brand.
:param id_brand: Identifier of the Brand. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{‘model’: [{‘id’: < id >,
‘nome’: < nome >,
‘id_marca’: < id_marca >}, ... too Model ...]}
:raise InvalidParameterError: The identifier of Brand is null and invalid.
:raise MarcaNaoExisteError: Brand not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response | entailment |
def inserir(self, id_brand, name):
"""Inserts a new Model and returns its identifier
:param id_brand: Identifier of the Brand. Integer value and greater than zero.
:param name: Model name. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'model': {'id': < id_model >}}
:raise InvalidParameterError: The identifier of Brand or name is null and invalid.
:raise NomeMarcaModeloDuplicadoError: There is already a registered Model with the value of name and brand.
:raise MarcaNaoExisteError: Brand not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
model_map = dict()
model_map['name'] = name
model_map['id_brand'] = id_brand
code, xml = self.submit({'model': model_map}, 'POST', 'model/')
return self.response(code, xml) | Inserts a new Model and returns its identifier
:param id_brand: Identifier of the Brand. Integer value and greater than zero.
:param name: Model name. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'model': {'id': < id_model >}}
:raise InvalidParameterError: The identifier of Brand or name is null and invalid.
:raise NomeMarcaModeloDuplicadoError: There is already a registered Model with the value of name and brand.
:raise MarcaNaoExisteError: Brand not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response | entailment |
def alterar(self, id_model, id_brand, name):
"""Change Model from by the identifier.
:param id_model: Identifier of the Model. Integer value and greater than zero.
:param id_brand: Identifier of the Brand. Integer value and greater than zero.
:param name: Model name. String with a minimum 3 and maximum of 100 characters
:return: None
:raise InvalidParameterError: The identifier of Model, Brand or name is null and invalid.
:raise MarcaNaoExisteError: Brand not registered.
:raise ModeloEquipamentoNaoExisteError: Model not registered.
:raise NomeMarcaModeloDuplicadoError: There is already a registered Model with the value of name and brand.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
if not is_valid_int_param(id_model):
raise InvalidParameterError(
u'The identifier of Model is invalid or was not informed.')
model_map = dict()
model_map['name'] = name
model_map['id_brand'] = id_brand
url = 'model/' + str(id_model) + '/'
code, xml = self.submit({'model': model_map}, 'PUT', url)
return self.response(code, xml) | Change Model from by the identifier.
:param id_model: Identifier of the Model. Integer value and greater than zero.
:param id_brand: Identifier of the Brand. Integer value and greater than zero.
:param name: Model name. String with a minimum 3 and maximum of 100 characters
:return: None
:raise InvalidParameterError: The identifier of Model, Brand or name is null and invalid.
:raise MarcaNaoExisteError: Brand not registered.
:raise ModeloEquipamentoNaoExisteError: Model not registered.
:raise NomeMarcaModeloDuplicadoError: There is already a registered Model with the value of name and brand.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response | entailment |
def remover(self, id_model):
"""Remove Model from by the identifier.
:param id_model: Identifier of the Model. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Model is null and invalid.
:raise ModeloEquipamentoNaoExisteError: Model not registered.
:raise ModeloEquipamentoError: The Model is associated with a equipment.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
if not is_valid_int_param(id_model):
raise InvalidParameterError(
u'The identifier of Model is invalid or was not informed.')
url = 'model/' + str(id_model) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Remove Model from by the identifier.
:param id_model: Identifier of the Model. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Model is null and invalid.
:raise ModeloEquipamentoNaoExisteError: Model not registered.
:raise ModeloEquipamentoError: The Model is associated with a equipment.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response | entailment |
def listar_por_equipamento(self, id_equipamento):
"""List all interfaces of an equipment.
:param id_equipamento: Equipment identifier.
:return: Dictionary with the following:
::
{'interface':
[{'protegida': < protegida >,
'nome': < nome >,
'id_ligacao_front': < id_ligacao_front >,
'id_equipamento': < id_equipamento >,
'id': < id >,
'descricao': < descricao >,
'id_ligacao_back': < id_ligacao_back >}, ... other interfaces ...]}
:raise InvalidParameterError: Equipment identifier is invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(
u'Equipment id is invalid or was not informed.')
url = 'interface/equipamento/' + str(id_equipamento) + '/'
code, map = self.submit(None, 'GET', url)
key = 'interface'
return get_list_map(self.response(code, map, [key]), key) | List all interfaces of an equipment.
:param id_equipamento: Equipment identifier.
:return: Dictionary with the following:
::
{'interface':
[{'protegida': < protegida >,
'nome': < nome >,
'id_ligacao_front': < id_ligacao_front >,
'id_equipamento': < id_equipamento >,
'id': < id >,
'descricao': < descricao >,
'id_ligacao_back': < id_ligacao_back >}, ... other interfaces ...]}
:raise InvalidParameterError: Equipment identifier is invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def get_by_id(self, id_interface):
"""Get an interface by id.
:param id_interface: Interface identifier.
:return: Following dictionary:
::
{'interface': {'id': < id >,
'interface': < interface >,
'descricao': < descricao >,
'protegida': < protegida >,
'tipo_equip': < id_tipo_equipamento >,
'equipamento': < id_equipamento >,
'equipamento_nome': < nome_equipamento >
'ligacao_front': < id_ligacao_front >,
'nome_ligacao_front': < interface_name >,
'nome_equip_l_front': < equipment_name >,
'ligacao_back': < id_ligacao_back >,
'nome_ligacao_back': < interface_name >,
'nome_equip_l_back': < equipment_name > }}
:raise InvalidParameterError: Interface identifier is invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_interface):
raise InvalidParameterError(
u'Interface id is invalid or was not informed.')
url = 'interface/' + str(id_interface) + '/get/'
code, map = self.submit(None, 'GET', url)
return self.response(code, map) | Get an interface by id.
:param id_interface: Interface identifier.
:return: Following dictionary:
::
{'interface': {'id': < id >,
'interface': < interface >,
'descricao': < descricao >,
'protegida': < protegida >,
'tipo_equip': < id_tipo_equipamento >,
'equipamento': < id_equipamento >,
'equipamento_nome': < nome_equipamento >
'ligacao_front': < id_ligacao_front >,
'nome_ligacao_front': < interface_name >,
'nome_equip_l_front': < equipment_name >,
'ligacao_back': < id_ligacao_back >,
'nome_ligacao_back': < interface_name >,
'nome_equip_l_back': < equipment_name > }}
:raise InvalidParameterError: Interface identifier is invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def inserir(
self,
nome,
protegida,
descricao,
id_ligacao_front,
id_ligacao_back,
id_equipamento,
tipo=None,
vlan=None):
"""Insert new interface for an equipment.
:param nome: Interface name.
:param protegida: Indication of protected ('0' or '1').
:param descricao: Interface description.
:param id_ligacao_front: Front end link interface identifier.
:param id_ligacao_back: Back end link interface identifier.
:param id_equipamento: Equipment identifier.
:return: Dictionary with the following: {'interface': {'id': < id >}}
:raise EquipamentoNaoExisteError: Equipment does not exist.
:raise InvalidParameterError: The parameters nome, protegida and/or equipment id are none or invalid.
:raise NomeInterfaceDuplicadoParaEquipamentoError: There is already an interface with this name for this equipment.
:raise InterfaceNaoExisteError: Front link interface and/or back link interface doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
interface_map = dict()
interface_map['nome'] = nome
interface_map['protegida'] = protegida
interface_map['descricao'] = descricao
interface_map['id_ligacao_front'] = id_ligacao_front
interface_map['id_ligacao_back'] = id_ligacao_back
interface_map['id_equipamento'] = id_equipamento
interface_map['tipo'] = tipo
interface_map['vlan'] = vlan
code, xml = self.submit(
{'interface': interface_map}, 'POST', 'interface/')
return self.response(code, xml) | Insert new interface for an equipment.
:param nome: Interface name.
:param protegida: Indication of protected ('0' or '1').
:param descricao: Interface description.
:param id_ligacao_front: Front end link interface identifier.
:param id_ligacao_back: Back end link interface identifier.
:param id_equipamento: Equipment identifier.
:return: Dictionary with the following: {'interface': {'id': < id >}}
:raise EquipamentoNaoExisteError: Equipment does not exist.
:raise InvalidParameterError: The parameters nome, protegida and/or equipment id are none or invalid.
:raise NomeInterfaceDuplicadoParaEquipamentoError: There is already an interface with this name for this equipment.
:raise InterfaceNaoExisteError: Front link interface and/or back link interface doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def alterar(
self,
id_interface,
nome,
protegida,
descricao,
id_ligacao_front,
id_ligacao_back,
tipo=None,
vlan=None):
"""Edit an interface by its identifier.
Equipment identifier is not changed.
:param nome: Interface name.
:param protegida: Indication of protected ('0' or '1').
:param descricao: Interface description.
:param id_ligacao_front: Front end link interface identifier.
:param id_ligacao_back: Back end link interface identifier.
:param id_interface: Interface identifier.
:return: None
:raise InvalidParameterError: The parameters interface id, nome and protegida are none or invalid.
:raise NomeInterfaceDuplicadoParaEquipamentoError: There is already an interface with this name for this equipment.
:raise InterfaceNaoExisteError: Front link interface and/or back link interface doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_interface):
raise InvalidParameterError(
u'Interface id is invalid or was not informed.')
url = 'interface/' + str(id_interface) + '/'
interface_map = dict()
interface_map['nome'] = nome
interface_map['protegida'] = protegida
interface_map['descricao'] = descricao
interface_map['id_ligacao_front'] = id_ligacao_front
interface_map['id_ligacao_back'] = id_ligacao_back
interface_map['tipo'] = tipo
interface_map['vlan'] = vlan
code, xml = self.submit({'interface': interface_map}, 'PUT', url)
return self.response(code, xml) | Edit an interface by its identifier.
Equipment identifier is not changed.
:param nome: Interface name.
:param protegida: Indication of protected ('0' or '1').
:param descricao: Interface description.
:param id_ligacao_front: Front end link interface identifier.
:param id_ligacao_back: Back end link interface identifier.
:param id_interface: Interface identifier.
:return: None
:raise InvalidParameterError: The parameters interface id, nome and protegida are none or invalid.
:raise NomeInterfaceDuplicadoParaEquipamentoError: There is already an interface with this name for this equipment.
:raise InterfaceNaoExisteError: Front link interface and/or back link interface doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def remover(self, id_interface):
"""Remove an interface by its identifier.
:param id_interface: Interface identifier.
:return: None
:raise InterfaceNaoExisteError: Interface doesn't exist.
:raise InterfaceError: Interface is linked to another interface.
:raise InvalidParameterError: The interface identifier is invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_interface):
raise InvalidParameterError(
u'Interface id is invalid or was not informed.')
url = 'interface/' + str(id_interface) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Remove an interface by its identifier.
:param id_interface: Interface identifier.
:return: None
:raise InterfaceNaoExisteError: Interface doesn't exist.
:raise InterfaceError: Interface is linked to another interface.
:raise InvalidParameterError: The interface identifier is invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def remove_connection(self, id_interface, back_or_front):
"""
Remove a connection between two interfaces
:param id_interface: One side of relation
:param back_or_front: This side of relation is back(0) or front(1)
:return: None
:raise InterfaceInvalidBackFrontError: Front or Back of interfaces not match to remove connection
:raise InvalidParameterError: Interface id or back or front indicator is none or invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
msg_err = u'Parameter %s is invalid. Value: %s.'
if not is_valid_0_1(back_or_front):
raise InvalidParameterError(
msg_err %
('back_or_front', back_or_front))
if not is_valid_int_param(id_interface):
raise InvalidParameterError(
msg_err %
('id_interface', id_interface))
url = 'interface/%s/%s/' % (str(id_interface), str(back_or_front))
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Remove a connection between two interfaces
:param id_interface: One side of relation
:param back_or_front: This side of relation is back(0) or front(1)
:return: None
:raise InterfaceInvalidBackFrontError: Front or Back of interfaces not match to remove connection
:raise InvalidParameterError: Interface id or back or front indicator is none or invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def list_connections(self, nome_interface, id_equipamento):
"""List interfaces linked to back and front of specified interface.
:param nome_interface: Interface name.
:param id_equipamento: Equipment identifier.
:return: Dictionary with the following:
::
{'interfaces':[ {'id': < id >,
'interface': < nome >,
'descricao': < descricao >,
'protegida': < protegida >,
'equipamento': < id_equipamento >,
'tipo_equip': < id_tipo_equipamento >,
'ligacao_front': < id_ligacao_front >,
'nome_ligacao_front': < interface_name >,
'nome_equip_l_front': < equipment_name >,
'ligacao_back': < id_ligacao_back >,
'nome_ligacao_back': < interface_name >,
'nome_equip_l_back': < equipment_name > }, ... other interfaces ...]}
:raise InterfaceNaoExisteError: Interface doesn't exist or is not associated with this equipment.
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise InvalidParameterError: Interface name and/or equipment identifier are none or invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(
u'Equipment identifier is none or was not informed.')
if (nome_interface is None) or (nome_interface == ''):
raise InvalidParameterError(u'Interface name was not informed.')
# Temporário, remover. Fazer de outra forma.
nome_interface = nome_interface.replace('/', 's2it_replace')
url = 'interface/' + \
urllib.quote(nome_interface) + '/equipment/' + \
str(id_equipamento) + '/'
code, map = self.submit(None, 'GET', url)
key = 'interfaces'
return get_list_map(self.response(code, map, [key]), key) | List interfaces linked to back and front of specified interface.
:param nome_interface: Interface name.
:param id_equipamento: Equipment identifier.
:return: Dictionary with the following:
::
{'interfaces':[ {'id': < id >,
'interface': < nome >,
'descricao': < descricao >,
'protegida': < protegida >,
'equipamento': < id_equipamento >,
'tipo_equip': < id_tipo_equipamento >,
'ligacao_front': < id_ligacao_front >,
'nome_ligacao_front': < interface_name >,
'nome_equip_l_front': < equipment_name >,
'ligacao_back': < id_ligacao_back >,
'nome_ligacao_back': < interface_name >,
'nome_equip_l_back': < equipment_name > }, ... other interfaces ...]}
:raise InterfaceNaoExisteError: Interface doesn't exist or is not associated with this equipment.
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise InvalidParameterError: Interface name and/or equipment identifier are none or invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def list_all(self):
"""List all Permission.
:return: Dictionary with the following structure:
::
{'perms': [{ 'function' < function >, 'id': < id > }, ... more permissions ...]}
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
code, map = self.submit(None, 'GET', 'perms/all/')
key = 'perms'
return get_list_map(self.response(code, map, [key]), key) | List all Permission.
:return: Dictionary with the following structure:
::
{'perms': [{ 'function' < function >, 'id': < id > }, ... more permissions ...]}
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def search(self, **kwargs):
"""
Method to search ipv4's based on extends search.
:param search: Dict containing QuerySets to find ipv4'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 ipv4's
"""
return super(ApiV4IPv4, self).get(self.prepare_url('api/v4/ipv4/',
kwargs)) | Method to search ipv4's based on extends search.
:param search: Dict containing QuerySets to find ipv4'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 ipv4's | entailment |
def delete(self, ids):
"""
Method to delete ipv4's by their ids
:param ids: Identifiers of ipv4's
:return: None
"""
url = build_uri_with_ids('api/v4/ipv4/%s/', ids)
return super(ApiV4IPv4, self).delete(url) | Method to delete ipv4's by their ids
:param ids: Identifiers of ipv4's
:return: None | entailment |
def create(self, ipv4s):
"""
Method to create ipv4's
:param ipv4s: List containing ipv4's desired to be created on database
:return: None
"""
data = {'ips': ipv4s}
return super(ApiV4IPv4, self).post('api/v4/ipv4/', data) | Method to create ipv4's
:param ipv4s: List containing ipv4's desired to be created on database
:return: None | entailment |
def provisionar(self, equipamentos, vips):
"""Realiza a inserção ou alteração de um grupo virtual para o sistema de Orquestração de VM.
:param equipamentos: Lista de equipamentos gerada pelo método "add_equipamento" da
classe "EspecificacaoGrupoVirtual".
:param vips: Lista de VIPs gerada pelo método "add_vip" da classe "EspecificacaoGrupoVirtual".
:return: Retorno da operação de inserir ou alterar um grupo virtual:
::
{'equipamentos': {'equipamento': [{'id': < id>,
'nome': < nome>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>},
'vips': {'vip': [{'id': < id>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>}}, ... demais vips ...]}}, ... demais equipamentos...]},
'vips': {'vip': [{'id': < id>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>},
'requisicao_vip': {'id': < id>}}, ... demais vips...]}}
{'equipamentos': {'equipamento': [{'id': < id>,
'nome': < nome>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>},
'vips': {'vip': [{'id': < id>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>}}, ... demais vips ...]}}, ... demais equipamentos...]},
'vips': {'vip': [{'id': < id>,
'requisicao_vip': {'id': < id>}}, ... demais vips...]}}
:raise InvalidParameterError: Algum dado obrigatório não foi informado nas listas ou possui um valor inválido.
:raise XMLError: Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise VlanNaoExisteError: VLAN não cadastrada.
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise IPNaoDisponivelError: Não existe IP disponível para a VLAN informada.
:raise TipoEquipamentoNaoExisteError: Tipo de equipamento não cadastrado.
:raise ModeloEquipamentoNaoExisteError: Modelo do equipamento não cadastrado.
:raise GrupoEquipamentoNaoExisteError: Grupo de equipamentos não cadastrado.
:raise EquipamentoError: Equipamento com o nome duplicado ou
Equipamento do grupo “Equipamentos Orquestração” somente poderá ser
criado com tipo igual a “Servidor Virtual".
:raise IpNaoExisteError: IP não cadastrado.
:raise IpError: IP já está associado ao equipamento.
:raise VipNaoExisteError: Requisição de VIP não cadastrada.
:raise HealthCheckExpectNaoExisteError: Healthcheck_expect não cadastrado.
"""
code, map = self.submit(
{
'equipamentos': {
'equipamento': equipamentos}, 'vips': {
'vip': vips}}, 'POST', 'grupovirtual/')
return self.response(code, map, force_list=['equipamento', 'vip']) | Realiza a inserção ou alteração de um grupo virtual para o sistema de Orquestração de VM.
:param equipamentos: Lista de equipamentos gerada pelo método "add_equipamento" da
classe "EspecificacaoGrupoVirtual".
:param vips: Lista de VIPs gerada pelo método "add_vip" da classe "EspecificacaoGrupoVirtual".
:return: Retorno da operação de inserir ou alterar um grupo virtual:
::
{'equipamentos': {'equipamento': [{'id': < id>,
'nome': < nome>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>},
'vips': {'vip': [{'id': < id>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>}}, ... demais vips ...]}}, ... demais equipamentos...]},
'vips': {'vip': [{'id': < id>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>},
'requisicao_vip': {'id': < id>}}, ... demais vips...]}}
{'equipamentos': {'equipamento': [{'id': < id>,
'nome': < nome>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>},
'vips': {'vip': [{'id': < id>,
'ip': {'id': < id>,
'id_vlan': < id_vlan>,
'oct4': < oct4>,
'oct3': < oct3>,
'oct2': < oct2>,
'oct1': < oct1>,
'descricao': < descricao>}}, ... demais vips ...]}}, ... demais equipamentos...]},
'vips': {'vip': [{'id': < id>,
'requisicao_vip': {'id': < id>}}, ... demais vips...]}}
:raise InvalidParameterError: Algum dado obrigatório não foi informado nas listas ou possui um valor inválido.
:raise XMLError: Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise VlanNaoExisteError: VLAN não cadastrada.
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise IPNaoDisponivelError: Não existe IP disponível para a VLAN informada.
:raise TipoEquipamentoNaoExisteError: Tipo de equipamento não cadastrado.
:raise ModeloEquipamentoNaoExisteError: Modelo do equipamento não cadastrado.
:raise GrupoEquipamentoNaoExisteError: Grupo de equipamentos não cadastrado.
:raise EquipamentoError: Equipamento com o nome duplicado ou
Equipamento do grupo “Equipamentos Orquestração” somente poderá ser
criado com tipo igual a “Servidor Virtual".
:raise IpNaoExisteError: IP não cadastrado.
:raise IpError: IP já está associado ao equipamento.
:raise VipNaoExisteError: Requisição de VIP não cadastrada.
:raise HealthCheckExpectNaoExisteError: Healthcheck_expect não cadastrado. | entailment |
def remover_provisionamento(self, equipamentos, vips):
"""Remove o provisionamento de um grupo virtual para o sistema de Orquestração VM.
:param equipamentos: Lista de equipamentos gerada pelo método "add_equipamento_remove" da
classe "EspecificacaoGrupoVirtual".
:param vips: Lista de VIPs gerada pelo método "add_vip_remove" da classe "EspecificacaoGrupoVirtual".
:return: None
:raise InvalidParameterError: Algum dado obrigatório não foi informado nas listas ou possui um valor inválido.
:raise IpNaoExisteError: IP não cadastrado.
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise IpError: IP não está associado ao equipamento.
: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.
"""
code, map = self.submit({'equipamentos': {'equipamento': equipamentos}, 'vips': {
'vip': vips}}, 'DELETE', 'grupovirtual/')
return self.response(code, map) | Remove o provisionamento de um grupo virtual para o sistema de Orquestração VM.
:param equipamentos: Lista de equipamentos gerada pelo método "add_equipamento_remove" da
classe "EspecificacaoGrupoVirtual".
:param vips: Lista de VIPs gerada pelo método "add_vip_remove" da classe "EspecificacaoGrupoVirtual".
:return: None
:raise InvalidParameterError: Algum dado obrigatório não foi informado nas listas ou possui um valor inválido.
:raise IpNaoExisteError: IP não cadastrado.
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise IpError: IP não está associado ao equipamento.
: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 list_with_usergroup(self):
"""List all users and their user groups.
is_more -If more than 3 of groups of users or no, to control expansion Screen.
:return: Dictionary with the following structure:
::
{'usuario': [{'nome': < nome >,
'id': < id >,
'pwd': < pwd >,
'user': < user >,
'ativo': < ativo >,
'email': < email >,
'is_more': <True ou False>,
'grupos': [nome_grupo, ...more user groups...]}, ...more user...]}
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
url = 'usuario/get/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | List all users and their user groups.
is_more -If more than 3 of groups of users or no, to control expansion Screen.
:return: Dictionary with the following structure:
::
{'usuario': [{'nome': < nome >,
'id': < id >,
'pwd': < pwd >,
'user': < user >,
'ativo': < ativo >,
'email': < email >,
'is_more': <True ou False>,
'grupos': [nome_grupo, ...more user groups...]}, ...more user...]}
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def get_by_user_ldap(self, user_name):
"""Get user by the ldap name.
is_more -If more than 3 of groups of users or no, to control expansion Screen.
:return: Dictionary with the following structure:
::
{'usuario': [{'nome': < nome >,
'id': < id >,
'pwd': < pwd >,
'user': < user >,
'ativo': < ativo >,
'email': < email >,
'grupos': [nome_grupo, ...more user groups...],
'user_ldap': < user_ldap >}}
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
url = 'user/get/ldap/' + str(user_name) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Get user by the ldap name.
is_more -If more than 3 of groups of users or no, to control expansion Screen.
:return: Dictionary with the following structure:
::
{'usuario': [{'nome': < nome >,
'id': < id >,
'pwd': < pwd >,
'user': < user >,
'ativo': < ativo >,
'email': < email >,
'grupos': [nome_grupo, ...more user groups...],
'user_ldap': < user_ldap >}}
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def inserir(self, user, pwd, name, email, user_ldap):
"""Inserts a new User and returns its identifier.
The user will be created with active status.
:param user: Username. String with a minimum 3 and maximum of 45 characters
:param pwd: User password. String with a minimum 3 and maximum of 45 characters
:param name: User name. String with a minimum 3 and maximum of 200 characters
:param email: User Email. String with a minimum 3 and maximum of 300 characters
:param user_ldap: LDAP Username. String with a minimum 3 and maximum of 45 characters
:return: Dictionary with the following structure:
::
{'usuario': {'id': < id_user >}}
:raise InvalidParameterError: The identifier of User, user, pwd, name or email is null and invalid.
:raise UserUsuarioDuplicadoError: There is already a registered user with the value of user.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
user_map = dict()
user_map['user'] = user
user_map['password'] = pwd
user_map['name'] = name
user_map['email'] = email
user_map['user_ldap'] = user_ldap
code, xml = self.submit({'user': user_map}, 'POST', 'user/')
return self.response(code, xml) | Inserts a new User and returns its identifier.
The user will be created with active status.
:param user: Username. String with a minimum 3 and maximum of 45 characters
:param pwd: User password. String with a minimum 3 and maximum of 45 characters
:param name: User name. String with a minimum 3 and maximum of 200 characters
:param email: User Email. String with a minimum 3 and maximum of 300 characters
:param user_ldap: LDAP Username. String with a minimum 3 and maximum of 45 characters
:return: Dictionary with the following structure:
::
{'usuario': {'id': < id_user >}}
:raise InvalidParameterError: The identifier of User, user, pwd, name or email is null and invalid.
:raise UserUsuarioDuplicadoError: There is already a registered user with the value of user.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def alterar(self, id_user, user, password, nome, ativo, email, user_ldap):
"""Change User from by the identifier.
:param id_user: Identifier of the User. Integer value and greater than zero.
:param user: Username. String with a minimum 3 and maximum of 45 characters
:param password: User password. String with a minimum 3 and maximum of 45 characters
:param nome: User name. String with a minimum 3 and maximum of 200 characters
:param email: User Email. String with a minimum 3 and maximum of 300 characters
:param ativo: Status. 0 or 1
:param user_ldap: LDAP Username. String with a minimum 3 and maximum of 45 characters
:return: None
:raise InvalidParameterError: The identifier of User, user, pwd, name, email or active is null and invalid.
:raise UserUsuarioDuplicadoError: There is already a registered user with the value of user.
:raise UsuarioNaoExisteError: User not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_user):
raise InvalidParameterError(
u'The identifier of User is invalid or was not informed.')
url = 'user/' + str(id_user) + '/'
user_map = dict()
user_map['user'] = user
user_map['password'] = password
user_map['name'] = nome
user_map['active'] = ativo
user_map['email'] = email
user_map['user_ldap'] = user_ldap
code, xml = self.submit({'user': user_map}, 'PUT', url)
return self.response(code, xml) | Change User from by the identifier.
:param id_user: Identifier of the User. Integer value and greater than zero.
:param user: Username. String with a minimum 3 and maximum of 45 characters
:param password: User password. String with a minimum 3 and maximum of 45 characters
:param nome: User name. String with a minimum 3 and maximum of 200 characters
:param email: User Email. String with a minimum 3 and maximum of 300 characters
:param ativo: Status. 0 or 1
:param user_ldap: LDAP Username. String with a minimum 3 and maximum of 45 characters
:return: None
:raise InvalidParameterError: The identifier of User, user, pwd, name, email or active is null and invalid.
:raise UserUsuarioDuplicadoError: There is already a registered user with the value of user.
:raise UsuarioNaoExisteError: User not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def change_password(self, id_user, user_current_password, password):
"""Change password of User from by the identifier.
:param id_user: Identifier of the User. Integer value and greater than zero.
:param user_current_password: Senha atual do usuário.
:param password: Nova Senha do usuário.
:return: None
:raise UsuarioNaoExisteError: User not registered.
:raise InvalidParameterError: The identifier of User is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_user):
raise InvalidParameterError(
u'The identifier of User is invalid or was not informed.')
if password is None or password == "":
raise InvalidParameterError(
u'A nova senha do usuário é inválida ou não foi informada')
user_map = dict()
user_map['user_id'] = id_user
user_map['password'] = password
code, xml = self.submit(
{'user': user_map}, 'POST', 'user-change-pass/')
return self.response(code, xml) | Change password of User from by the identifier.
:param id_user: Identifier of the User. Integer value and greater than zero.
:param user_current_password: Senha atual do usuário.
:param password: Nova Senha do usuário.
:return: None
:raise UsuarioNaoExisteError: User not registered.
:raise InvalidParameterError: The identifier of User is null and invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def authenticate(self, username, password, is_ldap_user):
"""Get user by username and password and their permissions.
:param username: Username. String with a minimum 3 and maximum of 45 characters
:param password: User password. String with a minimum 3 and maximum of 45 characters
:return: Following dictionary:
::
{'user': {'id': < id >}
{'user': < user >}
{'nome': < nome >}
{'pwd': < pwd >}
{'email': < email >}
{'active': < active >}
{'permission':[ {'<function>': { 'write': <value>, 'read': <value>}, ... more function ... ] } } }
:raise InvalidParameterError: The value of username or password is invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
user_map = dict()
user_map['username'] = username
user_map['password'] = password
user_map['is_ldap_user'] = is_ldap_user
code, xml = self.submit({'user': user_map}, 'POST', 'authenticate/')
return self.response(code, xml) | Get user by username and password and their permissions.
:param username: Username. String with a minimum 3 and maximum of 45 characters
:param password: User password. String with a minimum 3 and maximum of 45 characters
:return: Following dictionary:
::
{'user': {'id': < id >}
{'user': < user >}
{'nome': < nome >}
{'pwd': < pwd >}
{'email': < email >}
{'active': < active >}
{'permission':[ {'<function>': { 'write': <value>, 'read': <value>}, ... more function ... ] } } }
:raise InvalidParameterError: The value of username or password is invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def authenticate_ldap(self, username, password):
"""Get user by username and password and their permissions.
:param username: Username. String with a minimum 3 and maximum of 45 characters
:param password: User password. String with a minimum 3 and maximum of 45 characters
:return: Following dictionary:
::
{'user': {'id': < id >}
{'user': < user >}
{'nome': < nome >}
{'pwd': < pwd >}
{'email': < email >}
{'active': < active >}
{'permission':[ {'<function>': { 'write': <value>, 'read': <value>}, ... more function ... ] } } }
:raise InvalidParameterError: The value of username or password is invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
user_map = dict()
user_map['username'] = username
user_map['password'] = password
code, xml = self.submit(
{'user': user_map}, 'POST', 'authenticate/ldap/')
return self.response(code, xml) | Get user by username and password and their permissions.
:param username: Username. String with a minimum 3 and maximum of 45 characters
:param password: User password. String with a minimum 3 and maximum of 45 characters
:return: Following dictionary:
::
{'user': {'id': < id >}
{'user': < user >}
{'nome': < nome >}
{'pwd': < pwd >}
{'email': < email >}
{'active': < active >}
{'permission':[ {'<function>': { 'write': <value>, 'read': <value>}, ... more function ... ] } } }
:raise InvalidParameterError: The value of username or password is invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def listar(self):
"""List all access types.
:return: Dictionary with structure:
::
{‘tipo_acesso’: [{‘id’: < id >,
‘protocolo’: < protocolo >}, ... other access types ...]}
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
code, map = self.submit(None, 'GET', 'tipoacesso/')
key = 'tipo_acesso'
return get_list_map(self.response(code, map, [key]), key) | List all access types.
:return: Dictionary with structure:
::
{‘tipo_acesso’: [{‘id’: < id >,
‘protocolo’: < protocolo >}, ... other access types ...]}
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def inserir(self, protocolo):
"""Insert new access type and returns its identifier.
:param protocolo: Protocol.
:return: Dictionary with structure: {‘tipo_acesso’: {‘id’: < id >}}
:raise ProtocoloTipoAcessoDuplicadoError: Protocol already exists.
:raise InvalidParameterError: Protocol value is invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
tipo_acesso_map = dict()
tipo_acesso_map['protocolo'] = protocolo
code, xml = self.submit(
{'tipo_acesso': tipo_acesso_map}, 'POST', 'tipoacesso/')
return self.response(code, xml) | Insert new access type and returns its identifier.
:param protocolo: Protocol.
:return: Dictionary with structure: {‘tipo_acesso’: {‘id’: < id >}}
:raise ProtocoloTipoAcessoDuplicadoError: Protocol already exists.
:raise InvalidParameterError: Protocol value is invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def alterar(self, id_tipo_acesso, protocolo):
"""Edit access type by its identifier.
:param id_tipo_acesso: Access type identifier.
:param protocolo: Protocol.
:return: None
:raise ProtocoloTipoAcessoDuplicadoError: Protocol already exists.
:raise InvalidParameterError: Protocol value is invalid or none.
:raise TipoAcessoNaoExisteError: Access type doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_tipo_acesso):
raise InvalidParameterError(
u'Access type id is invalid or was not informed.')
tipo_acesso_map = dict()
tipo_acesso_map['protocolo'] = protocolo
url = 'tipoacesso/' + str(id_tipo_acesso) + '/'
code, xml = self.submit({'tipo_acesso': tipo_acesso_map}, 'PUT', url)
return self.response(code, xml) | Edit access type by its identifier.
:param id_tipo_acesso: Access type identifier.
:param protocolo: Protocol.
:return: None
:raise ProtocoloTipoAcessoDuplicadoError: Protocol already exists.
:raise InvalidParameterError: Protocol value is invalid or none.
:raise TipoAcessoNaoExisteError: Access type doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def remover(self, id_tipo_acesso):
"""Removes access type by its identifier.
:param id_tipo_acesso: Access type identifier.
:return: None
:raise TipoAcessoError: Access type associated with equipment, cannot be removed.
:raise InvalidParameterError: Protocol value is invalid or none.
:raise TipoAcessoNaoExisteError: Access type doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_tipo_acesso):
raise InvalidParameterError(
u'Access type id is invalid or was not informed.')
url = 'tipoacesso/' + str(id_tipo_acesso) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Removes access type by its identifier.
:param id_tipo_acesso: Access type identifier.
:return: None
:raise TipoAcessoError: Access type associated with equipment, cannot be removed.
:raise InvalidParameterError: Protocol value is invalid or none.
:raise TipoAcessoNaoExisteError: Access type doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def inserir(self, type, description):
"""Inserts a new Script Type and returns its identifier.
:param type: Script Type type. String with a minimum 3 and maximum of 40 characters
:param description: Script Type description. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'script_type': {'id': < id_script_type >}}
:raise InvalidParameterError: Type or description is null and invalid.
:raise NomeTipoRoteiroDuplicadoError: Type script already registered with informed.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
script_type_map = dict()
script_type_map['type'] = type
script_type_map['description'] = description
code, xml = self.submit(
{'script_type': script_type_map}, 'POST', 'scripttype/')
return self.response(code, xml) | Inserts a new Script Type and returns its identifier.
:param type: Script Type type. String with a minimum 3 and maximum of 40 characters
:param description: Script Type description. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'script_type': {'id': < id_script_type >}}
:raise InvalidParameterError: Type or description is null and invalid.
:raise NomeTipoRoteiroDuplicadoError: Type script already registered with informed.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def alterar(self, id_script_type, type, description):
"""Change Script Type from by the identifier.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:param type: Script Type type. String with a minimum 3 and maximum of 40 characters
:param description: Script Type description. String with a minimum 3 and maximum of 100 characters
:return: None
:raise InvalidParameterError: The identifier of Script Type, type or description is null and invalid.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise NomeTipoRoteiroDuplicadoError: Type script already registered with informed.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_script_type):
raise InvalidParameterError(
u'The identifier of Script Type is invalid or was not informed.')
script_type_map = dict()
script_type_map['type'] = type
script_type_map['description'] = description
url = 'scripttype/' + str(id_script_type) + '/'
code, xml = self.submit({'script_type': script_type_map}, 'PUT', url)
return self.response(code, xml) | Change Script Type from by the identifier.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:param type: Script Type type. String with a minimum 3 and maximum of 40 characters
:param description: Script Type description. String with a minimum 3 and maximum of 100 characters
:return: None
:raise InvalidParameterError: The identifier of Script Type, type or description is null and invalid.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise NomeTipoRoteiroDuplicadoError: Type script already registered with informed.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def remover(self, id_script_type):
"""Remove Script Type from by the identifier.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Script Type is null and invalid.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise TipoRoteiroError: Script type is associated with a script.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_script_type):
raise InvalidParameterError(
u'The identifier of Script Type is invalid or was not informed.')
url = 'scripttype/' + str(id_script_type) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Remove Script Type from by the identifier.
:param id_script_type: Identifier of the Script Type. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Script Type is null and invalid.
:raise TipoRoteiroNaoExisteError: Script Type not registered.
:raise TipoRoteiroError: Script type is associated with a script.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def pool_by_environmentvip(self, environment_vip_id):
"""
Method to return list object pool by environment vip id
Param environment_vip_id: environment vip id
Return list object pool
"""
uri = 'api/v3/pool/environment-vip/%s/' % environment_vip_id
return super(ApiPool, self).get(uri) | Method to return list object pool by environment vip id
Param environment_vip_id: environment vip id
Return list object pool | entailment |
def pool_by_id(self, pool_id):
"""
Method to return object pool by id
Param pool_id: pool id
Returns object pool
"""
uri = 'api/v3/pool/%s/' % pool_id
return super(ApiPool, self).get(uri) | Method to return object pool by id
Param pool_id: pool id
Returns object pool | entailment |
def get_pool_details(self, pool_id):
"""
Method to return object pool by id
Param pool_id: pool id
Returns object pool
"""
uri = 'api/v3/pool/details/%s/' % pool_id
return super(ApiPool, self).get(uri) | Method to return object pool by id
Param pool_id: pool id
Returns object pool | entailment |
def search(self, **kwargs):
"""
Method to search pool's based on extends search.
:param search: Dict containing QuerySets to find pool's.
:param include: Array containing fields to include on response.
:param exclude: Array containing fields to exclude on response.
:param fields: Array containing fields to override default fields.
:param kind: Determine if result will be detailed ('detail') or basic ('basic').
:return: Dict containing pool's
"""
return super(ApiPool, self).get(self.prepare_url('api/v3/pool/',
kwargs)) | Method to search pool's based on extends search.
:param search: Dict containing QuerySets to find pool's.
:param include: Array containing fields to include on response.
:param exclude: Array containing fields to exclude on response.
:param fields: Array containing fields to override default fields.
:param kind: Determine if result will be detailed ('detail') or basic ('basic').
:return: Dict containing pool's | entailment |
def delete(self, ids):
"""
Method to delete pool's by their ids
:param ids: Identifiers of pool's
:return: None
"""
url = build_uri_with_ids('api/v3/pool/%s/', ids)
return super(ApiPool, self).delete(url) | Method to delete pool's by their ids
:param ids: Identifiers of pool's
:return: None | entailment |
def update(self, pools):
"""
Method to update pool's
:param pools: List containing pool's desired to updated
:return: None
"""
data = {'server_pools': pools}
pools_ids = [str(pool.get('id'))
for pool in pools]
return super(ApiPool, self).put('api/v3/pool/%s/' %
';'.join(pools_ids), data) | Method to update pool's
:param pools: List containing pool's desired to updated
:return: None | entailment |
def create(self, pools):
"""
Method to create pool's
:param pools: List containing pool's desired to be created on database
:return: None
"""
data = {'server_pools': pools}
return super(ApiPool, self).post('api/v3/pool/', data) | Method to create pool's
:param pools: List containing pool's desired to be created on database
:return: None | entailment |
def get_real_related(self, id_equip):
"""
Find reals related with equipment
:param id_equip: Identifier of equipment
:return: Following dictionary:
::
{'vips': [{'port_real': < port_real >,
'server_pool_member_id': < server_pool_member_id >,
'ip': < ip >,
'port_vip': < port_vip >,
'host_name': < host_name >,
'id_vip': < id_vip >, ...],
'equip_name': < equip_name > }}
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise InvalidParameterError: Some parameter was invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
url = 'equipamento/get_real_related/' + str(id_equip) + '/'
code, xml = self.submit(None, 'GET', url)
data = self.response(code, xml)
return data | Find reals related with equipment
:param id_equip: Identifier of equipment
:return: Following dictionary:
::
{'vips': [{'port_real': < port_real >,
'server_pool_member_id': < server_pool_member_id >,
'ip': < ip >,
'port_vip': < port_vip >,
'host_name': < host_name >,
'id_vip': < id_vip >, ...],
'equip_name': < equip_name > }}
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise InvalidParameterError: Some parameter was invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def find_equips(
self,
name,
iexact,
environment,
equip_type,
group,
ip,
pagination):
"""
Find vlans by all search parameters
:param name: Filter by vlan name column
:param iexact: Filter by name will be exact?
:param environment: Filter by environment ID related
:param equip_type: Filter by equipment_type ID related
:param group: Filter by equipment group ID related
:param ip: Filter by each octs in ips related
:param pagination: Class with all data needed to paginate
:return: Following dictionary:
::
{'equipamento': {'id': < id_vlan >,
'nome': < nome_vlan >,
'num_vlan': < num_vlan >,
'id_ambiente': < id_ambiente >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'ativada': < ativada >,
'ambiente_name': < divisao_dc-ambiente_logico-grupo_l3 >
'redeipv4': [ { all networkipv4 related } ],
'redeipv6': [ { all networkipv6 related } ] },
'total': {< total_registros >} }
:raise InvalidParameterError: Some parameter was invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not isinstance(pagination, Pagination):
raise InvalidParameterError(
u"Invalid parameter: pagination must be a class of type 'Pagination'.")
equip_map = dict()
equip_map["start_record"] = pagination.start_record
equip_map["end_record"] = pagination.end_record
equip_map["asorting_cols"] = pagination.asorting_cols
equip_map["searchable_columns"] = pagination.searchable_columns
equip_map["custom_search"] = pagination.custom_search
equip_map["nome"] = name
equip_map["exato"] = iexact
equip_map["ambiente"] = environment
equip_map["tipo_equipamento"] = equip_type
equip_map["grupo"] = group
equip_map["ip"] = ip
url = "equipamento/find/"
code, xml = self.submit({"equipamento": equip_map}, "POST", url)
key = "equipamento"
return get_list_map(
self.response(
code, xml, [
key, "ips", "grupos"]), key) | Find vlans by all search parameters
:param name: Filter by vlan name column
:param iexact: Filter by name will be exact?
:param environment: Filter by environment ID related
:param equip_type: Filter by equipment_type ID related
:param group: Filter by equipment group ID related
:param ip: Filter by each octs in ips related
:param pagination: Class with all data needed to paginate
:return: Following dictionary:
::
{'equipamento': {'id': < id_vlan >,
'nome': < nome_vlan >,
'num_vlan': < num_vlan >,
'id_ambiente': < id_ambiente >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'ativada': < ativada >,
'ambiente_name': < divisao_dc-ambiente_logico-grupo_l3 >
'redeipv4': [ { all networkipv4 related } ],
'redeipv6': [ { all networkipv6 related } ] },
'total': {< total_registros >} }
:raise InvalidParameterError: Some parameter was invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def inserir(self, name, id_equipment_type, id_model, id_group, maintenance=False):
"""Inserts a new Equipment and returns its identifier
Além de inserir o equipamento, a networkAPI também associa o equipamento
ao grupo informado.
:param name: Equipment name. String with a minimum 3 and maximum of 30 characters
:param id_equipment_type: Identifier of the Equipment Type. Integer value and greater than zero.
:param id_model: Identifier of the Model. Integer value and greater than zero.
:param id_group: Identifier of the Group. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'equipamento': {'id': < id_equipamento >},
'equipamento_grupo': {'id': < id_grupo_equipamento >}}
:raise InvalidParameterError: The identifier of Equipment type, model, group or name is null and invalid.
:raise TipoEquipamentoNaoExisteError: Equipment Type not registered.
:raise ModeloEquipamentoNaoExisteError: Model not registered.
:raise GrupoEquipamentoNaoExisteError: Group not registered.
:raise EquipamentoError: Equipamento com o nome duplicado ou
Equipamento do grupo “Equipamentos Orquestração” somente poderá ser
criado com tipo igual a “Servidor Virtual".
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
equip_map = dict()
equip_map['id_tipo_equipamento'] = id_equipment_type
equip_map['id_modelo'] = id_model
equip_map['nome'] = name
equip_map['id_grupo'] = id_group
equip_map['maintenance'] = maintenance
code, xml = self.submit(
{'equipamento': equip_map}, 'POST', 'equipamento/')
return self.response(code, xml) | Inserts a new Equipment and returns its identifier
Além de inserir o equipamento, a networkAPI também associa o equipamento
ao grupo informado.
:param name: Equipment name. String with a minimum 3 and maximum of 30 characters
:param id_equipment_type: Identifier of the Equipment Type. Integer value and greater than zero.
:param id_model: Identifier of the Model. Integer value and greater than zero.
:param id_group: Identifier of the Group. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'equipamento': {'id': < id_equipamento >},
'equipamento_grupo': {'id': < id_grupo_equipamento >}}
:raise InvalidParameterError: The identifier of Equipment type, model, group or name is null and invalid.
:raise TipoEquipamentoNaoExisteError: Equipment Type not registered.
:raise ModeloEquipamentoNaoExisteError: Model not registered.
:raise GrupoEquipamentoNaoExisteError: Group not registered.
:raise EquipamentoError: Equipamento com o nome duplicado ou
Equipamento do grupo “Equipamentos Orquestração” somente poderá ser
criado com tipo igual a “Servidor Virtual".
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response | entailment |
def edit(self, id_equip, nome, id_tipo_equipamento, id_modelo, maintenance=None):
"""Change Equipment from by the identifier.
:param id_equip: Identifier of the Equipment. Integer value and greater than zero.
:param nome: Equipment name. String with a minimum 3 and maximum of 30 characters
:param id_tipo_equipamento: Identifier of the Equipment Type. Integer value and greater than zero.
:param id_modelo: Identifier of the Model. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Equipment, model, equipment type or name is null and invalid.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise TipoEquipamentoNaoExisteError: Equipment Type not registered.
:raise ModeloEquipamentoNaoExisteError: Model not registered.
:raise GrupoEquipamentoNaoExisteError: Group not registered.
:raise EquipamentoError: Equipamento com o nome duplicado ou
Equipamento do grupo “Equipamentos Orquestração” somente poderá ser
criado com tipo igual a “Servidor Virtual".
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
equip_map = dict()
equip_map['id_equip'] = id_equip
equip_map['id_tipo_equipamento'] = id_tipo_equipamento
equip_map['id_modelo'] = id_modelo
equip_map['nome'] = nome
if maintenance is not None:
equip_map['maintenance'] = maintenance
url = 'equipamento/edit/' + str(id_equip) + '/'
code, xml = self.submit({'equipamento': equip_map}, 'POST', url)
return self.response(code, xml) | Change Equipment from by the identifier.
:param id_equip: Identifier of the Equipment. Integer value and greater than zero.
:param nome: Equipment name. String with a minimum 3 and maximum of 30 characters
:param id_tipo_equipamento: Identifier of the Equipment Type. Integer value and greater than zero.
:param id_modelo: Identifier of the Model. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Equipment, model, equipment type or name is null and invalid.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise TipoEquipamentoNaoExisteError: Equipment Type not registered.
:raise ModeloEquipamentoNaoExisteError: Model not registered.
:raise GrupoEquipamentoNaoExisteError: Group not registered.
:raise EquipamentoError: Equipamento com o nome duplicado ou
Equipamento do grupo “Equipamentos Orquestração” somente poderá ser
criado com tipo igual a “Servidor Virtual".
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response | entailment |
def criar_ip(self, id_vlan, id_equipamento, descricao):
"""Aloca um IP em uma VLAN para um equipamento.
Insere um novo IP para a VLAN e o associa ao equipamento.
:param id_vlan: Identificador da vlan.
:param id_equipamento: Identificador do equipamento.
:param descricao: Descriçao do IP.
:return: Dicionário com a seguinte estrutura:
::
{'ip': {'id': < id_ip >,
'id_network_ipv4': < id_network_ipv4 >,
'oct1’: < oct1 >,
'oct2': < oct2 >,
'oct3': < oct3 >,
'oct4': < oct4 >,
'descricao': < descricao >}}
:raise InvalidParameterError: O identificador da VLAN e/ou do equipamento são nulos ou inválidos.
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise VlanNaoExisteError: VLAN não cadastrada.
:raise IPNaoDisponivelError: Não existe IP disponível para a VLAN informada.
: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.
"""
ip_map = dict()
ip_map['id_vlan'] = id_vlan
ip_map['descricao'] = descricao
ip_map['id_equipamento'] = id_equipamento
code, xml = self.submit({'ip': ip_map}, 'POST', 'ip/')
return self.response(code, xml) | Aloca um IP em uma VLAN para um equipamento.
Insere um novo IP para a VLAN e o associa ao equipamento.
:param id_vlan: Identificador da vlan.
:param id_equipamento: Identificador do equipamento.
:param descricao: Descriçao do IP.
:return: Dicionário com a seguinte estrutura:
::
{'ip': {'id': < id_ip >,
'id_network_ipv4': < id_network_ipv4 >,
'oct1’: < oct1 >,
'oct2': < oct2 >,
'oct3': < oct3 >,
'oct4': < oct4 >,
'descricao': < descricao >}}
:raise InvalidParameterError: O identificador da VLAN e/ou do equipamento são nulos ou inválidos.
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise VlanNaoExisteError: VLAN não cadastrada.
:raise IPNaoDisponivelError: Não existe IP disponível para a VLAN informada.
: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_ipv4(self, id_network_ipv4, id_equipamento, descricao):
"""Allocate an IP on a network to an equipment.
Insert new IP for network and associate to the equipment
:param id_network_ipv4: ID for NetworkIPv4.
:param id_equipamento: ID for Equipment.
:param descricao: Description for IP.
:return: Following dictionary:
::
{'ip': {'id': < id_ip >,
'id_network_ipv4': < id_network_ipv4 >,
'oct1’: < oct1 >,
'oct2': < oct2 >,
'oct3': < oct3 >,
'oct4': < oct4 >,
'descricao': < descricao >}}
:raise InvalidParameterError: Invalid ID for NetworkIPv4 or Equipment.
:raise InvalidParameterError: The value of description is invalid.
:raise EquipamentoNaoExisteError: Equipment not found.
:raise RedeIPv4NaoExisteError: NetworkIPv4 not found.
:raise IPNaoDisponivelError: There is no network address is available to create the VLAN.
:raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
ip_map = dict()
ip_map['id_network_ipv4'] = id_network_ipv4
ip_map['description'] = descricao
ip_map['id_equipment'] = id_equipamento
code, xml = self.submit({'ip': ip_map}, 'POST', 'ipv4/')
return self.response(code, xml) | Allocate an IP on a network to an equipment.
Insert new IP for network and associate to the equipment
:param id_network_ipv4: ID for NetworkIPv4.
:param id_equipamento: ID for Equipment.
:param descricao: Description for IP.
:return: Following dictionary:
::
{'ip': {'id': < id_ip >,
'id_network_ipv4': < id_network_ipv4 >,
'oct1’: < oct1 >,
'oct2': < oct2 >,
'oct3': < oct3 >,
'oct4': < oct4 >,
'descricao': < descricao >}}
:raise InvalidParameterError: Invalid ID for NetworkIPv4 or Equipment.
:raise InvalidParameterError: The value of description is invalid.
:raise EquipamentoNaoExisteError: Equipment not found.
:raise RedeIPv4NaoExisteError: NetworkIPv4 not found.
:raise IPNaoDisponivelError: There is no network address is available to create the VLAN.
:raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def add_ipv6(self, id_network_ipv6, id_equip, description):
"""Allocate an IP on a network to an equipment.
Insert new IP for network and associate to the equipment
:param id_network_ipv6: ID for NetworkIPv6.
:param id_equip: ID for Equipment.
:param description: Description for IP.
:return: Following dictionary:
::
{'ip': {'id': < id_ip >,
'id_network_ipv6': < id_network_ipv6 >,
'bloco1': < bloco1 >,
'bloco2': < bloco2 >,
'bloco3': < bloco3 >,
'bloco4': < bloco4 >,
'bloco5': < bloco5 >,
'bloco6': < bloco6 >,
'bloco7': < bloco7 >,
'bloco8': < bloco8 >,
'descricao': < descricao >}}
:raise InvalidParameterError: NetworkIPv6 identifier or Equipament identifier is null and invalid,
:raise InvalidParameterError: The value of description is invalid.
:raise EquipamentoNaoExisteError: Equipment not found.
:raise RedeIPv6NaoExisteError: NetworkIPv6 not found.
:raise IPNaoDisponivelError: There is no network address is available to create the VLAN.
:raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
ip_map = dict()
ip_map['id_network_ipv6'] = id_network_ipv6
ip_map['description'] = description
ip_map['id_equip'] = id_equip
code, xml = self.submit({'ip': ip_map}, 'POST', 'ipv6/')
return self.response(code, xml) | Allocate an IP on a network to an equipment.
Insert new IP for network and associate to the equipment
:param id_network_ipv6: ID for NetworkIPv6.
:param id_equip: ID for Equipment.
:param description: Description for IP.
:return: Following dictionary:
::
{'ip': {'id': < id_ip >,
'id_network_ipv6': < id_network_ipv6 >,
'bloco1': < bloco1 >,
'bloco2': < bloco2 >,
'bloco3': < bloco3 >,
'bloco4': < bloco4 >,
'bloco5': < bloco5 >,
'bloco6': < bloco6 >,
'bloco7': < bloco7 >,
'bloco8': < bloco8 >,
'descricao': < descricao >}}
:raise InvalidParameterError: NetworkIPv6 identifier or Equipament identifier is null and invalid,
:raise InvalidParameterError: The value of description is invalid.
:raise EquipamentoNaoExisteError: Equipment not found.
:raise RedeIPv6NaoExisteError: NetworkIPv6 not found.
:raise IPNaoDisponivelError: There is no network address is available to create the VLAN.
:raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def remover_ip(self, id_equipamento, id_ip):
"""Removes association of IP and Equipment.
If IP has no other association with equipments, IP is also removed.
:param id_equipamento: Equipment identifier
:param id_ip: IP identifier.
:return: None
:raise VipIpError: Ip can't be removed because there is a created Vip Request.
:raise IpEquipCantDissociateFromVip: Equipment is the last balancer for created Vip Request.
:raise IpError: IP not associated with equipment.
:raise InvalidParameterError: Equipment or IP identifier is none or invalid.
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi failed to build response XML.
"""
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(
u'O identificador do equipamento é inválido ou não foi informado.')
if not is_valid_int_param(id_ip):
raise InvalidParameterError(
u'O identificador do ip é inválido ou não foi informado.')
url = 'ip/' + str(id_ip) + '/equipamento/' + str(id_equipamento) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Removes association of IP and Equipment.
If IP has no other association with equipments, IP is also removed.
:param id_equipamento: Equipment identifier
:param id_ip: IP identifier.
:return: None
:raise VipIpError: Ip can't be removed because there is a created Vip Request.
:raise IpEquipCantDissociateFromVip: Equipment is the last balancer for created Vip Request.
:raise IpError: IP not associated with equipment.
:raise InvalidParameterError: Equipment or IP identifier is none or invalid.
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi failed to build response XML. | entailment |
def associate_ipv6(self, id_equip, id_ipv6):
"""Associates an IPv6 to a equipament.
:param id_equip: Identifier of the equipment. Integer value and greater than zero.
:param id_ipv6: Identifier of the ip. Integer value and greater than zero.
:return: Dictionary with the following structure:
{'ip_equipamento': {'id': < id_ip_do_equipamento >}}
:raise EquipamentoNaoExisteError: Equipment is not registered.
:raise IpNaoExisteError: IP not registered.
:raise IpError: IP is already associated with the equipment.
:raise InvalidParameterError: Identifier of the equipment and/or IP is null or invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_equip):
raise InvalidParameterError(
u'The identifier of equipment is invalid or was not informed.')
if not is_valid_int_param(id_ipv6):
raise InvalidParameterError(
u'The identifier of ip is invalid or was not informed.')
url = 'ipv6/' + str(id_ipv6) + '/equipment/' + str(id_equip) + '/'
code, xml = self.submit(None, 'PUT', url)
return self.response(code, xml) | Associates an IPv6 to a equipament.
:param id_equip: Identifier of the equipment. Integer value and greater than zero.
:param id_ipv6: Identifier of the ip. Integer value and greater than zero.
:return: Dictionary with the following structure:
{'ip_equipamento': {'id': < id_ip_do_equipamento >}}
:raise EquipamentoNaoExisteError: Equipment is not registered.
:raise IpNaoExisteError: IP not registered.
:raise IpError: IP is already associated with the equipment.
:raise InvalidParameterError: Identifier of the equipment and/or IP is null or invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def listar_por_tipo_ambiente(self, id_tipo_equipamento, id_ambiente):
"""Lista os equipamentos de um tipo e que estão associados a um ambiente.
:param id_tipo_equipamento: Identificador do tipo do equipamento.
:param id_ambiente: Identificador do ambiente.
:return: Dicionário com a seguinte estrutura:
::
{'equipamento': [{'id': < id_equipamento >,
'nome': < nome_equipamento >,
'id_tipo_equipamento': < id_tipo_equipamento >,
'nome_tipo_equipamento': < nome_tipo_equipamento >,
'id_modelo': < id_modelo >,
'nome_modelo': < nome_modelo >,
'id_marca': < id_marca >,
'nome_marca': < nome_marca >
}, ... demais equipamentos ...]}
:raise InvalidParameterError: O identificador do tipo de equipamento e/ou do ambiente são nulos ou inválidos.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta.
"""
if not is_valid_int_param(id_tipo_equipamento):
raise InvalidParameterError(
u'O identificador do tipo do equipamento é inválido ou não foi informado.')
if not is_valid_int_param(id_ambiente):
raise InvalidParameterError(
u'O identificador do ambiente é inválido ou não foi informado.')
url = 'equipamento/tipoequipamento/' + \
str(id_tipo_equipamento) + '/ambiente/' + str(id_ambiente) + '/'
code, xml = self.submit(None, 'GET', url)
key = 'equipamento'
return get_list_map(self.response(code, xml, [key]), key) | Lista os equipamentos de um tipo e que estão associados a um ambiente.
:param id_tipo_equipamento: Identificador do tipo do equipamento.
:param id_ambiente: Identificador do ambiente.
:return: Dicionário com a seguinte estrutura:
::
{'equipamento': [{'id': < id_equipamento >,
'nome': < nome_equipamento >,
'id_tipo_equipamento': < id_tipo_equipamento >,
'nome_tipo_equipamento': < nome_tipo_equipamento >,
'id_modelo': < id_modelo >,
'nome_modelo': < nome_modelo >,
'id_marca': < id_marca >,
'nome_marca': < nome_marca >
}, ... demais equipamentos ...]}
:raise InvalidParameterError: O identificador do tipo de equipamento e/ou do ambiente são nulos ou inválidos.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta. | entailment |
def listar_por_nome(self, nome):
"""Obtém um equipamento a partir do seu nome.
:param nome: Nome do equipamento.
:return: Dicionário com a seguinte estrutura:
::
{'equipamento': {'id': < id_equipamento >,
'nome': < nome_equipamento >,
'id_tipo_equipamento': < id_tipo_equipamento >,
'nome_tipo_equipamento': < nome_tipo_equipamento >,
'id_modelo': < id_modelo >,
'nome_modelo': < nome_modelo >,
'id_marca': < id_marca >,
'nome_marca': < nome_marca >}}
:raise EquipamentoNaoExisteError: Equipamento com o
nome informado não cadastrado.
:raise InvalidParameterError: O nome do equipamento é nulo ou vazio.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta.
"""
if nome == '' or nome is None:
raise InvalidParameterError(
u'O nome do equipamento não foi informado.')
url = 'equipamento/nome/' + urllib.quote(nome) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Obtém um equipamento a partir do seu nome.
:param nome: Nome do equipamento.
:return: Dicionário com a seguinte estrutura:
::
{'equipamento': {'id': < id_equipamento >,
'nome': < nome_equipamento >,
'id_tipo_equipamento': < id_tipo_equipamento >,
'nome_tipo_equipamento': < nome_tipo_equipamento >,
'id_modelo': < id_modelo >,
'nome_modelo': < nome_modelo >,
'id_marca': < id_marca >,
'nome_marca': < nome_marca >}}
:raise EquipamentoNaoExisteError: Equipamento com o
nome informado não cadastrado.
:raise InvalidParameterError: O nome do equipamento é nulo ou vazio.
: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_por_id(self, id):
"""Obtém um equipamento a partir do seu identificador.
:param id: ID do equipamento.
:return: Dicionário com a seguinte estrutura:
::
{'equipamento': {'id': < id_equipamento >,
'nome': < nome_equipamento >,
'id_tipo_equipamento': < id_tipo_equipamento >,
'nome_tipo_equipamento': < nome_tipo_equipamento >,
'id_modelo': < id_modelo >,
'nome_modelo': < nome_modelo >,
'id_marca': < id_marca >,
'nome_marca': < nome_marca >}}
:raise EquipamentoNaoExisteError: Equipamento com o
id informado não cadastrado.
:raise InvalidParameterError: O nome do equipamento é nulo ou vazio.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta.
"""
if id is None:
raise InvalidParameterError(
u'O id do equipamento não foi informado.')
url = 'equipamento/id/' + urllib.quote(id) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Obtém um equipamento a partir do seu identificador.
:param id: ID do equipamento.
:return: Dicionário com a seguinte estrutura:
::
{'equipamento': {'id': < id_equipamento >,
'nome': < nome_equipamento >,
'id_tipo_equipamento': < id_tipo_equipamento >,
'nome_tipo_equipamento': < nome_tipo_equipamento >,
'id_modelo': < id_modelo >,
'nome_modelo': < nome_modelo >,
'id_marca': < id_marca >,
'nome_marca': < nome_marca >}}
:raise EquipamentoNaoExisteError: Equipamento com o
id informado não cadastrado.
:raise InvalidParameterError: O nome do equipamento é nulo ou vazio.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta. | entailment |
def list_all(self):
"""Return all equipments in database
:return: Dictionary with the following structure:
::
{'equipaments': {'name' :< name_equipament >}, {... demais equipamentos ...} }
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
url = 'equipamento/list/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Return all equipments in database
:return: Dictionary with the following structure:
::
{'equipaments': {'name' :< name_equipament >}, {... demais equipamentos ...} }
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def get_all(self):
"""Return all equipments in database
:return: Dictionary with the following structure:
::
{'equipaments': {'name' :< name_equipament >}, {... demais equipamentos ...} }
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
url = 'equipment/all'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | Return all equipments in database
:return: Dictionary with the following structure:
::
{'equipaments': {'name' :< name_equipament >}, {... demais equipamentos ...} }
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | entailment |
def remover(self, id_equipamento):
"""Remove um equipamento a partir do seu identificador.
Além de remover o equipamento, a API também remove:
- O relacionamento do equipamento com os tipos de acessos.
- O relacionamento do equipamento com os roteiros.
- O relacionamento do equipamento com os IPs.
- As interfaces do equipamento.
- O relacionamento do equipamento com os ambientes.
- O relacionamento do equipamento com os grupos.
:param id_equipamento: Identificador do equipamento.
:return: None
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise InvalidParameterError: O identificador do equipamento é nulo ou inválido.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta.
"""
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(
u'O identificador do equipamento é inválido ou não foi informado.')
url = 'equipamento/' + str(id_equipamento) + '/'
code, map = self.submit(None, 'DELETE', url)
return self.response(code, map) | Remove um equipamento a partir do seu identificador.
Além de remover o equipamento, a API também remove:
- O relacionamento do equipamento com os tipos de acessos.
- O relacionamento do equipamento com os roteiros.
- O relacionamento do equipamento com os IPs.
- As interfaces do equipamento.
- O relacionamento do equipamento com os ambientes.
- O relacionamento do equipamento com os grupos.
:param id_equipamento: Identificador do equipamento.
:return: None
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise InvalidParameterError: O identificador do equipamento é nulo ou inválido.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta. | entailment |
def associar_grupo(self, id_equipamento, id_grupo_equipamento):
"""Associa um equipamento a um grupo.
:param id_equipamento: 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_equipamento
code, xml = self.submit(
{'equipamento_grupo': equip_map}, 'POST', 'equipamentogrupo/')
return self.response(code, xml) | Associa um equipamento a um grupo.
:param id_equipamento: 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 remover_grupo(self, id_equipamento, id_grupo):
"""Remove a associação de um equipamento com um grupo de equipamento.
:param id_equipamento: Identificador do equipamento.
:param id_grupo: Identificador do grupo de equipamento.
:return: None
:raise EquipamentoGrupoNaoExisteError: Associação entre grupo e equipamento não cadastrada.
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise EquipmentDontRemoveError: Failure to remove an association between an equipment and a group because the group is related only to a group.
:raise InvalidParameterError: O identificador do equipamento e/ou do grupo são nulos ou inválidos.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta.
"""
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(
u'O identificador do equipamento é inválido ou não foi informado.')
if not is_valid_int_param(id_grupo):
raise InvalidParameterError(
u'O identificador do grupo é inválido ou não foi informado.')
url = 'equipamentogrupo/equipamento/' + \
str(id_equipamento) + '/egrupo/' + str(id_grupo) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | Remove a associação de um equipamento com um grupo de equipamento.
:param id_equipamento: Identificador do equipamento.
:param id_grupo: Identificador do grupo de equipamento.
:return: None
:raise EquipamentoGrupoNaoExisteError: Associação entre grupo e equipamento não cadastrada.
:raise EquipamentoNaoExisteError: Equipamento não cadastrado.
:raise EquipmentDontRemoveError: Failure to remove an association between an equipment and a group because the group is related only to a group.
:raise InvalidParameterError: O identificador do equipamento e/ou do grupo são nulos ou inválidos.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.