text_prompt
stringlengths 157
13.1k
| code_prompt
stringlengths 7
19.8k
⌀ |
---|---|
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create_environment(self, environment):
""" Method to create environment """ |
uri = 'api/v3/environment/'
data = dict()
data['environments'] = list()
data['environments'].append(environment)
return super(ApiEnvironment, self).post(uri, data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def update_environment(self, environment, environment_ids):
""" Method to update environment :param environment_ids: Ids of Environment """ |
uri = 'api/v3/environment/%s/' % environment_ids
data = dict()
data['environments'] = list()
data['environments'].append(environment)
return super(ApiEnvironment, self).put(uri, data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def delete_environment(self, environment_ids):
""" Method to delete environment :param environment_ids: Ids of Environment """ |
uri = 'api/v3/environment/%s/' % environment_ids
return super(ApiEnvironment, self).delete(uri) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def search(self, **kwargs):
""" Method to search environments based on extends search. :param search: Dict containing QuerySets to find environments. :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 environments """ |
return super(ApiEnvironment, self).get(self.prepare_url('api/v3/environment/',
kwargs)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def delete(self, ids):
""" Method to delete environments by their id's :param ids: Identifiers of environments :return: None """ |
url = build_uri_with_ids('api/v3/environment/%s/', ids)
return super(ApiEnvironment, self).delete(url) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def update(self, environments):
""" Method to update environments :param environments: List containing environments desired to updated :return: None """ |
data = {'environments': environments}
environments_ids = [str(env.get('id')) for env in environments]
return super(ApiEnvironment, self).put('api/v3/environment/%s/' %
';'.join(environments_ids), data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create(self, environments):
""" Method to create environments :param environments: Dict containing environments desired to be created on database :return: None """ |
data = {'environments': environments}
return super(ApiEnvironment, self).post('api/v3/environment/', data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def search(self, **kwargs):
""" Method to search asns based on extends search. :param search: Dict containing QuerySets to find asns. :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 asns """ |
return super(ApiV4As, self).get(self.prepare_url(
'api/v4/as/', kwargs)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def delete(self, ids):
""" Method to delete asns by their id's :param ids: Identifiers of asns :return: None """ |
url = build_uri_with_ids('api/v4/as/%s/', ids)
return super(ApiV4As, self).delete(url) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def update(self, asns):
""" Method to update asns :param asns: List containing asns desired to updated :return: None """ |
data = {'asns': asns}
asns_ids = [str(env.get('id')) for env in asns]
return super(ApiV4As, self).put('api/v4/as/%s/' %
';'.join(asns_ids), data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create(self, asns):
""" Method to create asns :param asns: List containing asns desired to be created on database :return: None """ |
data = {'asns': asns}
return super(ApiV4As, self).post('api/v4/as/', data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def update(self, equipments):
""" Method to update equipments :param equipments: List containing equipments desired to updated :return: None """ |
data = {'equipments': equipments}
equipments_ids = [str(env.get('id')) for env in equipments]
return super(ApiV4Equipment, self).put('api/v4/equipment/%s/' %
';'.join(equipments_ids), data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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 >, :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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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 >, :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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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']) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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 >, :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']) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listar_por_marca(self, id_brand):
"""List all Model by Brand. :param id_brand: Identifier of the Brand. Integer value and greater than zero. :return: Dictionary with the following structure: :: {‘model’: [{‘id’: < id >, ‘nome’: < nome >, :raise InvalidParameterError: The identifier of Brand is null and invalid. :raise MarcaNaoExisteError: Brand not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ |
if not is_valid_int_param(id_brand):
raise InvalidParameterError(
u'The identifier of Brand is invalid or was not informed.')
url = 'model/brand/' + str(id_brand) + '/'
code, map = self.submit(None, 'GET', url)
key = 'model'
return get_list_map(self.response(code, map, [key]), key) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def inserir(self, id_brand, name):
"""Inserts a new Model and returns its identifier :param id_brand: Identifier of the Brand. Integer value and greater than zero. :param name: Model name. String with a minimum 3 and maximum of 100 characters :return: Dictionary with the following structure: :: {'model': {'id': < id_model >}} :raise InvalidParameterError: The identifier of Brand or name is null and invalid. :raise NomeMarcaModeloDuplicadoError: There is already a registered Model with the value of name and brand. :raise MarcaNaoExisteError: Brand not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ |
model_map = dict()
model_map['name'] = name
model_map['id_brand'] = id_brand
code, xml = self.submit({'model': model_map}, 'POST', 'model/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def alterar(self, id_model, id_brand, name):
"""Change Model from by the identifier. :param id_model: Identifier of the Model. Integer value and greater than zero. :param id_brand: Identifier of the Brand. Integer value and greater than zero. :param name: Model name. String with a minimum 3 and maximum of 100 characters :return: None :raise InvalidParameterError: The identifier of Model, Brand or name is null and invalid. :raise MarcaNaoExisteError: Brand not registered. :raise ModeloEquipamentoNaoExisteError: Model not registered. :raise NomeMarcaModeloDuplicadoError: There is already a registered Model with the value of name and brand. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ |
if not is_valid_int_param(id_model):
raise InvalidParameterError(
u'The identifier of Model is invalid or was not informed.')
model_map = dict()
model_map['name'] = name
model_map['id_brand'] = id_brand
url = 'model/' + str(id_model) + '/'
code, xml = self.submit({'model': model_map}, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def remover(self, id_model):
"""Remove Model from by the identifier. :param id_model: Identifier of the Model. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Model is null and invalid. :raise ModeloEquipamentoNaoExisteError: Model not registered. :raise ModeloEquipamentoError: The Model is associated with a equipment. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response """ |
if not is_valid_int_param(id_model):
raise InvalidParameterError(
u'The identifier of Model is invalid or was not informed.')
url = 'model/' + str(id_model) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listar_por_equipamento(self, id_equipamento):
"""List all interfaces of an equipment. :param id_equipamento: Equipment identifier. :return: Dictionary with the following: :: {'interface': [{'protegida': < protegida >, 'nome': < nome >, 'id_ligacao_front': < id_ligacao_front >, 'id_equipamento': < id_equipamento >, 'id': < id >, 'descricao': < descricao >, :raise InvalidParameterError: Equipment identifier is invalid or none. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(
u'Equipment id is invalid or was not informed.')
url = 'interface/equipamento/' + str(id_equipamento) + '/'
code, map = self.submit(None, 'GET', url)
key = 'interface'
return get_list_map(self.response(code, map, [key]), key) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_by_id(self, id_interface):
"""Get an interface by id. :param id_interface: Interface identifier. :return: Following dictionary: :: {'interface': {'id': < id >, 'interface': < interface >, 'descricao': < descricao >, 'protegida': < protegida >, 'tipo_equip': < id_tipo_equipamento >, 'equipamento': < id_equipamento >, 'equipamento_nome': < nome_equipamento > 'ligacao_front': < id_ligacao_front >, 'nome_ligacao_front': < interface_name >, 'nome_equip_l_front': < equipment_name >, 'ligacao_back': < id_ligacao_back >, 'nome_ligacao_back': < interface_name >, 'nome_equip_l_back': < equipment_name > }} :raise InvalidParameterError: Interface identifier is invalid or none. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_interface):
raise InvalidParameterError(
u'Interface id is invalid or was not informed.')
url = 'interface/' + str(id_interface) + '/get/'
code, map = self.submit(None, 'GET', url)
return self.response(code, map) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def inserir( self, nome, protegida, descricao, id_ligacao_front, id_ligacao_back, id_equipamento, tipo=None, vlan=None):
"""Insert new interface for an equipment. :param nome: Interface name. :param protegida: Indication of protected ('0' or '1'). :param descricao: Interface description. :param id_ligacao_front: Front end link interface identifier. :param id_ligacao_back: Back end link interface identifier. :param id_equipamento: Equipment identifier. :return: Dictionary with the following: {'interface': {'id': < id >}} :raise EquipamentoNaoExisteError: Equipment does not exist. :raise InvalidParameterError: The parameters nome, protegida and/or equipment id are none or invalid. :raise NomeInterfaceDuplicadoParaEquipamentoError: There is already an interface with this name for this equipment. :raise InterfaceNaoExisteError: Front link interface and/or back link interface doesn't exist. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
interface_map = dict()
interface_map['nome'] = nome
interface_map['protegida'] = protegida
interface_map['descricao'] = descricao
interface_map['id_ligacao_front'] = id_ligacao_front
interface_map['id_ligacao_back'] = id_ligacao_back
interface_map['id_equipamento'] = id_equipamento
interface_map['tipo'] = tipo
interface_map['vlan'] = vlan
code, xml = self.submit(
{'interface': interface_map}, 'POST', 'interface/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def alterar( self, id_interface, nome, protegida, descricao, id_ligacao_front, id_ligacao_back, tipo=None, vlan=None):
"""Edit an interface by its identifier. Equipment identifier is not changed. :param nome: Interface name. :param protegida: Indication of protected ('0' or '1'). :param descricao: Interface description. :param id_ligacao_front: Front end link interface identifier. :param id_ligacao_back: Back end link interface identifier. :param id_interface: Interface identifier. :return: None :raise InvalidParameterError: The parameters interface id, nome and protegida are none or invalid. :raise NomeInterfaceDuplicadoParaEquipamentoError: There is already an interface with this name for this equipment. :raise InterfaceNaoExisteError: Front link interface and/or back link interface doesn't exist. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_interface):
raise InvalidParameterError(
u'Interface id is invalid or was not informed.')
url = 'interface/' + str(id_interface) + '/'
interface_map = dict()
interface_map['nome'] = nome
interface_map['protegida'] = protegida
interface_map['descricao'] = descricao
interface_map['id_ligacao_front'] = id_ligacao_front
interface_map['id_ligacao_back'] = id_ligacao_back
interface_map['tipo'] = tipo
interface_map['vlan'] = vlan
code, xml = self.submit({'interface': interface_map}, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def remover(self, id_interface):
"""Remove an interface by its identifier. :param id_interface: Interface identifier. :return: None :raise InterfaceNaoExisteError: Interface doesn't exist. :raise InterfaceError: Interface is linked to another interface. :raise InvalidParameterError: The interface identifier is invalid or none. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_interface):
raise InvalidParameterError(
u'Interface id is invalid or was not informed.')
url = 'interface/' + str(id_interface) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list_connections(self, nome_interface, id_equipamento):
"""List interfaces linked to back and front of specified interface. :param nome_interface: Interface name. :param id_equipamento: Equipment identifier. :return: Dictionary with the following: :: {'interfaces':[ {'id': < id >, 'interface': < nome >, 'descricao': < descricao >, 'protegida': < protegida >, 'equipamento': < id_equipamento >, 'tipo_equip': < id_tipo_equipamento >, 'ligacao_front': < id_ligacao_front >, 'nome_ligacao_front': < interface_name >, 'nome_equip_l_front': < equipment_name >, 'ligacao_back': < id_ligacao_back >, 'nome_ligacao_back': < interface_name >, :raise InterfaceNaoExisteError: Interface doesn't exist or is not associated with this equipment. :raise EquipamentoNaoExisteError: Equipment doesn't exist. :raise InvalidParameterError: Interface name and/or equipment identifier are none or invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(
u'Equipment identifier is none or was not informed.')
if (nome_interface is None) or (nome_interface == ''):
raise InvalidParameterError(u'Interface name was not informed.')
# Temporário, remover. Fazer de outra forma.
nome_interface = nome_interface.replace('/', 's2it_replace')
url = 'interface/' + \
urllib.quote(nome_interface) + '/equipment/' + \
str(id_equipamento) + '/'
code, map = self.submit(None, 'GET', url)
key = 'interfaces'
return get_list_map(self.response(code, map, [key]), key) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list_all(self):
"""List all Permission. :return: Dictionary with the following structure: :: :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
code, map = self.submit(None, 'GET', 'perms/all/')
key = 'perms'
return get_list_map(self.response(code, map, [key]), key) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list_with_usergroup(self):
"""List all users and their user groups. is_more -If more than 3 of groups of users or no, to control expansion Screen. :return: Dictionary with the following structure: :: {'usuario': [{'nome': < nome >, 'id': < id >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'email': < email >, 'is_more': <True ou False>, :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
url = 'usuario/get/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_by_user_ldap(self, user_name):
"""Get user by the ldap name. is_more -If more than 3 of groups of users or no, to control expansion Screen. :return: Dictionary with the following structure: :: {'usuario': [{'nome': < nome >, 'id': < id >, 'pwd': < pwd >, 'user': < user >, 'ativo': < ativo >, 'email': < email >, 'user_ldap': < user_ldap >}} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
url = 'user/get/ldap/' + str(user_name) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def inserir(self, user, pwd, name, email, user_ldap):
"""Inserts a new User and returns its identifier. The user will be created with active status. :param user: Username. String with a minimum 3 and maximum of 45 characters :param pwd: User password. String with a minimum 3 and maximum of 45 characters :param name: User name. String with a minimum 3 and maximum of 200 characters :param email: User Email. String with a minimum 3 and maximum of 300 characters :param user_ldap: LDAP Username. String with a minimum 3 and maximum of 45 characters :return: Dictionary with the following structure: :: {'usuario': {'id': < id_user >}} :raise InvalidParameterError: The identifier of User, user, pwd, name or email is null and invalid. :raise UserUsuarioDuplicadoError: There is already a registered user with the value of user. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
user_map = dict()
user_map['user'] = user
user_map['password'] = pwd
user_map['name'] = name
user_map['email'] = email
user_map['user_ldap'] = user_ldap
code, xml = self.submit({'user': user_map}, 'POST', 'user/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def alterar(self, id_user, user, password, nome, ativo, email, user_ldap):
"""Change User from by the identifier. :param id_user: Identifier of the User. Integer value and greater than zero. :param user: Username. String with a minimum 3 and maximum of 45 characters :param password: User password. String with a minimum 3 and maximum of 45 characters :param nome: User name. String with a minimum 3 and maximum of 200 characters :param email: User Email. String with a minimum 3 and maximum of 300 characters :param ativo: Status. 0 or 1 :param user_ldap: LDAP Username. String with a minimum 3 and maximum of 45 characters :return: None :raise InvalidParameterError: The identifier of User, user, pwd, name, email or active is null and invalid. :raise UserUsuarioDuplicadoError: There is already a registered user with the value of user. :raise UsuarioNaoExisteError: User not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_user):
raise InvalidParameterError(
u'The identifier of User is invalid or was not informed.')
url = 'user/' + str(id_user) + '/'
user_map = dict()
user_map['user'] = user
user_map['password'] = password
user_map['name'] = nome
user_map['active'] = ativo
user_map['email'] = email
user_map['user_ldap'] = user_ldap
code, xml = self.submit({'user': user_map}, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listar(self):
"""List all access types. :return: Dictionary with structure: :: {‘tipo_acesso’: [{‘id’: < id >, :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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def inserir(self, protocolo):
"""Insert new access type and returns its identifier. :param protocolo: Protocol. :return: Dictionary with structure: {‘tipo_acesso’: {‘id’: < id >}} :raise ProtocoloTipoAcessoDuplicadoError: Protocol already exists. :raise InvalidParameterError: Protocol value is invalid or none. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
tipo_acesso_map = dict()
tipo_acesso_map['protocolo'] = protocolo
code, xml = self.submit(
{'tipo_acesso': tipo_acesso_map}, 'POST', 'tipoacesso/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def alterar(self, id_tipo_acesso, protocolo):
"""Edit access type by its identifier. :param id_tipo_acesso: Access type identifier. :param protocolo: Protocol. :return: None :raise ProtocoloTipoAcessoDuplicadoError: Protocol already exists. :raise InvalidParameterError: Protocol value is invalid or none. :raise TipoAcessoNaoExisteError: Access type doesn't exist. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_tipo_acesso):
raise InvalidParameterError(
u'Access type id is invalid or was not informed.')
tipo_acesso_map = dict()
tipo_acesso_map['protocolo'] = protocolo
url = 'tipoacesso/' + str(id_tipo_acesso) + '/'
code, xml = self.submit({'tipo_acesso': tipo_acesso_map}, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def remover(self, id_tipo_acesso):
"""Removes access type by its identifier. :param id_tipo_acesso: Access type identifier. :return: None :raise TipoAcessoError: Access type associated with equipment, cannot be removed. :raise InvalidParameterError: Protocol value is invalid or none. :raise TipoAcessoNaoExisteError: Access type doesn't exist. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_tipo_acesso):
raise InvalidParameterError(
u'Access type id is invalid or was not informed.')
url = 'tipoacesso/' + str(id_tipo_acesso) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def inserir(self, type, description):
"""Inserts a new Script Type and returns its identifier. :param type: Script Type type. String with a minimum 3 and maximum of 40 characters :param description: Script Type description. String with a minimum 3 and maximum of 100 characters :return: Dictionary with the following structure: :: {'script_type': {'id': < id_script_type >}} :raise InvalidParameterError: Type or description is null and invalid. :raise NomeTipoRoteiroDuplicadoError: Type script already registered with informed. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
script_type_map = dict()
script_type_map['type'] = type
script_type_map['description'] = description
code, xml = self.submit(
{'script_type': script_type_map}, 'POST', 'scripttype/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def alterar(self, id_script_type, type, description):
"""Change Script Type from by the identifier. :param id_script_type: Identifier of the Script Type. Integer value and greater than zero. :param type: Script Type type. String with a minimum 3 and maximum of 40 characters :param description: Script Type description. String with a minimum 3 and maximum of 100 characters :return: None :raise InvalidParameterError: The identifier of Script Type, type or description is null and invalid. :raise TipoRoteiroNaoExisteError: Script Type not registered. :raise NomeTipoRoteiroDuplicadoError: Type script already registered with informed. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_script_type):
raise InvalidParameterError(
u'The identifier of Script Type is invalid or was not informed.')
script_type_map = dict()
script_type_map['type'] = type
script_type_map['description'] = description
url = 'scripttype/' + str(id_script_type) + '/'
code, xml = self.submit({'script_type': script_type_map}, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def remover(self, id_script_type):
"""Remove Script Type from by the identifier. :param id_script_type: Identifier of the Script Type. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Script Type is null and invalid. :raise TipoRoteiroNaoExisteError: Script Type not registered. :raise TipoRoteiroError: Script type is associated with a script. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_script_type):
raise InvalidParameterError(
u'The identifier of Script Type is invalid or was not informed.')
url = 'scripttype/' + str(id_script_type) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def search(self, **kwargs):
""" Method to search pool's based on extends search. :param search: Dict containing QuerySets to find pool's. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :param fields: Array containing fields to override default fields. :param kind: Determine if result will be detailed ('detail') or basic ('basic'). :return: Dict containing pool's """ |
return super(ApiPool, self).get(self.prepare_url('api/v3/pool/',
kwargs)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def delete(self, ids):
""" Method to delete pool's by their ids :param ids: Identifiers of pool's :return: None """ |
url = build_uri_with_ids('api/v3/pool/%s/', ids)
return super(ApiPool, self).delete(url) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create(self, pools):
""" Method to create pool's :param pools: List containing pool's desired to be created on database :return: None """ |
data = {'server_pools': pools}
return super(ApiPool, self).post('api/v3/pool/', data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_real_related(self, id_equip):
""" Find reals related with equipment :param id_equip: Identifier of equipment :return: Following dictionary: :: {'vips': [{'port_real': < port_real >, 'server_pool_member_id': < server_pool_member_id >, 'ip': < ip >, 'port_vip': < port_vip >, 'host_name': < host_name >, 'equip_name': < equip_name > }} :raise EquipamentoNaoExisteError: Equipment not registered. :raise InvalidParameterError: Some parameter was invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
url = 'equipamento/get_real_related/' + str(id_equip) + '/'
code, xml = self.submit(None, 'GET', url)
data = self.response(code, xml)
return data |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
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) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def associate_ipv6(self, id_equip, id_ipv6):
"""Associates an IPv6 to a equipament. :param id_equip: Identifier of the equipment. Integer value and greater than zero. :param id_ipv6: Identifier of the ip. Integer value and greater than zero. :return: Dictionary with the following structure: {'ip_equipamento': {'id': < id_ip_do_equipamento >}} :raise EquipamentoNaoExisteError: Equipment is not registered. :raise IpNaoExisteError: IP not registered. :raise IpError: IP is already associated with the equipment. :raise InvalidParameterError: Identifier of the equipment and/or IP is null or invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_equip):
raise InvalidParameterError(
u'The identifier of equipment is invalid or was not informed.')
if not is_valid_int_param(id_ipv6):
raise InvalidParameterError(
u'The identifier of ip is invalid or was not informed.')
url = 'ipv6/' + str(id_ipv6) + '/equipment/' + str(id_equip) + '/'
code, xml = self.submit(None, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def _parse(self, content):
""" Parse data request to data from python. @param content: Context of request. @raise ParseError: """ |
if content:
stream = BytesIO(str(content))
data = json.loads(stream.getvalue())
return data |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def prepare_url(self, uri, kwargs):
"""Convert dict for URL params """ |
params = dict()
for key in kwargs:
if key in ('include', 'exclude', 'fields'):
params.update({
key: ','.join(kwargs.get(key))
})
elif key in ('search', 'kind'):
params.update({
key: kwargs.get(key)
})
if params:
params = urlencode(params)
uri = '%s?%s' % (uri, params)
return uri |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def remover(self, id_rack):
"""Remove Rack by the identifier. :param id_rack: Identifier of the Rack. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Rack is null and invalid. :raise RackNaoExisteError: Rack not registered. :raise RackError: Rack is associated with a script. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_rack):
raise InvalidParameterError(
u'The identifier of Rack is invalid or was not informed.')
url = 'rack/' + str(id_rack) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def insert_with_ip_range( self, id_l3_group, id_logical_environment, id_division, id_ip_config, link, id_filter=None):
"""Insert new environment with ip config and returns your id. :param id_l3_group: Layer 3 Group ID. :param id_logical_environment: Logical Environment ID. :param id_division: Data Center Division ID. :param id_filter: Filter identifier. :param id_ip_config: IP Configuration ID. :param link: Link. :return: Following dictionary: {'ambiente': {'id': < id >}} :raise ConfigEnvironmentDuplicateError: Error saving duplicate Environment Configuration. :raise InvalidParameterError: Some parameter was invalid. :raise GrupoL3NaoExisteError: Layer 3 Group not found. :raise AmbienteLogicoNaoExisteError: Logical Environment not found. :raise DivisaoDcNaoExisteError: Data Center Division not found. :raise AmbienteDuplicadoError: Environment with this parameters already exists. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
environment_map = dict()
environment_map['id_grupo_l3'] = id_l3_group
environment_map['id_ambiente_logico'] = id_logical_environment
environment_map['id_divisao'] = id_division
environment_map['id_filter'] = id_filter
environment_map['id_ip_config'] = id_ip_config
environment_map['link'] = link
code, xml = self.submit(
{'ambiente': environment_map}, 'POST', 'ambiente/ipconfig/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_ip_range(self, id_environment, id_ip_config):
"""Makes relationship of environment with ip config and returns your id. :param id_environment: Environment ID. :param id_ip_config: IP Configuration ID. :return: Following dictionary: {'config_do_ambiente': {'id_config_do_ambiente': < id_config_do_ambiente >}} :raise InvalidParameterError: Some parameter was invalid. :raise ConfigEnvironmentDuplicateError: Error saving duplicate Environment Configuration. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
environment_map = dict()
environment_map['id_environment'] = id_environment
environment_map['id_ip_config'] = id_ip_config
code, xml = self.submit(
{'ambiente': environment_map}, 'POST', 'ipconfig/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def add_expect_string_healthcheck(self, expect_string):
"""Inserts a new healthckeck_expect with only expect_string. :param expect_string: expect_string. :return: Dictionary with the following structure: :: {'healthcheck_expect': {'id': < id >}} :raise InvalidParameterError: The value of expect_string is invalid. :raise HealthCheckExpectJaCadastradoError: There is already a healthcheck_expect registered with the same data. :raise HealthCheckExpectNaoExisteError: Healthcheck_expect not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
healthcheck_map = dict()
healthcheck_map['expect_string'] = expect_string
url = 'healthcheckexpect/add/expect_string/'
code, xml = self.submit({'healthcheck': healthcheck_map}, 'POST', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def listar_healtchcheck_expect_distinct(self):
"""Get all expect_string. :return: Dictionary with the following structure: :: {'healthcheck_expect': [ 'expect_string': < expect_string >, :raise InvalidParameterError: Identifier is null and invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
url = 'healthcheckexpect/distinct/busca/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def list_acl_path(self):
"""Get all distinct acl paths. :return: Dictionary with the following structure: :: {'acl_paths': [ < acl_path >, :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
url = 'environment/acl_path/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def set_template(self, id_environment, name, network):
"""Set template value. If id_environment = 0, set '' to all environments related with the template name. :param id_environment: Environment Identifier. :param name: Template Name. :param network: IPv4 or IPv6. :return: None :raise InvalidParameterError: Invalid param. :raise AmbienteNaoExisteError: Ambiente não cadastrado. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta. """ |
url = 'environment/set_template/' + str(id_environment) + '/'
environment_map = dict()
environment_map['name'] = name
environment_map['network'] = network
code, xml = self.submit({'environment': environment_map}, 'POST', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_environment_template(self, name, network):
"""Get environments by template name :param name: Template name. :param network: IPv4 or IPv6. :return: Following dictionary: :: :raise InvalidParameterError: Invalid param. :raise DataBaseError: Falha na networkapi ao acessar o banco de dados. :raise XMLError: Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta. """ |
url = 'environment/get_env_template/'
map_dict = dict()
map_dict['name'] = name
map_dict['network'] = network
code, xml = self.submit({'map': map_dict}, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def configuration_save( self, id_environment, network, prefix, ip_version, network_type):
""" Add new prefix configuration :param id_environment: Identifier of the Environment. Integer value and greater than zero. :param network: Network Ipv4 or Ipv6. :param prefix: Prefix 0-32 to Ipv4 or 0-128 to Ipv6. :param ip_version: v4 to IPv4 or v6 to IPv6 :param network_type: type network :return: Following dictionary: :: {'network':{'id_environment': <id_environment>, 'id_vlan': <id_vlan>, 'network_type': <network_type>, 'network': <network>, 'prefix': <prefix>} } :raise ConfigEnvironmentInvalidError: Invalid Environment Configuration or not registered. :raise InvalidValueError: Invalid Id for environment or network or network_type or prefix. :raise AmbienteNotFoundError: Environment not registered. :raise DataBaseError: Failed into networkapi access data base. :raise XMLError: Networkapi failed to generate the XML response. """ |
network_map = dict()
network_map['id_environment'] = id_environment
network_map['network'] = network
network_map['prefix'] = prefix
network_map['ip_version'] = ip_version
network_map['network_type'] = network_type
code, xml = self.submit(
{'ambiente': network_map}, 'POST', 'environment/configuration/save/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def configuration_list_all(self, environment_id):
""" List all prefix configurations by environment in DB :return: Following dictionary: :: {'lists_configuration': [{ 'id': <id_ipconfig>, 'subnet': <subnet>, 'type': <type>, 'new_prefix': <new_prefix>, :raise InvalidValueError: Invalid ID for Environment. :raise AmbienteNotFoundError: Environment not registered. :raise DataBaseError: Failed into networkapi access data base. :raise XMLError: Networkapi failed to generate the XML response. """ |
data = dict()
data["environment_id"] = environment_id
url = ("environment/configuration/list/%(environment_id)s/" % data)
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml, force_list=['lists_configuration']) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def configuration_remove(self, environment_id, configuration_id):
""" Remove Prefix Configuration :return: None :raise InvalidValueError: Invalid Id for Environment or IpConfig. :raise IPConfigNotFoundError: Ipconfig not resgistred. :raise AmbienteNotFoundError: Environment not registered. :raise DataBaseError: Failed into networkapi access data base. :raise XMLError: Networkapi failed to generate the XML response. """ |
data = dict()
data["configuration_id"] = configuration_id
data["environment_id"] = environment_id
url = (
"environment/configuration/remove/%(environment_id)s/%(configuration_id)s/" %
data)
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def associate(self, environment_id, environment_vip_id):
"""Associate a news Environment on Environment VIP and returns its identifier. :param environment_id: Identifier of the Environment. Integer value and greater than zero. :param environment_vip_id: Identifier of the Environment VIP. Integer value and greater than zero. :return: Following dictionary: :: {'environment_environment_vip': {'id': < id >}} :raise InvalidParameterError: The value of environment_id or environment_vip_id is invalid. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(environment_id):
raise InvalidParameterError(
u'The identifier of Environment VIP is invalid or was not informed.')
if not is_valid_int_param(environment_vip_id):
raise InvalidParameterError(
u'The identifier of Environment is invalid or was not informed.')
environment_environment_vip_map = dict()
environment_environment_vip_map['environment_id'] = environment_id
environment_environment_vip_map['environment_vip_id'] = environment_vip_id
url = 'environment/{}/environmentvip/{}/'.format(environment_id, environment_vip_id)
code, xml = self.submit(None, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_related_environment_list(self, environment_vip_id):
"""Get all Environment by Environment Vip. :return: Following dictionary: :: {'ambiente': [{ 'id': <id_environment>, 'grupo_l3': <id_group_l3>, 'grupo_l3_name': <name_group_l3>, 'ambiente_logico': <id_logical_environment>, 'ambiente_logico_name': <name_ambiente_logico>, 'divisao_dc': <id_dc_division>, 'divisao_dc_name': <name_divisao_dc>, 'filter': <id_filter>, 'filter_name': <filter_name>, :raise EnvironmentVipNotFoundError: Environment VIP not registered. :raise DataBaseError: Can't connect to networkapi database. :raise XMLError: Failed to generate the XML response. """ |
url = 'environment/environmentvip/{}/'.format(environment_vip_id)
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml, ['environment_related_list']) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_equipment(self, **kwargs):
""" Return list environments related with environment vip """ |
uri = 'api/v3/equipment/'
uri = self.prepare_url(uri, kwargs)
return super(ApiEquipment, self).get(uri) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def delete(self, ids):
""" Method to undeploy pool's by their ids :param ids: Identifiers of deployed pool's :return: Empty Dict """ |
url = build_uri_with_ids('api/v3/pool/deploy/%s/', ids)
return super(ApiPoolDeploy, self).delete(url) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create(self, ids):
""" Method to deploy pool's :param pools: Identifiers of pool's desired to be deployed :return: Empty Dict """ |
url = build_uri_with_ids('api/v3/pool/deploy/%s/', ids)
return super(ApiPoolDeploy, self).post(url) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def inserir(self, name):
"""Inserts a new Brand and returns its identifier :param name: Brand name. String with a minimum 3 and maximum of 100 characters :return: Dictionary with the following structure: :: {'marca': {'id': < id_brand >}} :raise InvalidParameterError: Name is null and invalid. :raise NomeMarcaDuplicadoError: There is already a registered Brand with the value of name. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
brand_map = dict()
brand_map['name'] = name
code, xml = self.submit({'brand': brand_map}, 'POST', 'brand/')
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def alterar(self, id_brand, name):
"""Change Brand from by the identifier. :param id_brand: Identifier of the Brand. Integer value and greater than zero. :param name: Brand name. String with a minimum 3 and maximum of 100 characters :return: None :raise InvalidParameterError: The identifier of Brand or name is null and invalid. :raise NomeMarcaDuplicadoError: There is already a registered Brand with the value of name. :raise MarcaNaoExisteError: Brand not registered. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_brand):
raise InvalidParameterError(
u'The identifier of Brand is invalid or was not informed.')
url = 'brand/' + str(id_brand) + '/'
brand_map = dict()
brand_map['name'] = name
code, xml = self.submit({'brand': brand_map}, 'PUT', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def remover(self, id_brand):
"""Remove Brand from by the identifier. :param id_brand: Identifier of the Brand. Integer value and greater than zero. :return: None :raise InvalidParameterError: The identifier of Brand is null and invalid. :raise MarcaNaoExisteError: Brand not registered. :raise MarcaError: The brand is associated with a model. :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to generate the XML response. """ |
if not is_valid_int_param(id_brand):
raise InvalidParameterError(
u'The identifier of Brand is invalid or was not informed.')
url = 'brand/' + str(id_brand) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def acl_remove_draft(self, id_vlan, type_acl):
""" Remove Acl draft by type :param id_vlan: Identity of Vlan :param type_acl: Acl type v4 or v6 :return: None :raise VlanDoesNotExistException: Vlan Does Not Exist. :raise InvalidIdVlanException: Invalid id for Vlan. :raise NetworkAPIException: Failed to access the data source. """ |
parameters = dict(id_vlan=id_vlan, type_acl=type_acl)
uri = 'api/vlan/acl/remove/draft/%(id_vlan)s/%(type_acl)s/' % parameters
return super(ApiVlan, self).get(uri) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def acl_save_draft(self, id_vlan, type_acl, content_draft):
""" Save Acl draft by type :param id_vlan: Identity of Vlan :param type_acl: Acl type v4 or v6 :return: None :raise VlanDoesNotExistException: Vlan Does Not Exist. :raise InvalidIdVlanException: Invalid id for Vlan. :raise NetworkAPIException: Failed to access the data source. """ |
parameters = dict(id_vlan=id_vlan, type_acl=type_acl)
data = dict(content_draft=content_draft)
uri = 'api/vlan/acl/save/draft/%(id_vlan)s/%(type_acl)s/' % parameters
return super(ApiVlan, self).post(uri, data=data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def search(self, **kwargs):
""" Method to search vlan's based on extends search. :param search: Dict containing QuerySets to find vlan's. :param include: Array containing fields to include on response. :param exclude: Array containing fields to exclude on response. :param fields: Array containing fields to override default fields. :param kind: Determine if result will be detailed ('detail') or basic ('basic'). :return: Dict containing vlan's """ |
return super(ApiVlan, self).get(self.prepare_url('api/v3/vlan/',
kwargs)) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def delete(self, ids):
""" Method to delete vlan's by their ids :param ids: Identifiers of vlan's :return: None """ |
url = build_uri_with_ids('api/v3/vlan/%s/', ids)
return super(ApiVlan, self).delete(url) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def update(self, vlans):
""" Method to update vlan's :param vlans: List containing vlan's desired to updated :return: None """ |
data = {'vlans': vlans}
vlans_ids = [str(vlan.get('id')) for vlan in vlans]
return super(ApiVlan, self).put('api/v3/vlan/%s/' %
';'.join(vlans_ids), data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def create(self, vlans):
""" Method to create vlan's :param vlans: List containing vlan's desired to be created on database :return: None """ |
data = {'vlans': vlans}
return super(ApiVlan, self).post('api/v3/vlan/', data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def is_valid_version_ip(param):
"""Checks if the parameter is a valid ip version value. :param param: Value to be validated. :return: True if the parameter has a valid ip version value, or False otherwise. """ |
if param is None:
return False
if param == IP_VERSION.IPv4[0] or param == IP_VERSION.IPv6[0]:
return True
return False |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def option_vip_by_environmentvip(self, environment_vip_id):
""" List Option Vip by Environment Vip param environment_vip_id: Id of Environment Vip """ |
uri = 'api/v3/option-vip/environment-vip/%s/' % environment_vip_id
return super(ApiVipRequest, self).get(uri) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_vip_request_details(self, vip_request_id):
""" Method to get details of vip request param vip_request_id: vip_request id """ |
uri = 'api/v3/vip-request/details/%s/' % vip_request_id
return super(ApiVipRequest, self).get(uri) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def get_vip_request(self, vip_request_id):
""" Method to get vip request param vip_request_id: vip_request id """ |
uri = 'api/v3/vip-request/%s/' % vip_request_id
return super(ApiVipRequest, self).get(uri) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def search_vip_request(self, search):
""" Method to list vip request param search: search """ |
uri = 'api/v3/vip-request/?%s' % urllib.urlencode({'search': search})
return super(ApiVipRequest, self).get(uri) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def save_vip_request(self, vip_request):
""" Method to save vip request param vip_request: vip_request object """ |
uri = 'api/v3/vip-request/'
data = dict()
data['vips'] = list()
data['vips'].append(vip_request)
return super(ApiVipRequest, self).post(uri, data) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def update_vip_request(self, vip_request, vip_request_id):
""" Method to update vip request param vip_request: vip_request object param vip_request_id: vip_request id """ |
uri = 'api/v3/vip-request/%s/' % vip_request_id
data = dict()
data['vips'] = list()
data['vips'].append(vip_request)
return super(ApiVipRequest, self).put(uri, data) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.