repository_name
stringlengths 7
55
| func_path_in_repository
stringlengths 4
223
| func_name
stringlengths 1
134
| whole_func_string
stringlengths 75
104k
| language
stringclasses 1
value | func_code_string
stringlengths 75
104k
| func_code_tokens
sequencelengths 19
28.4k
| func_documentation_string
stringlengths 1
46.9k
| func_documentation_tokens
sequencelengths 1
1.97k
| split_name
stringclasses 1
value | func_code_url
stringlengths 87
315
|
---|---|---|---|---|---|---|---|---|---|---|
globocom/GloboNetworkAPI-client-python | networkapiclient/Vlan.py | Vlan.validar | def validar(self, id_vlan):
"""Validates ACL - IPv4 of VLAN from its identifier.
Assigns 1 to 'acl_valida'.
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: Vlan identifier is null and invalid.
:raise VlanNaoExisteError: Vlan 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_vlan):
raise InvalidParameterError(
u'The identifier of Vlan is invalid or was not informed.')
url = 'vlan/' + str(id_vlan) + '/validate/' + IP_VERSION.IPv4[0] + '/'
code, xml = self.submit(None, 'PUT', url)
return self.response(code, xml) | python | def validar(self, id_vlan):
"""Validates ACL - IPv4 of VLAN from its identifier.
Assigns 1 to 'acl_valida'.
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: Vlan identifier is null and invalid.
:raise VlanNaoExisteError: Vlan 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_vlan):
raise InvalidParameterError(
u'The identifier of Vlan is invalid or was not informed.')
url = 'vlan/' + str(id_vlan) + '/validate/' + IP_VERSION.IPv4[0] + '/'
code, xml = self.submit(None, 'PUT', url)
return self.response(code, xml) | [
"def",
"validar",
"(",
"self",
",",
"id_vlan",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_vlan",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Vlan is invalid or was not informed.'",
")",
"url",
"=",
"'vlan/'",
"+",
"str",
"(",
"id_vlan",
")",
"+",
"'/validate/'",
"+",
"IP_VERSION",
".",
"IPv4",
"[",
"0",
"]",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'PUT'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Validates ACL - IPv4 of VLAN from its identifier.
Assigns 1 to 'acl_valida'.
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: Vlan identifier is null and invalid.
:raise VlanNaoExisteError: Vlan not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Validates",
"ACL",
"-",
"IPv4",
"of",
"VLAN",
"from",
"its",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L918-L941 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Vlan.py | Vlan.validate_ipv6 | def validate_ipv6(self, id_vlan):
"""Validates ACL - IPv6 of VLAN from its identifier.
Assigns 1 to 'acl_valida_v6'.
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: Vlan identifier is null and invalid.
:raise VlanNaoExisteError: Vlan 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_vlan):
raise InvalidParameterError(
u'The identifier of Vlan is invalid or was not informed.')
url = 'vlan/' + str(id_vlan) + '/validate/' + IP_VERSION.IPv6[0] + '/'
code, xml = self.submit(None, 'PUT', url)
return self.response(code, xml) | python | def validate_ipv6(self, id_vlan):
"""Validates ACL - IPv6 of VLAN from its identifier.
Assigns 1 to 'acl_valida_v6'.
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: Vlan identifier is null and invalid.
:raise VlanNaoExisteError: Vlan 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_vlan):
raise InvalidParameterError(
u'The identifier of Vlan is invalid or was not informed.')
url = 'vlan/' + str(id_vlan) + '/validate/' + IP_VERSION.IPv6[0] + '/'
code, xml = self.submit(None, 'PUT', url)
return self.response(code, xml) | [
"def",
"validate_ipv6",
"(",
"self",
",",
"id_vlan",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_vlan",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Vlan is invalid or was not informed.'",
")",
"url",
"=",
"'vlan/'",
"+",
"str",
"(",
"id_vlan",
")",
"+",
"'/validate/'",
"+",
"IP_VERSION",
".",
"IPv6",
"[",
"0",
"]",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'PUT'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Validates ACL - IPv6 of VLAN from its identifier.
Assigns 1 to 'acl_valida_v6'.
:param id_vlan: Identifier of the Vlan. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: Vlan identifier is null and invalid.
:raise VlanNaoExisteError: Vlan not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Validates",
"ACL",
"-",
"IPv6",
"of",
"VLAN",
"from",
"its",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L943-L966 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Vlan.py | Vlan.remove | def remove(self, id_vlan):
"""Remove a VLAN by your primary key.
Execute script to remove VLAN
:param id_vlan: ID for VLAN.
:return: Following dictionary:
::
{‘sucesso’: {‘codigo’: < codigo >,
‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
:raise InvalidParameterError: Identifier of the VLAN is invalid.
:raise VlanNaoExisteError: VLAN not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_vlan):
raise InvalidParameterError(
u'Parameter id_vlan is invalid. Value: ' +
id_vlan)
url = 'vlan/' + str(id_vlan) + '/remove/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | python | def remove(self, id_vlan):
"""Remove a VLAN by your primary key.
Execute script to remove VLAN
:param id_vlan: ID for VLAN.
:return: Following dictionary:
::
{‘sucesso’: {‘codigo’: < codigo >,
‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
:raise InvalidParameterError: Identifier of the VLAN is invalid.
:raise VlanNaoExisteError: VLAN not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_vlan):
raise InvalidParameterError(
u'Parameter id_vlan is invalid. Value: ' +
id_vlan)
url = 'vlan/' + str(id_vlan) + '/remove/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | [
"def",
"remove",
"(",
"self",
",",
"id_vlan",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_vlan",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Parameter id_vlan is invalid. Value: '",
"+",
"id_vlan",
")",
"url",
"=",
"'vlan/'",
"+",
"str",
"(",
"id_vlan",
")",
"+",
"'/remove/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'DELETE'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Remove a VLAN by your primary key.
Execute script to remove VLAN
:param id_vlan: ID for VLAN.
:return: Following dictionary:
::
{‘sucesso’: {‘codigo’: < codigo >,
‘descricao’: {'stdout':< stdout >, 'stderr':< stderr >}}}
:raise InvalidParameterError: Identifier of the VLAN is invalid.
:raise VlanNaoExisteError: VLAN not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Remove",
"a",
"VLAN",
"by",
"your",
"primary",
"key",
".",
"Execute",
"script",
"to",
"remove",
"VLAN"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L968-L996 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Vlan.py | Vlan.deallocate | def deallocate(self, id_vlan):
"""Deallocate all relationships between Vlan.
:param id_vlan: Identifier of the VLAN. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: VLAN identifier is null and invalid.
:raise VlanError: VLAN is active.
:raise VlanNaoExisteError: VLAN not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_vlan):
raise InvalidParameterError(
u'The identifier of Vlan is invalid or was not informed.')
url = 'vlan/' + str(id_vlan) + '/deallocate/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | python | def deallocate(self, id_vlan):
"""Deallocate all relationships between Vlan.
:param id_vlan: Identifier of the VLAN. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: VLAN identifier is null and invalid.
:raise VlanError: VLAN is active.
:raise VlanNaoExisteError: VLAN not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_vlan):
raise InvalidParameterError(
u'The identifier of Vlan is invalid or was not informed.')
url = 'vlan/' + str(id_vlan) + '/deallocate/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | [
"def",
"deallocate",
"(",
"self",
",",
"id_vlan",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_vlan",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Vlan is invalid or was not informed.'",
")",
"url",
"=",
"'vlan/'",
"+",
"str",
"(",
"id_vlan",
")",
"+",
"'/deallocate/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'DELETE'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Deallocate all relationships between Vlan.
:param id_vlan: Identifier of the VLAN. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: VLAN identifier is null and invalid.
:raise VlanError: VLAN is active.
:raise VlanNaoExisteError: VLAN not found.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Deallocate",
"all",
"relationships",
"between",
"Vlan",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L998-L1020 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Vlan.py | Vlan.allocate_IPv6 | def allocate_IPv6(
self,
name,
id_network_type,
id_environment,
description,
id_environment_vip=None):
"""Inserts a new VLAN.
:param name: Name of Vlan. String with a maximum of 50 characters.
:param id_network_type: Identifier of the Netwok Type. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param description: Description of Vlan. String with a maximum of 200 characters.
:param id_environment_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 >,
'bloco1': < bloco1 >,
'bloco2': < bloco2 >,
'bloco3': < bloco3 >,
'bloco4': < bloco4 >,
'bloco5': < bloco5 >,
'bloco6': < bloco6 >,
'bloco7': < bloco7 >,
'bloco8': < bloco8 >,
'bloco': < bloco >,
'mask_bloco1': < mask_bloco1 >,
'mask_bloco2': < mask_bloco2 >,
'mask_bloco3': < mask_bloco3 >,
'mask_bloco4': < mask_bloco4 >,
'mask_bloco5': < mask_bloco5 >,
'mask_bloco6': < mask_bloco6 >,
'mask_bloco7': < mask_bloco7 >,
'mask_bloco8': < mask_bloco8 >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'acl_file_name_v6': < acl_file_name_v6 >,
'acl_valida_v6': < acl_valida_v6 >,
'ativada': < ativada >}}
:raise VlanError: VLAN name already exists, VLAN name already exists, DC division of the environment invalid or does not exist VLAN number available.
:raise VlanNaoExisteError: VLAN not found.
:raise TipoRedeNaoExisteError: Network Type not registered.
:raise AmbienteNaoExisteError: Environment not registered.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: Name of Vlan and/or the identifier of the Environment is null or invalid.
: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.
"""
vlan_map = dict()
vlan_map['name'] = name
vlan_map['id_network_type'] = id_network_type
vlan_map['id_environment'] = id_environment
vlan_map['description'] = description
vlan_map['id_environment_vip'] = id_environment_vip
code, xml = self.submit({'vlan': vlan_map}, 'POST', 'vlan/ipv6/')
return self.response(code, xml) | python | def allocate_IPv6(
self,
name,
id_network_type,
id_environment,
description,
id_environment_vip=None):
"""Inserts a new VLAN.
:param name: Name of Vlan. String with a maximum of 50 characters.
:param id_network_type: Identifier of the Netwok Type. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param description: Description of Vlan. String with a maximum of 200 characters.
:param id_environment_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 >,
'bloco1': < bloco1 >,
'bloco2': < bloco2 >,
'bloco3': < bloco3 >,
'bloco4': < bloco4 >,
'bloco5': < bloco5 >,
'bloco6': < bloco6 >,
'bloco7': < bloco7 >,
'bloco8': < bloco8 >,
'bloco': < bloco >,
'mask_bloco1': < mask_bloco1 >,
'mask_bloco2': < mask_bloco2 >,
'mask_bloco3': < mask_bloco3 >,
'mask_bloco4': < mask_bloco4 >,
'mask_bloco5': < mask_bloco5 >,
'mask_bloco6': < mask_bloco6 >,
'mask_bloco7': < mask_bloco7 >,
'mask_bloco8': < mask_bloco8 >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'acl_file_name_v6': < acl_file_name_v6 >,
'acl_valida_v6': < acl_valida_v6 >,
'ativada': < ativada >}}
:raise VlanError: VLAN name already exists, VLAN name already exists, DC division of the environment invalid or does not exist VLAN number available.
:raise VlanNaoExisteError: VLAN not found.
:raise TipoRedeNaoExisteError: Network Type not registered.
:raise AmbienteNaoExisteError: Environment not registered.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: Name of Vlan and/or the identifier of the Environment is null or invalid.
: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.
"""
vlan_map = dict()
vlan_map['name'] = name
vlan_map['id_network_type'] = id_network_type
vlan_map['id_environment'] = id_environment
vlan_map['description'] = description
vlan_map['id_environment_vip'] = id_environment_vip
code, xml = self.submit({'vlan': vlan_map}, 'POST', 'vlan/ipv6/')
return self.response(code, xml) | [
"def",
"allocate_IPv6",
"(",
"self",
",",
"name",
",",
"id_network_type",
",",
"id_environment",
",",
"description",
",",
"id_environment_vip",
"=",
"None",
")",
":",
"vlan_map",
"=",
"dict",
"(",
")",
"vlan_map",
"[",
"'name'",
"]",
"=",
"name",
"vlan_map",
"[",
"'id_network_type'",
"]",
"=",
"id_network_type",
"vlan_map",
"[",
"'id_environment'",
"]",
"=",
"id_environment",
"vlan_map",
"[",
"'description'",
"]",
"=",
"description",
"vlan_map",
"[",
"'id_environment_vip'",
"]",
"=",
"id_environment_vip",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'vlan'",
":",
"vlan_map",
"}",
",",
"'POST'",
",",
"'vlan/ipv6/'",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Inserts a new VLAN.
:param name: Name of Vlan. String with a maximum of 50 characters.
:param id_network_type: Identifier of the Netwok Type. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param description: Description of Vlan. String with a maximum of 200 characters.
:param id_environment_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 >,
'bloco1': < bloco1 >,
'bloco2': < bloco2 >,
'bloco3': < bloco3 >,
'bloco4': < bloco4 >,
'bloco5': < bloco5 >,
'bloco6': < bloco6 >,
'bloco7': < bloco7 >,
'bloco8': < bloco8 >,
'bloco': < bloco >,
'mask_bloco1': < mask_bloco1 >,
'mask_bloco2': < mask_bloco2 >,
'mask_bloco3': < mask_bloco3 >,
'mask_bloco4': < mask_bloco4 >,
'mask_bloco5': < mask_bloco5 >,
'mask_bloco6': < mask_bloco6 >,
'mask_bloco7': < mask_bloco7 >,
'mask_bloco8': < mask_bloco8 >,
'descricao': < descricao >,
'acl_file_name': < acl_file_name >,
'acl_valida': < acl_valida >,
'acl_file_name_v6': < acl_file_name_v6 >,
'acl_valida_v6': < acl_valida_v6 >,
'ativada': < ativada >}}
:raise VlanError: VLAN name already exists, VLAN name already exists, DC division of the environment invalid or does not exist VLAN number available.
:raise VlanNaoExisteError: VLAN not found.
:raise TipoRedeNaoExisteError: Network Type not registered.
:raise AmbienteNaoExisteError: Environment not registered.
:raise EnvironmentVipNotFoundError: Environment VIP not registered.
:raise InvalidParameterError: Name of Vlan and/or the identifier of the Environment is null or invalid.
: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. | [
"Inserts",
"a",
"new",
"VLAN",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L1022-L1091 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Vlan.py | Vlan.create_script_acl | def create_script_acl(self, id_vlan, network_type):
'''Generate the script acl
:param id_vlan: Vlan Id
:param network_type: v4 or v6
:raise InvalidValueError: Attrs invalids.
:raise XMLError: Networkapi failed to generate the XML response.
:raise VlanACLDuplicatedError: ACL name duplicate.
:raise VlanNotFoundError: Vlan not registered.
:return: Following dictionary:
::
{'vlan': {
'id': < id >,
'nome': '< nome >',
'num_vlan': < num_vlan >,
'descricao': < descricao >
'acl_file_name': < acl_file_name >,
'ativada': < ativada >,
'acl_valida': < acl_valida >,
'acl_file_name_v6': < acl_file_name_v6 >,
'redeipv6': < redeipv6 >,
'acl_valida_v6': < acl_valida_v6 >,
'redeipv4': < redeipv4 >,
'ambiente': < ambiente >,
}}
'''
vlan_map = dict()
vlan_map['id_vlan'] = id_vlan
vlan_map['network_type'] = network_type
url = 'vlan/create/script/acl/'
code, xml = self.submit({'vlan': vlan_map}, 'POST', url)
return self.response(code, xml) | python | def create_script_acl(self, id_vlan, network_type):
'''Generate the script acl
:param id_vlan: Vlan Id
:param network_type: v4 or v6
:raise InvalidValueError: Attrs invalids.
:raise XMLError: Networkapi failed to generate the XML response.
:raise VlanACLDuplicatedError: ACL name duplicate.
:raise VlanNotFoundError: Vlan not registered.
:return: Following dictionary:
::
{'vlan': {
'id': < id >,
'nome': '< nome >',
'num_vlan': < num_vlan >,
'descricao': < descricao >
'acl_file_name': < acl_file_name >,
'ativada': < ativada >,
'acl_valida': < acl_valida >,
'acl_file_name_v6': < acl_file_name_v6 >,
'redeipv6': < redeipv6 >,
'acl_valida_v6': < acl_valida_v6 >,
'redeipv4': < redeipv4 >,
'ambiente': < ambiente >,
}}
'''
vlan_map = dict()
vlan_map['id_vlan'] = id_vlan
vlan_map['network_type'] = network_type
url = 'vlan/create/script/acl/'
code, xml = self.submit({'vlan': vlan_map}, 'POST', url)
return self.response(code, xml) | [
"def",
"create_script_acl",
"(",
"self",
",",
"id_vlan",
",",
"network_type",
")",
":",
"vlan_map",
"=",
"dict",
"(",
")",
"vlan_map",
"[",
"'id_vlan'",
"]",
"=",
"id_vlan",
"vlan_map",
"[",
"'network_type'",
"]",
"=",
"network_type",
"url",
"=",
"'vlan/create/script/acl/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'vlan'",
":",
"vlan_map",
"}",
",",
"'POST'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Generate the script acl
:param id_vlan: Vlan Id
:param network_type: v4 or v6
:raise InvalidValueError: Attrs invalids.
:raise XMLError: Networkapi failed to generate the XML response.
:raise VlanACLDuplicatedError: ACL name duplicate.
:raise VlanNotFoundError: Vlan not registered.
:return: Following dictionary:
::
{'vlan': {
'id': < id >,
'nome': '< nome >',
'num_vlan': < num_vlan >,
'descricao': < descricao >
'acl_file_name': < acl_file_name >,
'ativada': < ativada >,
'acl_valida': < acl_valida >,
'acl_file_name_v6': < acl_file_name_v6 >,
'redeipv6': < redeipv6 >,
'acl_valida_v6': < acl_valida_v6 >,
'redeipv4': < redeipv4 >,
'ambiente': < ambiente >,
}} | [
"Generate",
"the",
"script",
"acl"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Vlan.py#L1132-L1171 |
globocom/GloboNetworkAPI-client-python | networkapiclient/UsuarioGrupo.py | UsuarioGrupo.inserir | def inserir(self, id_user, id_group):
"""Create a relationship between User and Group.
:param id_user: Identifier of the User. Integer value and greater than zero.
:param id_group: Identifier of the Group. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'user_group': {'id': < id_user_group >}}
:raise InvalidParameterError: The identifier of User or Group is null and invalid.
:raise GrupoUsuarioNaoExisteError: UserGroup not registered.
:raise UsuarioNaoExisteError: User not registered.
:raise UsuarioGrupoError: User already registered in the group.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_user):
raise InvalidParameterError(
u'The identifier of User is invalid or was not informed.')
if not is_valid_int_param(id_group):
raise InvalidParameterError(
u'The identifier of Group is invalid or was not informed.')
url = 'usergroup/user/' + \
str(id_user) + '/ugroup/' + str(id_group) + '/associate/'
code, xml = self.submit(None, 'PUT', url) | python | def inserir(self, id_user, id_group):
"""Create a relationship between User and Group.
:param id_user: Identifier of the User. Integer value and greater than zero.
:param id_group: Identifier of the Group. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'user_group': {'id': < id_user_group >}}
:raise InvalidParameterError: The identifier of User or Group is null and invalid.
:raise GrupoUsuarioNaoExisteError: UserGroup not registered.
:raise UsuarioNaoExisteError: User not registered.
:raise UsuarioGrupoError: User already registered in the group.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_user):
raise InvalidParameterError(
u'The identifier of User is invalid or was not informed.')
if not is_valid_int_param(id_group):
raise InvalidParameterError(
u'The identifier of Group is invalid or was not informed.')
url = 'usergroup/user/' + \
str(id_user) + '/ugroup/' + str(id_group) + '/associate/'
code, xml = self.submit(None, 'PUT', url) | [
"def",
"inserir",
"(",
"self",
",",
"id_user",
",",
"id_group",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_user",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of User is invalid or was not informed.'",
")",
"if",
"not",
"is_valid_int_param",
"(",
"id_group",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Group is invalid or was not informed.'",
")",
"url",
"=",
"'usergroup/user/'",
"+",
"str",
"(",
"id_user",
")",
"+",
"'/ugroup/'",
"+",
"str",
"(",
"id_group",
")",
"+",
"'/associate/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'PUT'",
",",
"url",
")"
] | Create a relationship between User and Group.
:param id_user: Identifier of the User. Integer value and greater than zero.
:param id_group: Identifier of the Group. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'user_group': {'id': < id_user_group >}}
:raise InvalidParameterError: The identifier of User or Group is null and invalid.
:raise GrupoUsuarioNaoExisteError: UserGroup not registered.
:raise UsuarioNaoExisteError: User not registered.
:raise UsuarioGrupoError: User already registered in the group.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Create",
"a",
"relationship",
"between",
"User",
"and",
"Group",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/UsuarioGrupo.py#L38-L67 |
globocom/GloboNetworkAPI-client-python | networkapiclient/xml_utils.py | dumps | def dumps(map, root_name, root_attributes=None):
"""Cria um string no formato XML a partir dos elementos do map.
Os elementos do mapa serão nós filhos do root_name.
Cada chave do map será um Nó no XML. E o valor da chave será o conteúdo do Nó.
Exemplos:
::
- Mapa: {'networkapi':1}
XML: <?xml version="1.0" encoding="UTF-8"?><networkapi>1</networkapi>
- Mapa: {'networkapi':{'teste':1}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste>1</teste>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':02}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>02</teste02>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':[02,03,04]}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>02</teste02>
<teste02>03</teste02>
<teste02>04</teste02>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':{'a':1, 'b':2}}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>
<a>1</a>
<b>2</b>
</teste02>
</networkapi>
:param map: Dicionário com os dados para serem convertidos em XML.
:param root_name: Nome do nó root do XML.
:param root_attributes: Dicionário com valores para serem adicionados como atributos
para o nó root.
:return: XML
:raise XMLErrorUtils: Representa um erro ocorrido durante o marshall ou unmarshall do XML.
:raise InvalidNodeNameXMLError: Nome inválido para representá-lo como uma TAG de XML.
:raise InvalidNodeTypeXMLError: "Tipo inválido para o conteúdo de uma TAG de XML.
"""
xml = ''
try:
implementation = getDOMImplementation()
except ImportError as i:
raise XMLErrorUtils(i, u'Erro ao obter o DOMImplementation')
doc = implementation.createDocument(None, root_name, None)
try:
root = doc.documentElement
if (root_attributes is not None):
for key, value in root_attributes.iteritems():
attribute = doc.createAttribute(key)
attribute.nodeValue = value
root.setAttributeNode(attribute)
_add_nodes_to_parent(map, root, doc)
xml = doc.toxml('UTF-8')
except InvalidCharacterErr as i:
raise InvalidNodeNameXMLError(
i,
u'Valor inválido para nome de uma TAG de XML: %s' %
root_name)
finally:
doc.unlink()
return xml | python | def dumps(map, root_name, root_attributes=None):
"""Cria um string no formato XML a partir dos elementos do map.
Os elementos do mapa serão nós filhos do root_name.
Cada chave do map será um Nó no XML. E o valor da chave será o conteúdo do Nó.
Exemplos:
::
- Mapa: {'networkapi':1}
XML: <?xml version="1.0" encoding="UTF-8"?><networkapi>1</networkapi>
- Mapa: {'networkapi':{'teste':1}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste>1</teste>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':02}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>02</teste02>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':[02,03,04]}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>02</teste02>
<teste02>03</teste02>
<teste02>04</teste02>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':{'a':1, 'b':2}}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>
<a>1</a>
<b>2</b>
</teste02>
</networkapi>
:param map: Dicionário com os dados para serem convertidos em XML.
:param root_name: Nome do nó root do XML.
:param root_attributes: Dicionário com valores para serem adicionados como atributos
para o nó root.
:return: XML
:raise XMLErrorUtils: Representa um erro ocorrido durante o marshall ou unmarshall do XML.
:raise InvalidNodeNameXMLError: Nome inválido para representá-lo como uma TAG de XML.
:raise InvalidNodeTypeXMLError: "Tipo inválido para o conteúdo de uma TAG de XML.
"""
xml = ''
try:
implementation = getDOMImplementation()
except ImportError as i:
raise XMLErrorUtils(i, u'Erro ao obter o DOMImplementation')
doc = implementation.createDocument(None, root_name, None)
try:
root = doc.documentElement
if (root_attributes is not None):
for key, value in root_attributes.iteritems():
attribute = doc.createAttribute(key)
attribute.nodeValue = value
root.setAttributeNode(attribute)
_add_nodes_to_parent(map, root, doc)
xml = doc.toxml('UTF-8')
except InvalidCharacterErr as i:
raise InvalidNodeNameXMLError(
i,
u'Valor inválido para nome de uma TAG de XML: %s' %
root_name)
finally:
doc.unlink()
return xml | [
"def",
"dumps",
"(",
"map",
",",
"root_name",
",",
"root_attributes",
"=",
"None",
")",
":",
"xml",
"=",
"''",
"try",
":",
"implementation",
"=",
"getDOMImplementation",
"(",
")",
"except",
"ImportError",
"as",
"i",
":",
"raise",
"XMLErrorUtils",
"(",
"i",
",",
"u'Erro ao obter o DOMImplementation'",
")",
"doc",
"=",
"implementation",
".",
"createDocument",
"(",
"None",
",",
"root_name",
",",
"None",
")",
"try",
":",
"root",
"=",
"doc",
".",
"documentElement",
"if",
"(",
"root_attributes",
"is",
"not",
"None",
")",
":",
"for",
"key",
",",
"value",
"in",
"root_attributes",
".",
"iteritems",
"(",
")",
":",
"attribute",
"=",
"doc",
".",
"createAttribute",
"(",
"key",
")",
"attribute",
".",
"nodeValue",
"=",
"value",
"root",
".",
"setAttributeNode",
"(",
"attribute",
")",
"_add_nodes_to_parent",
"(",
"map",
",",
"root",
",",
"doc",
")",
"xml",
"=",
"doc",
".",
"toxml",
"(",
"'UTF-8'",
")",
"except",
"InvalidCharacterErr",
"as",
"i",
":",
"raise",
"InvalidNodeNameXMLError",
"(",
"i",
",",
"u'Valor inválido para nome de uma TAG de XML: %s' ",
"",
"root_name",
")",
"finally",
":",
"doc",
".",
"unlink",
"(",
")",
"return",
"xml"
] | Cria um string no formato XML a partir dos elementos do map.
Os elementos do mapa serão nós filhos do root_name.
Cada chave do map será um Nó no XML. E o valor da chave será o conteúdo do Nó.
Exemplos:
::
- Mapa: {'networkapi':1}
XML: <?xml version="1.0" encoding="UTF-8"?><networkapi>1</networkapi>
- Mapa: {'networkapi':{'teste':1}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste>1</teste>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':02}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>02</teste02>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':[02,03,04]}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>02</teste02>
<teste02>03</teste02>
<teste02>04</teste02>
</networkapi>
- Mapa: {'networkapi':{'teste01':01, 'teste02':{'a':1, 'b':2}}}
XML: <?xml version="1.0" encoding="UTF-8"?>
<networkapi>
<teste01>01</teste01>
<teste02>
<a>1</a>
<b>2</b>
</teste02>
</networkapi>
:param map: Dicionário com os dados para serem convertidos em XML.
:param root_name: Nome do nó root do XML.
:param root_attributes: Dicionário com valores para serem adicionados como atributos
para o nó root.
:return: XML
:raise XMLErrorUtils: Representa um erro ocorrido durante o marshall ou unmarshall do XML.
:raise InvalidNodeNameXMLError: Nome inválido para representá-lo como uma TAG de XML.
:raise InvalidNodeTypeXMLError: "Tipo inválido para o conteúdo de uma TAG de XML. | [
"Cria",
"um",
"string",
"no",
"formato",
"XML",
"a",
"partir",
"dos",
"elementos",
"do",
"map",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/xml_utils.py#L106-L191 |
globocom/GloboNetworkAPI-client-python | networkapiclient/xml_utils.py | loads | def loads(xml, force_list=None):
"""Cria um dicionário com os dados do XML.
O dicionário terá como chave o nome do nó root e como valor o conteúdo do nó root.
Quando o conteúdo de um nó é uma lista de nós então o valor do nó será
um dicionário com uma chave para cada nó.
Entretanto, se existir nós, de um mesmo pai, com o mesmo nome, então eles serão
armazenados em uma mesma chave do dicionário que terá como valor uma lista.
O force_list deverá ter nomes de nós do XML que necessariamente terão seus
valores armazenados em uma lista no dicionário de retorno.
::
Por exemplo:
xml_1 = <?xml version="1.0" encoding="UTF-8"?>
<networkapi versao="1.0">
<testes>
<teste>1<teste>
<teste>2<teste>
</testes>
</networkapi>
A chamada loads(xml_1), irá gerar o dicionário: {'networkapi':{'testes':{'teste':[1,2]}}}
xml_2 = <?xml version="1.0" encoding="UTF-8"?>
<networkapi versao="1.0">
<testes>
<teste>1<teste>
</testes>
</networkapi>
A chamada loads(xml_2), irá gerar o dicionário: {'networkapi':{'testes':{'teste':1}}}
A chamada loads(xml_2, ['teste']), irá gerar o dicionário: {'networkapi':{'testes':{'teste':[1]}}}
Ou seja, o XML_2 tem apenas um nó 'teste', porém, ao informar o parâmetro 'force_list'
com o valor ['teste'], a chave 'teste', no dicionário, terá o valor dentro de uma lista.
:param xml: XML
:param force_list: Lista com os nomes dos nós do XML que deverão ter seus valores
armazenados em lista dentro da chave do dicionário de retorno.
:return: Dicionário com os nós do XML.
:raise XMLErrorUtils: Representa um erro ocorrido durante o marshall ou unmarshall do XML.
"""
if force_list is None:
force_list = []
try:
xml = remove_illegal_characters(xml)
doc = parseString(xml)
except Exception as e:
raise XMLErrorUtils(e, u'Falha ao realizar o parse do xml.')
root = doc.documentElement
map = dict()
attrs_map = dict()
if root.hasAttributes():
attributes = root.attributes
for i in range(attributes.length):
attr = attributes.item(i)
attrs_map[attr.nodeName] = attr.nodeValue
map[root.nodeName] = _create_childs_map(root, force_list)
return map | python | def loads(xml, force_list=None):
"""Cria um dicionário com os dados do XML.
O dicionário terá como chave o nome do nó root e como valor o conteúdo do nó root.
Quando o conteúdo de um nó é uma lista de nós então o valor do nó será
um dicionário com uma chave para cada nó.
Entretanto, se existir nós, de um mesmo pai, com o mesmo nome, então eles serão
armazenados em uma mesma chave do dicionário que terá como valor uma lista.
O force_list deverá ter nomes de nós do XML que necessariamente terão seus
valores armazenados em uma lista no dicionário de retorno.
::
Por exemplo:
xml_1 = <?xml version="1.0" encoding="UTF-8"?>
<networkapi versao="1.0">
<testes>
<teste>1<teste>
<teste>2<teste>
</testes>
</networkapi>
A chamada loads(xml_1), irá gerar o dicionário: {'networkapi':{'testes':{'teste':[1,2]}}}
xml_2 = <?xml version="1.0" encoding="UTF-8"?>
<networkapi versao="1.0">
<testes>
<teste>1<teste>
</testes>
</networkapi>
A chamada loads(xml_2), irá gerar o dicionário: {'networkapi':{'testes':{'teste':1}}}
A chamada loads(xml_2, ['teste']), irá gerar o dicionário: {'networkapi':{'testes':{'teste':[1]}}}
Ou seja, o XML_2 tem apenas um nó 'teste', porém, ao informar o parâmetro 'force_list'
com o valor ['teste'], a chave 'teste', no dicionário, terá o valor dentro de uma lista.
:param xml: XML
:param force_list: Lista com os nomes dos nós do XML que deverão ter seus valores
armazenados em lista dentro da chave do dicionário de retorno.
:return: Dicionário com os nós do XML.
:raise XMLErrorUtils: Representa um erro ocorrido durante o marshall ou unmarshall do XML.
"""
if force_list is None:
force_list = []
try:
xml = remove_illegal_characters(xml)
doc = parseString(xml)
except Exception as e:
raise XMLErrorUtils(e, u'Falha ao realizar o parse do xml.')
root = doc.documentElement
map = dict()
attrs_map = dict()
if root.hasAttributes():
attributes = root.attributes
for i in range(attributes.length):
attr = attributes.item(i)
attrs_map[attr.nodeName] = attr.nodeValue
map[root.nodeName] = _create_childs_map(root, force_list)
return map | [
"def",
"loads",
"(",
"xml",
",",
"force_list",
"=",
"None",
")",
":",
"if",
"force_list",
"is",
"None",
":",
"force_list",
"=",
"[",
"]",
"try",
":",
"xml",
"=",
"remove_illegal_characters",
"(",
"xml",
")",
"doc",
"=",
"parseString",
"(",
"xml",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"XMLErrorUtils",
"(",
"e",
",",
"u'Falha ao realizar o parse do xml.'",
")",
"root",
"=",
"doc",
".",
"documentElement",
"map",
"=",
"dict",
"(",
")",
"attrs_map",
"=",
"dict",
"(",
")",
"if",
"root",
".",
"hasAttributes",
"(",
")",
":",
"attributes",
"=",
"root",
".",
"attributes",
"for",
"i",
"in",
"range",
"(",
"attributes",
".",
"length",
")",
":",
"attr",
"=",
"attributes",
".",
"item",
"(",
"i",
")",
"attrs_map",
"[",
"attr",
".",
"nodeName",
"]",
"=",
"attr",
".",
"nodeValue",
"map",
"[",
"root",
".",
"nodeName",
"]",
"=",
"_create_childs_map",
"(",
"root",
",",
"force_list",
")",
"return",
"map"
] | Cria um dicionário com os dados do XML.
O dicionário terá como chave o nome do nó root e como valor o conteúdo do nó root.
Quando o conteúdo de um nó é uma lista de nós então o valor do nó será
um dicionário com uma chave para cada nó.
Entretanto, se existir nós, de um mesmo pai, com o mesmo nome, então eles serão
armazenados em uma mesma chave do dicionário que terá como valor uma lista.
O force_list deverá ter nomes de nós do XML que necessariamente terão seus
valores armazenados em uma lista no dicionário de retorno.
::
Por exemplo:
xml_1 = <?xml version="1.0" encoding="UTF-8"?>
<networkapi versao="1.0">
<testes>
<teste>1<teste>
<teste>2<teste>
</testes>
</networkapi>
A chamada loads(xml_1), irá gerar o dicionário: {'networkapi':{'testes':{'teste':[1,2]}}}
xml_2 = <?xml version="1.0" encoding="UTF-8"?>
<networkapi versao="1.0">
<testes>
<teste>1<teste>
</testes>
</networkapi>
A chamada loads(xml_2), irá gerar o dicionário: {'networkapi':{'testes':{'teste':1}}}
A chamada loads(xml_2, ['teste']), irá gerar o dicionário: {'networkapi':{'testes':{'teste':[1]}}}
Ou seja, o XML_2 tem apenas um nó 'teste', porém, ao informar o parâmetro 'force_list'
com o valor ['teste'], a chave 'teste', no dicionário, terá o valor dentro de uma lista.
:param xml: XML
:param force_list: Lista com os nomes dos nós do XML que deverão ter seus valores
armazenados em lista dentro da chave do dicionário de retorno.
:return: Dicionário com os nós do XML.
:raise XMLErrorUtils: Representa um erro ocorrido durante o marshall ou unmarshall do XML. | [
"Cria",
"um",
"dicionário",
"com",
"os",
"dados",
"do",
"XML",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/xml_utils.py#L261-L330 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiOptionVip.py | ApiOptionVip.option_vip_by_environment_vip_type | def option_vip_by_environment_vip_type(self, environment_vip_id, type_option):
"""
List option vip.
param environment_vip_id: Id of Environment Vip
Param type_option: type option vip
"""
uri = "api/v3/option-vip/environment-vip/%s/type-option/%s/" % (environment_vip_id, type_option)
return self.get(uri) | python | def option_vip_by_environment_vip_type(self, environment_vip_id, type_option):
"""
List option vip.
param environment_vip_id: Id of Environment Vip
Param type_option: type option vip
"""
uri = "api/v3/option-vip/environment-vip/%s/type-option/%s/" % (environment_vip_id, type_option)
return self.get(uri) | [
"def",
"option_vip_by_environment_vip_type",
"(",
"self",
",",
"environment_vip_id",
",",
"type_option",
")",
":",
"uri",
"=",
"\"api/v3/option-vip/environment-vip/%s/type-option/%s/\"",
"%",
"(",
"environment_vip_id",
",",
"type_option",
")",
"return",
"self",
".",
"get",
"(",
"uri",
")"
] | List option vip.
param environment_vip_id: Id of Environment Vip
Param type_option: type option vip | [
"List",
"option",
"vip",
".",
"param",
"environment_vip_id",
":",
"Id",
"of",
"Environment",
"Vip",
"Param",
"type_option",
":",
"type",
"option",
"vip"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiOptionVip.py#L36-L45 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4Neighbor.py | ApiV4Neighbor.search | def search(self, **kwargs):
"""
Method to search neighbors based on extends search.
:param search: Dict containing QuerySets to find neighbors.
: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 neighbors
"""
return super(ApiV4Neighbor, self).get(self.prepare_url(
'api/v4/neighbor/', kwargs)) | python | def search(self, **kwargs):
"""
Method to search neighbors based on extends search.
:param search: Dict containing QuerySets to find neighbors.
: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 neighbors
"""
return super(ApiV4Neighbor, self).get(self.prepare_url(
'api/v4/neighbor/', kwargs)) | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"ApiV4Neighbor",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"'api/v4/neighbor/'",
",",
"kwargs",
")",
")"
] | Method to search neighbors based on extends search.
:param search: Dict containing QuerySets to find neighbors.
: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 neighbors | [
"Method",
"to",
"search",
"neighbors",
"based",
"on",
"extends",
"search",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4Neighbor.py#L36-L49 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4Neighbor.py | ApiV4Neighbor.delete | def delete(self, ids):
"""
Method to delete neighbors by their id's
:param ids: Identifiers of neighbors
:return: None
"""
url = build_uri_with_ids('api/v4/neighbor/%s/', ids)
return super(ApiV4Neighbor, self).delete(url) | python | def delete(self, ids):
"""
Method to delete neighbors by their id's
:param ids: Identifiers of neighbors
:return: None
"""
url = build_uri_with_ids('api/v4/neighbor/%s/', ids)
return super(ApiV4Neighbor, self).delete(url) | [
"def",
"delete",
"(",
"self",
",",
"ids",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v4/neighbor/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiV4Neighbor",
",",
"self",
")",
".",
"delete",
"(",
"url",
")"
] | Method to delete neighbors by their id's
:param ids: Identifiers of neighbors
:return: None | [
"Method",
"to",
"delete",
"neighbors",
"by",
"their",
"id",
"s"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4Neighbor.py#L65-L73 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4Neighbor.py | ApiV4Neighbor.update | def update(self, neighbors):
"""
Method to update neighbors
:param neighbors: List containing neighbors desired to updated
:return: None
"""
data = {'neighbors': neighbors}
neighbors_ids = [str(env.get('id')) for env in neighbors]
return super(ApiV4Neighbor, self).put('api/v4/neighbor/%s/' %
';'.join(neighbors_ids), data) | python | def update(self, neighbors):
"""
Method to update neighbors
:param neighbors: List containing neighbors desired to updated
:return: None
"""
data = {'neighbors': neighbors}
neighbors_ids = [str(env.get('id')) for env in neighbors]
return super(ApiV4Neighbor, self).put('api/v4/neighbor/%s/' %
';'.join(neighbors_ids), data) | [
"def",
"update",
"(",
"self",
",",
"neighbors",
")",
":",
"data",
"=",
"{",
"'neighbors'",
":",
"neighbors",
"}",
"neighbors_ids",
"=",
"[",
"str",
"(",
"env",
".",
"get",
"(",
"'id'",
")",
")",
"for",
"env",
"in",
"neighbors",
"]",
"return",
"super",
"(",
"ApiV4Neighbor",
",",
"self",
")",
".",
"put",
"(",
"'api/v4/neighbor/%s/'",
"%",
"';'",
".",
"join",
"(",
"neighbors_ids",
")",
",",
"data",
")"
] | Method to update neighbors
:param neighbors: List containing neighbors desired to updated
:return: None | [
"Method",
"to",
"update",
"neighbors"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4Neighbor.py#L75-L87 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4Neighbor.py | ApiV4Neighbor.create | def create(self, neighbors):
"""
Method to create neighbors
:param neighbors: List containing neighbors desired to be created on database
:return: None
"""
data = {'neighbors': neighbors}
return super(ApiV4Neighbor, self).post('api/v4/neighbor/', data) | python | def create(self, neighbors):
"""
Method to create neighbors
:param neighbors: List containing neighbors desired to be created on database
:return: None
"""
data = {'neighbors': neighbors}
return super(ApiV4Neighbor, self).post('api/v4/neighbor/', data) | [
"def",
"create",
"(",
"self",
",",
"neighbors",
")",
":",
"data",
"=",
"{",
"'neighbors'",
":",
"neighbors",
"}",
"return",
"super",
"(",
"ApiV4Neighbor",
",",
"self",
")",
".",
"post",
"(",
"'api/v4/neighbor/'",
",",
"data",
")"
] | Method to create neighbors
:param neighbors: List containing neighbors desired to be created on database
:return: None | [
"Method",
"to",
"create",
"neighbors"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4Neighbor.py#L89-L98 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EspecificacaoGrupoVirtual.py | EspecificacaoGrupoVirtual.add_equipamento | def add_equipamento(
self,
id_tipo_equipamento,
id_modelo,
prefixo,
id_grupo,
id_vlan,
descricao_vlan):
"""Adiciona um equipamento na lista de equipamentos para operação de inserir/alterar um grupo virtual.
:param id_tipo_equipamento: Identificador do tipo de equipamento.
:param id_modelo: Identificador do modelo do equipamento.
:param prefixo: Prefixo do nome do equipamento.
:param id_grupo: Identificador do grupo do equipamento.
:param id_vlan: Identificador da VLAN para criar um IP para o equipamento.
:param descricao_vlan: Descrição do IP que será criado.
:return: None
"""
equipamento_map = dict()
equipamento_map['id_tipo_equipamento'] = id_tipo_equipamento
equipamento_map['id_modelo'] = id_modelo
equipamento_map['prefixo'] = prefixo
equipamento_map['id_grupo'] = id_grupo
equipamento_map['ip'] = {
'id_vlan': id_vlan,
'descricao': descricao_vlan}
self.lista_equipamentos.append(equipamento_map) | python | def add_equipamento(
self,
id_tipo_equipamento,
id_modelo,
prefixo,
id_grupo,
id_vlan,
descricao_vlan):
"""Adiciona um equipamento na lista de equipamentos para operação de inserir/alterar um grupo virtual.
:param id_tipo_equipamento: Identificador do tipo de equipamento.
:param id_modelo: Identificador do modelo do equipamento.
:param prefixo: Prefixo do nome do equipamento.
:param id_grupo: Identificador do grupo do equipamento.
:param id_vlan: Identificador da VLAN para criar um IP para o equipamento.
:param descricao_vlan: Descrição do IP que será criado.
:return: None
"""
equipamento_map = dict()
equipamento_map['id_tipo_equipamento'] = id_tipo_equipamento
equipamento_map['id_modelo'] = id_modelo
equipamento_map['prefixo'] = prefixo
equipamento_map['id_grupo'] = id_grupo
equipamento_map['ip'] = {
'id_vlan': id_vlan,
'descricao': descricao_vlan}
self.lista_equipamentos.append(equipamento_map) | [
"def",
"add_equipamento",
"(",
"self",
",",
"id_tipo_equipamento",
",",
"id_modelo",
",",
"prefixo",
",",
"id_grupo",
",",
"id_vlan",
",",
"descricao_vlan",
")",
":",
"equipamento_map",
"=",
"dict",
"(",
")",
"equipamento_map",
"[",
"'id_tipo_equipamento'",
"]",
"=",
"id_tipo_equipamento",
"equipamento_map",
"[",
"'id_modelo'",
"]",
"=",
"id_modelo",
"equipamento_map",
"[",
"'prefixo'",
"]",
"=",
"prefixo",
"equipamento_map",
"[",
"'id_grupo'",
"]",
"=",
"id_grupo",
"equipamento_map",
"[",
"'ip'",
"]",
"=",
"{",
"'id_vlan'",
":",
"id_vlan",
",",
"'descricao'",
":",
"descricao_vlan",
"}",
"self",
".",
"lista_equipamentos",
".",
"append",
"(",
"equipamento_map",
")"
] | Adiciona um equipamento na lista de equipamentos para operação de inserir/alterar um grupo virtual.
:param id_tipo_equipamento: Identificador do tipo de equipamento.
:param id_modelo: Identificador do modelo do equipamento.
:param prefixo: Prefixo do nome do equipamento.
:param id_grupo: Identificador do grupo do equipamento.
:param id_vlan: Identificador da VLAN para criar um IP para o equipamento.
:param descricao_vlan: Descrição do IP que será criado.
:return: None | [
"Adiciona",
"um",
"equipamento",
"na",
"lista",
"de",
"equipamentos",
"para",
"operação",
"de",
"inserir",
"/",
"alterar",
"um",
"grupo",
"virtual",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EspecificacaoGrupoVirtual.py#L32-L62 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EspecificacaoGrupoVirtual.py | EspecificacaoGrupoVirtual.add_equipamento_remove | def add_equipamento_remove(self, id, id_ip, ids_ips_vips):
'''Adiciona um equipamento na lista de equipamentos para operação de remover um grupo virtual.
:param id: Identificador do equipamento.
:param id_ip: Identificador do IP do equipamento.
:param ids_ips_vips: Lista com os identificadores de IPs criados para cada VIP e associados ao
equipamento.
:return: None
'''
equipament_map = dict()
equipament_map['id'] = id
equipament_map['id_ip'] = id_ip
equipament_map['vips'] = {'id_ip_vip': ids_ips_vips}
self.lista_equipamentos_remove.append(equipament_map) | python | def add_equipamento_remove(self, id, id_ip, ids_ips_vips):
'''Adiciona um equipamento na lista de equipamentos para operação de remover um grupo virtual.
:param id: Identificador do equipamento.
:param id_ip: Identificador do IP do equipamento.
:param ids_ips_vips: Lista com os identificadores de IPs criados para cada VIP e associados ao
equipamento.
:return: None
'''
equipament_map = dict()
equipament_map['id'] = id
equipament_map['id_ip'] = id_ip
equipament_map['vips'] = {'id_ip_vip': ids_ips_vips}
self.lista_equipamentos_remove.append(equipament_map) | [
"def",
"add_equipamento_remove",
"(",
"self",
",",
"id",
",",
"id_ip",
",",
"ids_ips_vips",
")",
":",
"equipament_map",
"=",
"dict",
"(",
")",
"equipament_map",
"[",
"'id'",
"]",
"=",
"id",
"equipament_map",
"[",
"'id_ip'",
"]",
"=",
"id_ip",
"equipament_map",
"[",
"'vips'",
"]",
"=",
"{",
"'id_ip_vip'",
":",
"ids_ips_vips",
"}",
"self",
".",
"lista_equipamentos_remove",
".",
"append",
"(",
"equipament_map",
")"
] | Adiciona um equipamento na lista de equipamentos para operação de remover um grupo virtual.
:param id: Identificador do equipamento.
:param id_ip: Identificador do IP do equipamento.
:param ids_ips_vips: Lista com os identificadores de IPs criados para cada VIP e associados ao
equipamento.
:return: None | [
"Adiciona",
"um",
"equipamento",
"na",
"lista",
"de",
"equipamentos",
"para",
"operação",
"de",
"remover",
"um",
"grupo",
"virtual",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EspecificacaoGrupoVirtual.py#L64-L79 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EspecificacaoGrupoVirtual.py | EspecificacaoGrupoVirtual.add_vip | def add_vip(
self,
id,
real_name_sufixo,
id_vlan,
descricao_vlan,
id_vlan_real,
descricao_vlan_real,
balanceadores,
id_healthcheck_expect,
finalidade,
cliente,
ambiente,
cache,
metodo_bal,
persistencia,
healthcheck_type,
healthcheck,
timeout,
host,
maxcon,
dsr,
bal_ativo,
transbordos,
portas,
real_maps,
id_requisicao_vip,
areanegocio='Orquestra',
nome_servico='Orquestra',
l7_filter=None,
reals_prioritys=None,
reals_weights=None):
"""Adiciona um VIP na lista de VIPs para operação de inserir/alterar um grupo virtual.
Os parâmetros abaixo somente são necessários para a operação de alteração:
- 'real_maps': Deverá conter os reals atualmente criados para a requisição de VIP.
- 'id_requisicao_vip': O identificador da requisição que deverá ser alterada.
Os parâmetros abaixo somente são necessários para a operação de inserção:
- 'id_vlan': Identificador da VLAN para criar o IP do VIP.
- 'descricao_vlan': Descrição do IP do VIP.
- balanceadores: Lista com os identificadores dos balanceadores que serão associados ao IP do VIP.
:param id: Identificador do VIP utilizado pelo sistema de orquestração.
:param real_name_sufixo: Sufixo utilizado para criar os reals_names dos equipamentos na requisição de VIP.
:param id_vlan: Identificador da VLAN para criar um IP para o VIP.
:param descricao_vlan: Descrição do IP que será criado para o VIP.
:param id_vlan_real: Identificador da VLAN para criar os IPs dos equipamentos no VIP.
:param descricao_vlan_real: Descrição dos IPs que serão criados para os equipamentos no VIP.
:param balanceadores: Lista com os identificadores dos balanceadores que serão associados ao IP do VIP.
:param id_healthcheck_expect: Identificador do healthcheck_expect para criar a requisição de VIP.
:param finalidade: Finalidade da requisição de VIP.
:param cliente: Cliente da requisição de VIP.
:param ambiente: Ambiente da requisição de VIP.
:param cache: Cache da requisição de VIP.
:param metodo_bal: Método de balanceamento da requisição de VIP.
:param persistencia: Persistência da requisição de VIP.
:param healthcheck_type: Healthcheck_type da requisição de VIP.
:param healthcheck: Healthcheck da requisição de VIP.
:param timeout: Timeout da requisição de VIP.
:param host: Host da requisição de VIP.
:param maxcon: Máximo número de conexão da requisição de VIP.
:param dsr: DSR da requisição de VIP.
:param bal_ativo: Balanceador ativo da requisição de VIP.
:param transbordos: Lista com os IPs dos transbordos da requisição de VIP.
:param portas: Lista com as portas da requisição de VIP.
:param real_maps: Lista dos mapas com os dados dos reals da requisição de VIP.
Cada mapa deverá ter a estrutura: {'real_name':< real_name>, 'real_ip':< real_ip>}
:param id_requisicao_vip: Identificador da requisição de VIP para operação de alterar um
grupo virtual.
:param areanegocio: Área de negócio para a requisição de VIP (é utilizado 'Orquestra' caso seja None).
:param nome_servico: Nome do serviço para a requisição de VIP (é utilizado 'Orquestra' caso seja None).
:param l7_filter: Filtro L7 para a requisição de VIP.
:param reals_prioritys: Lista dos dados de prioridade dos reals da requisição de VIP (lista de zeros, caso seja None).
:param reals_weights: Lista dos dados de pesos dos reals da requisição de VIP (lista de zeros, caso seja None).
:return: None
"""
vip_map = dict()
vip_map['id'] = id
# Causa erro na hora de validar os nomes de equipamentos (real servers)
#vip_map['real_name_sufixo'] = real_name_sufixo
vip_map['ip_real'] = {
'id_vlan': id_vlan_real,
'descricao': descricao_vlan_real}
vip_map['ip'] = {'id_vlan': id_vlan, 'descricao': descricao_vlan}
vip_map['balanceadores'] = {'id_equipamento': balanceadores}
vip_map['id_healthcheck_expect'] = id_healthcheck_expect
vip_map['finalidade'] = finalidade
vip_map['cliente'] = cliente
vip_map['ambiente'] = ambiente
vip_map['cache'] = cache
vip_map['metodo_bal'] = metodo_bal
vip_map['persistencia'] = persistencia
vip_map['healthcheck_type'] = healthcheck_type
vip_map['healthcheck'] = healthcheck
vip_map['timeout'] = timeout
vip_map['host'] = host
vip_map['maxcon'] = maxcon
vip_map['dsr'] = dsr
# Nao sao mais utilizados (bal_ativo e transbordos)
#vip_map['bal_ativo'] = bal_ativo
#vip_map['transbordos'] = {'transbordo': transbordos}
vip_map['portas_servicos'] = {'porta': portas}
vip_map['reals'] = {'real': real_maps}
vip_map['areanegocio'] = areanegocio
vip_map['nome_servico'] = nome_servico
vip_map['l7_filter'] = l7_filter
if reals_prioritys is not None:
vip_map['reals_prioritys'] = {'reals_priority': reals_prioritys}
else:
vip_map['reals_prioritys'] = None
if metodo_bal.upper() == 'WEIGHTED':
if reals_weights is not None:
vip_map['reals_weights'] = {'reals_weight': reals_weights}
else:
vip_map['reals_weights'] = None
if id_requisicao_vip is not None:
vip_map['requisicao_vip'] = {'id': id_requisicao_vip}
self.lista_vip.append(vip_map) | python | def add_vip(
self,
id,
real_name_sufixo,
id_vlan,
descricao_vlan,
id_vlan_real,
descricao_vlan_real,
balanceadores,
id_healthcheck_expect,
finalidade,
cliente,
ambiente,
cache,
metodo_bal,
persistencia,
healthcheck_type,
healthcheck,
timeout,
host,
maxcon,
dsr,
bal_ativo,
transbordos,
portas,
real_maps,
id_requisicao_vip,
areanegocio='Orquestra',
nome_servico='Orquestra',
l7_filter=None,
reals_prioritys=None,
reals_weights=None):
"""Adiciona um VIP na lista de VIPs para operação de inserir/alterar um grupo virtual.
Os parâmetros abaixo somente são necessários para a operação de alteração:
- 'real_maps': Deverá conter os reals atualmente criados para a requisição de VIP.
- 'id_requisicao_vip': O identificador da requisição que deverá ser alterada.
Os parâmetros abaixo somente são necessários para a operação de inserção:
- 'id_vlan': Identificador da VLAN para criar o IP do VIP.
- 'descricao_vlan': Descrição do IP do VIP.
- balanceadores: Lista com os identificadores dos balanceadores que serão associados ao IP do VIP.
:param id: Identificador do VIP utilizado pelo sistema de orquestração.
:param real_name_sufixo: Sufixo utilizado para criar os reals_names dos equipamentos na requisição de VIP.
:param id_vlan: Identificador da VLAN para criar um IP para o VIP.
:param descricao_vlan: Descrição do IP que será criado para o VIP.
:param id_vlan_real: Identificador da VLAN para criar os IPs dos equipamentos no VIP.
:param descricao_vlan_real: Descrição dos IPs que serão criados para os equipamentos no VIP.
:param balanceadores: Lista com os identificadores dos balanceadores que serão associados ao IP do VIP.
:param id_healthcheck_expect: Identificador do healthcheck_expect para criar a requisição de VIP.
:param finalidade: Finalidade da requisição de VIP.
:param cliente: Cliente da requisição de VIP.
:param ambiente: Ambiente da requisição de VIP.
:param cache: Cache da requisição de VIP.
:param metodo_bal: Método de balanceamento da requisição de VIP.
:param persistencia: Persistência da requisição de VIP.
:param healthcheck_type: Healthcheck_type da requisição de VIP.
:param healthcheck: Healthcheck da requisição de VIP.
:param timeout: Timeout da requisição de VIP.
:param host: Host da requisição de VIP.
:param maxcon: Máximo número de conexão da requisição de VIP.
:param dsr: DSR da requisição de VIP.
:param bal_ativo: Balanceador ativo da requisição de VIP.
:param transbordos: Lista com os IPs dos transbordos da requisição de VIP.
:param portas: Lista com as portas da requisição de VIP.
:param real_maps: Lista dos mapas com os dados dos reals da requisição de VIP.
Cada mapa deverá ter a estrutura: {'real_name':< real_name>, 'real_ip':< real_ip>}
:param id_requisicao_vip: Identificador da requisição de VIP para operação de alterar um
grupo virtual.
:param areanegocio: Área de negócio para a requisição de VIP (é utilizado 'Orquestra' caso seja None).
:param nome_servico: Nome do serviço para a requisição de VIP (é utilizado 'Orquestra' caso seja None).
:param l7_filter: Filtro L7 para a requisição de VIP.
:param reals_prioritys: Lista dos dados de prioridade dos reals da requisição de VIP (lista de zeros, caso seja None).
:param reals_weights: Lista dos dados de pesos dos reals da requisição de VIP (lista de zeros, caso seja None).
:return: None
"""
vip_map = dict()
vip_map['id'] = id
# Causa erro na hora de validar os nomes de equipamentos (real servers)
#vip_map['real_name_sufixo'] = real_name_sufixo
vip_map['ip_real'] = {
'id_vlan': id_vlan_real,
'descricao': descricao_vlan_real}
vip_map['ip'] = {'id_vlan': id_vlan, 'descricao': descricao_vlan}
vip_map['balanceadores'] = {'id_equipamento': balanceadores}
vip_map['id_healthcheck_expect'] = id_healthcheck_expect
vip_map['finalidade'] = finalidade
vip_map['cliente'] = cliente
vip_map['ambiente'] = ambiente
vip_map['cache'] = cache
vip_map['metodo_bal'] = metodo_bal
vip_map['persistencia'] = persistencia
vip_map['healthcheck_type'] = healthcheck_type
vip_map['healthcheck'] = healthcheck
vip_map['timeout'] = timeout
vip_map['host'] = host
vip_map['maxcon'] = maxcon
vip_map['dsr'] = dsr
# Nao sao mais utilizados (bal_ativo e transbordos)
#vip_map['bal_ativo'] = bal_ativo
#vip_map['transbordos'] = {'transbordo': transbordos}
vip_map['portas_servicos'] = {'porta': portas}
vip_map['reals'] = {'real': real_maps}
vip_map['areanegocio'] = areanegocio
vip_map['nome_servico'] = nome_servico
vip_map['l7_filter'] = l7_filter
if reals_prioritys is not None:
vip_map['reals_prioritys'] = {'reals_priority': reals_prioritys}
else:
vip_map['reals_prioritys'] = None
if metodo_bal.upper() == 'WEIGHTED':
if reals_weights is not None:
vip_map['reals_weights'] = {'reals_weight': reals_weights}
else:
vip_map['reals_weights'] = None
if id_requisicao_vip is not None:
vip_map['requisicao_vip'] = {'id': id_requisicao_vip}
self.lista_vip.append(vip_map) | [
"def",
"add_vip",
"(",
"self",
",",
"id",
",",
"real_name_sufixo",
",",
"id_vlan",
",",
"descricao_vlan",
",",
"id_vlan_real",
",",
"descricao_vlan_real",
",",
"balanceadores",
",",
"id_healthcheck_expect",
",",
"finalidade",
",",
"cliente",
",",
"ambiente",
",",
"cache",
",",
"metodo_bal",
",",
"persistencia",
",",
"healthcheck_type",
",",
"healthcheck",
",",
"timeout",
",",
"host",
",",
"maxcon",
",",
"dsr",
",",
"bal_ativo",
",",
"transbordos",
",",
"portas",
",",
"real_maps",
",",
"id_requisicao_vip",
",",
"areanegocio",
"=",
"'Orquestra'",
",",
"nome_servico",
"=",
"'Orquestra'",
",",
"l7_filter",
"=",
"None",
",",
"reals_prioritys",
"=",
"None",
",",
"reals_weights",
"=",
"None",
")",
":",
"vip_map",
"=",
"dict",
"(",
")",
"vip_map",
"[",
"'id'",
"]",
"=",
"id",
"# Causa erro na hora de validar os nomes de equipamentos (real servers)",
"#vip_map['real_name_sufixo'] = real_name_sufixo",
"vip_map",
"[",
"'ip_real'",
"]",
"=",
"{",
"'id_vlan'",
":",
"id_vlan_real",
",",
"'descricao'",
":",
"descricao_vlan_real",
"}",
"vip_map",
"[",
"'ip'",
"]",
"=",
"{",
"'id_vlan'",
":",
"id_vlan",
",",
"'descricao'",
":",
"descricao_vlan",
"}",
"vip_map",
"[",
"'balanceadores'",
"]",
"=",
"{",
"'id_equipamento'",
":",
"balanceadores",
"}",
"vip_map",
"[",
"'id_healthcheck_expect'",
"]",
"=",
"id_healthcheck_expect",
"vip_map",
"[",
"'finalidade'",
"]",
"=",
"finalidade",
"vip_map",
"[",
"'cliente'",
"]",
"=",
"cliente",
"vip_map",
"[",
"'ambiente'",
"]",
"=",
"ambiente",
"vip_map",
"[",
"'cache'",
"]",
"=",
"cache",
"vip_map",
"[",
"'metodo_bal'",
"]",
"=",
"metodo_bal",
"vip_map",
"[",
"'persistencia'",
"]",
"=",
"persistencia",
"vip_map",
"[",
"'healthcheck_type'",
"]",
"=",
"healthcheck_type",
"vip_map",
"[",
"'healthcheck'",
"]",
"=",
"healthcheck",
"vip_map",
"[",
"'timeout'",
"]",
"=",
"timeout",
"vip_map",
"[",
"'host'",
"]",
"=",
"host",
"vip_map",
"[",
"'maxcon'",
"]",
"=",
"maxcon",
"vip_map",
"[",
"'dsr'",
"]",
"=",
"dsr",
"# Nao sao mais utilizados (bal_ativo e transbordos)",
"#vip_map['bal_ativo'] = bal_ativo",
"#vip_map['transbordos'] = {'transbordo': transbordos}",
"vip_map",
"[",
"'portas_servicos'",
"]",
"=",
"{",
"'porta'",
":",
"portas",
"}",
"vip_map",
"[",
"'reals'",
"]",
"=",
"{",
"'real'",
":",
"real_maps",
"}",
"vip_map",
"[",
"'areanegocio'",
"]",
"=",
"areanegocio",
"vip_map",
"[",
"'nome_servico'",
"]",
"=",
"nome_servico",
"vip_map",
"[",
"'l7_filter'",
"]",
"=",
"l7_filter",
"if",
"reals_prioritys",
"is",
"not",
"None",
":",
"vip_map",
"[",
"'reals_prioritys'",
"]",
"=",
"{",
"'reals_priority'",
":",
"reals_prioritys",
"}",
"else",
":",
"vip_map",
"[",
"'reals_prioritys'",
"]",
"=",
"None",
"if",
"metodo_bal",
".",
"upper",
"(",
")",
"==",
"'WEIGHTED'",
":",
"if",
"reals_weights",
"is",
"not",
"None",
":",
"vip_map",
"[",
"'reals_weights'",
"]",
"=",
"{",
"'reals_weight'",
":",
"reals_weights",
"}",
"else",
":",
"vip_map",
"[",
"'reals_weights'",
"]",
"=",
"None",
"if",
"id_requisicao_vip",
"is",
"not",
"None",
":",
"vip_map",
"[",
"'requisicao_vip'",
"]",
"=",
"{",
"'id'",
":",
"id_requisicao_vip",
"}",
"self",
".",
"lista_vip",
".",
"append",
"(",
"vip_map",
")"
] | Adiciona um VIP na lista de VIPs para operação de inserir/alterar um grupo virtual.
Os parâmetros abaixo somente são necessários para a operação de alteração:
- 'real_maps': Deverá conter os reals atualmente criados para a requisição de VIP.
- 'id_requisicao_vip': O identificador da requisição que deverá ser alterada.
Os parâmetros abaixo somente são necessários para a operação de inserção:
- 'id_vlan': Identificador da VLAN para criar o IP do VIP.
- 'descricao_vlan': Descrição do IP do VIP.
- balanceadores: Lista com os identificadores dos balanceadores que serão associados ao IP do VIP.
:param id: Identificador do VIP utilizado pelo sistema de orquestração.
:param real_name_sufixo: Sufixo utilizado para criar os reals_names dos equipamentos na requisição de VIP.
:param id_vlan: Identificador da VLAN para criar um IP para o VIP.
:param descricao_vlan: Descrição do IP que será criado para o VIP.
:param id_vlan_real: Identificador da VLAN para criar os IPs dos equipamentos no VIP.
:param descricao_vlan_real: Descrição dos IPs que serão criados para os equipamentos no VIP.
:param balanceadores: Lista com os identificadores dos balanceadores que serão associados ao IP do VIP.
:param id_healthcheck_expect: Identificador do healthcheck_expect para criar a requisição de VIP.
:param finalidade: Finalidade da requisição de VIP.
:param cliente: Cliente da requisição de VIP.
:param ambiente: Ambiente da requisição de VIP.
:param cache: Cache da requisição de VIP.
:param metodo_bal: Método de balanceamento da requisição de VIP.
:param persistencia: Persistência da requisição de VIP.
:param healthcheck_type: Healthcheck_type da requisição de VIP.
:param healthcheck: Healthcheck da requisição de VIP.
:param timeout: Timeout da requisição de VIP.
:param host: Host da requisição de VIP.
:param maxcon: Máximo número de conexão da requisição de VIP.
:param dsr: DSR da requisição de VIP.
:param bal_ativo: Balanceador ativo da requisição de VIP.
:param transbordos: Lista com os IPs dos transbordos da requisição de VIP.
:param portas: Lista com as portas da requisição de VIP.
:param real_maps: Lista dos mapas com os dados dos reals da requisição de VIP.
Cada mapa deverá ter a estrutura: {'real_name':< real_name>, 'real_ip':< real_ip>}
:param id_requisicao_vip: Identificador da requisição de VIP para operação de alterar um
grupo virtual.
:param areanegocio: Área de negócio para a requisição de VIP (é utilizado 'Orquestra' caso seja None).
:param nome_servico: Nome do serviço para a requisição de VIP (é utilizado 'Orquestra' caso seja None).
:param l7_filter: Filtro L7 para a requisição de VIP.
:param reals_prioritys: Lista dos dados de prioridade dos reals da requisição de VIP (lista de zeros, caso seja None).
:param reals_weights: Lista dos dados de pesos dos reals da requisição de VIP (lista de zeros, caso seja None).
:return: None | [
"Adiciona",
"um",
"VIP",
"na",
"lista",
"de",
"VIPs",
"para",
"operação",
"de",
"inserir",
"/",
"alterar",
"um",
"grupo",
"virtual",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EspecificacaoGrupoVirtual.py#L81-L207 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EspecificacaoGrupoVirtual.py | EspecificacaoGrupoVirtual.add_vip_remove | def add_vip_remove(self, id_ip, id_equipamentos):
'''Adiciona um VIP na lista de VIPs para operação de remover um grupo virtual.
:param id_ip: Identificador do IP criado para o VIP.
:param id_equipamentos: Lista com os identificadores dos balanceadores associados ao IP do VIP.
:return: None
'''
vip_map = dict()
vip_map['id_ip'] = id_ip
vip_map['balanceadores'] = {'id_equipamento': id_equipamentos}
self.lista_vip_remove.append(vip_map) | python | def add_vip_remove(self, id_ip, id_equipamentos):
'''Adiciona um VIP na lista de VIPs para operação de remover um grupo virtual.
:param id_ip: Identificador do IP criado para o VIP.
:param id_equipamentos: Lista com os identificadores dos balanceadores associados ao IP do VIP.
:return: None
'''
vip_map = dict()
vip_map['id_ip'] = id_ip
vip_map['balanceadores'] = {'id_equipamento': id_equipamentos}
self.lista_vip_remove.append(vip_map) | [
"def",
"add_vip_remove",
"(",
"self",
",",
"id_ip",
",",
"id_equipamentos",
")",
":",
"vip_map",
"=",
"dict",
"(",
")",
"vip_map",
"[",
"'id_ip'",
"]",
"=",
"id_ip",
"vip_map",
"[",
"'balanceadores'",
"]",
"=",
"{",
"'id_equipamento'",
":",
"id_equipamentos",
"}",
"self",
".",
"lista_vip_remove",
".",
"append",
"(",
"vip_map",
")"
] | Adiciona um VIP na lista de VIPs para operação de remover um grupo virtual.
:param id_ip: Identificador do IP criado para o VIP.
:param id_equipamentos: Lista com os identificadores dos balanceadores associados ao IP do VIP.
:return: None | [
"Adiciona",
"um",
"VIP",
"na",
"lista",
"de",
"VIPs",
"para",
"operação",
"de",
"remover",
"um",
"grupo",
"virtual",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EspecificacaoGrupoVirtual.py#L209-L221 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EspecificacaoGrupoVirtual.py | EspecificacaoGrupoVirtual.add_vip_incremento | def add_vip_incremento(self, id):
"""Adiciona um vip à especificação do grupo virtual.
:param id: Identificador de referencia do VIP.
"""
vip_map = dict()
vip_map['id'] = id
self.lista_vip.append(vip_map) | python | def add_vip_incremento(self, id):
"""Adiciona um vip à especificação do grupo virtual.
:param id: Identificador de referencia do VIP.
"""
vip_map = dict()
vip_map['id'] = id
self.lista_vip.append(vip_map) | [
"def",
"add_vip_incremento",
"(",
"self",
",",
"id",
")",
":",
"vip_map",
"=",
"dict",
"(",
")",
"vip_map",
"[",
"'id'",
"]",
"=",
"id",
"self",
".",
"lista_vip",
".",
"append",
"(",
"vip_map",
")"
] | Adiciona um vip à especificação do grupo virtual.
:param id: Identificador de referencia do VIP. | [
"Adiciona",
"um",
"vip",
"à",
"especificação",
"do",
"grupo",
"virtual",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EspecificacaoGrupoVirtual.py#L223-L232 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoAcesso.py | EquipamentoAcesso.get_access | def get_access(self, id_access):
"""Get Equipment Access by id.
:return: Dictionary with following:
::
{'equipamento_acesso':
{'id_equipamento': < id_equipamento >,
'fqdn': < fqdn >,
'user': < user >,
'pass': < pass >,
'id_tipo_acesso': < id_tipo_acesso >,
'enable_pass': < enable_pass >}}
"""
if not is_valid_int_param(id_access):
raise InvalidParameterError(u'Equipment Access ID is invalid.')
url = 'equipamentoacesso/id/' + str(id_access) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | python | def get_access(self, id_access):
"""Get Equipment Access by id.
:return: Dictionary with following:
::
{'equipamento_acesso':
{'id_equipamento': < id_equipamento >,
'fqdn': < fqdn >,
'user': < user >,
'pass': < pass >,
'id_tipo_acesso': < id_tipo_acesso >,
'enable_pass': < enable_pass >}}
"""
if not is_valid_int_param(id_access):
raise InvalidParameterError(u'Equipment Access ID is invalid.')
url = 'equipamentoacesso/id/' + str(id_access) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | [
"def",
"get_access",
"(",
"self",
",",
"id_access",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_access",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Equipment Access ID is invalid.'",
")",
"url",
"=",
"'equipamentoacesso/id/'",
"+",
"str",
"(",
"id_access",
")",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'GET'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Get Equipment Access by id.
:return: Dictionary with following:
::
{'equipamento_acesso':
{'id_equipamento': < id_equipamento >,
'fqdn': < fqdn >,
'user': < user >,
'pass': < pass >,
'id_tipo_acesso': < id_tipo_acesso >,
'enable_pass': < enable_pass >}} | [
"Get",
"Equipment",
"Access",
"by",
"id",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoAcesso.py#L38-L61 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoAcesso.py | EquipamentoAcesso.list_by_equip | def list_by_equip(self, name):
"""
List all equipment access by equipment name
:return: Dictionary with the following structure:
::
{‘equipamento_acesso’:[ {'id': <id_equiptos_access>,
'equipamento': <id_equip>,
'fqdn': <fqdn>,
'user': <user>,
'password': <pass>
'tipo_acesso': <id_tipo_acesso>,
'enable_pass': <enable_pass> }]}
:raise InvalidValueError: Invalid parameter.
:raise EquipamentoNotFoundError: Equipment name not found in database.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
equip_access_map = dict()
equip_access_map['name'] = name
code, xml = self.submit(
{"equipamento_acesso": equip_access_map}, 'POST', 'equipamentoacesso/name/')
key = 'equipamento_acesso'
return get_list_map(self.response(code, xml, [key]), key) | python | def list_by_equip(self, name):
"""
List all equipment access by equipment name
:return: Dictionary with the following structure:
::
{‘equipamento_acesso’:[ {'id': <id_equiptos_access>,
'equipamento': <id_equip>,
'fqdn': <fqdn>,
'user': <user>,
'password': <pass>
'tipo_acesso': <id_tipo_acesso>,
'enable_pass': <enable_pass> }]}
:raise InvalidValueError: Invalid parameter.
:raise EquipamentoNotFoundError: Equipment name not found in database.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
equip_access_map = dict()
equip_access_map['name'] = name
code, xml = self.submit(
{"equipamento_acesso": equip_access_map}, 'POST', 'equipamentoacesso/name/')
key = 'equipamento_acesso'
return get_list_map(self.response(code, xml, [key]), key) | [
"def",
"list_by_equip",
"(",
"self",
",",
"name",
")",
":",
"equip_access_map",
"=",
"dict",
"(",
")",
"equip_access_map",
"[",
"'name'",
"]",
"=",
"name",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"\"equipamento_acesso\"",
":",
"equip_access_map",
"}",
",",
"'POST'",
",",
"'equipamentoacesso/name/'",
")",
"key",
"=",
"'equipamento_acesso'",
"return",
"get_list_map",
"(",
"self",
".",
"response",
"(",
"code",
",",
"xml",
",",
"[",
"key",
"]",
")",
",",
"key",
")"
] | List all equipment access by equipment name
:return: Dictionary with the following structure:
::
{‘equipamento_acesso’:[ {'id': <id_equiptos_access>,
'equipamento': <id_equip>,
'fqdn': <fqdn>,
'user': <user>,
'password': <pass>
'tipo_acesso': <id_tipo_acesso>,
'enable_pass': <enable_pass> }]}
:raise InvalidValueError: Invalid parameter.
:raise EquipamentoNotFoundError: Equipment name not found in database.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"List",
"all",
"equipment",
"access",
"by",
"equipment",
"name"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoAcesso.py#L92-L120 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoAcesso.py | EquipamentoAcesso.inserir | def inserir(
self,
id_equipamento,
fqdn,
user,
password,
id_tipo_acesso,
enable_pass):
"""Add new relationship between equipment and access type and returns its id.
:param id_equipamento: Equipment identifier.
:param fqdn: Equipment FQDN.
:param user: User.
:param password: Password.
:param id_tipo_acesso: Access Type identifier.
:param enable_pass: Enable access.
:return: Dictionary with the following: {‘equipamento_acesso’: {‘id’: < id >}}
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise TipoAcessoNaoExisteError: Access Type doesn't exist.
:raise EquipamentoAcessoError: Equipment and access type already associated.
:raise InvalidParameterError: The parameters equipment id, fqdn, user, password or
access type id are invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
equipamento_acesso_map = dict()
equipamento_acesso_map['id_equipamento'] = id_equipamento
equipamento_acesso_map['fqdn'] = fqdn
equipamento_acesso_map['user'] = user
equipamento_acesso_map['pass'] = password
equipamento_acesso_map['id_tipo_acesso'] = id_tipo_acesso
equipamento_acesso_map['enable_pass'] = enable_pass
code, xml = self.submit(
{'equipamento_acesso': equipamento_acesso_map}, 'POST', 'equipamentoacesso/')
return self.response(code, xml) | python | def inserir(
self,
id_equipamento,
fqdn,
user,
password,
id_tipo_acesso,
enable_pass):
"""Add new relationship between equipment and access type and returns its id.
:param id_equipamento: Equipment identifier.
:param fqdn: Equipment FQDN.
:param user: User.
:param password: Password.
:param id_tipo_acesso: Access Type identifier.
:param enable_pass: Enable access.
:return: Dictionary with the following: {‘equipamento_acesso’: {‘id’: < id >}}
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise TipoAcessoNaoExisteError: Access Type doesn't exist.
:raise EquipamentoAcessoError: Equipment and access type already associated.
:raise InvalidParameterError: The parameters equipment id, fqdn, user, password or
access type id are invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
equipamento_acesso_map = dict()
equipamento_acesso_map['id_equipamento'] = id_equipamento
equipamento_acesso_map['fqdn'] = fqdn
equipamento_acesso_map['user'] = user
equipamento_acesso_map['pass'] = password
equipamento_acesso_map['id_tipo_acesso'] = id_tipo_acesso
equipamento_acesso_map['enable_pass'] = enable_pass
code, xml = self.submit(
{'equipamento_acesso': equipamento_acesso_map}, 'POST', 'equipamentoacesso/')
return self.response(code, xml) | [
"def",
"inserir",
"(",
"self",
",",
"id_equipamento",
",",
"fqdn",
",",
"user",
",",
"password",
",",
"id_tipo_acesso",
",",
"enable_pass",
")",
":",
"equipamento_acesso_map",
"=",
"dict",
"(",
")",
"equipamento_acesso_map",
"[",
"'id_equipamento'",
"]",
"=",
"id_equipamento",
"equipamento_acesso_map",
"[",
"'fqdn'",
"]",
"=",
"fqdn",
"equipamento_acesso_map",
"[",
"'user'",
"]",
"=",
"user",
"equipamento_acesso_map",
"[",
"'pass'",
"]",
"=",
"password",
"equipamento_acesso_map",
"[",
"'id_tipo_acesso'",
"]",
"=",
"id_tipo_acesso",
"equipamento_acesso_map",
"[",
"'enable_pass'",
"]",
"=",
"enable_pass",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'equipamento_acesso'",
":",
"equipamento_acesso_map",
"}",
",",
"'POST'",
",",
"'equipamentoacesso/'",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Add new relationship between equipment and access type and returns its id.
:param id_equipamento: Equipment identifier.
:param fqdn: Equipment FQDN.
:param user: User.
:param password: Password.
:param id_tipo_acesso: Access Type identifier.
:param enable_pass: Enable access.
:return: Dictionary with the following: {‘equipamento_acesso’: {‘id’: < id >}}
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise TipoAcessoNaoExisteError: Access Type doesn't exist.
:raise EquipamentoAcessoError: Equipment and access type already associated.
:raise InvalidParameterError: The parameters equipment id, fqdn, user, password or
access type id are invalid or none.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Add",
"new",
"relationship",
"between",
"equipment",
"and",
"access",
"type",
"and",
"returns",
"its",
"id",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoAcesso.py#L122-L160 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoAcesso.py | EquipamentoAcesso.edit_by_id | def edit_by_id(
self,
id_equip_acesso,
id_tipo_acesso,
fqdn,
user,
password,
enable_pass):
"""Edit access type, fqdn, user, password and enable_pass of the relationship of
equipment and access type.
:param id_tipo_acesso: Access type identifier.
:param id_equip_acesso: Equipment identifier.
:param fqdn: Equipment FQDN.
:param user: User.
:param password: Password.
:param enable_pass: Enable access.
:return: None
:raise InvalidParameterError: The parameters fqdn, user, password or
access type id are invalid or none.
:raise EquipamentoAcessoNaoExisteError: Equipment access type relationship 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 not informed.')
equipamento_acesso_map = dict()
equipamento_acesso_map['fqdn'] = fqdn
equipamento_acesso_map['user'] = user
equipamento_acesso_map['pass'] = password
equipamento_acesso_map['enable_pass'] = enable_pass
equipamento_acesso_map['id_tipo_acesso'] = id_tipo_acesso
equipamento_acesso_map['id_equip_acesso'] = id_equip_acesso
url = 'equipamentoacesso/edit/'
code, xml = self.submit(
{'equipamento_acesso': equipamento_acesso_map}, 'POST', url)
return self.response(code, xml) | python | def edit_by_id(
self,
id_equip_acesso,
id_tipo_acesso,
fqdn,
user,
password,
enable_pass):
"""Edit access type, fqdn, user, password and enable_pass of the relationship of
equipment and access type.
:param id_tipo_acesso: Access type identifier.
:param id_equip_acesso: Equipment identifier.
:param fqdn: Equipment FQDN.
:param user: User.
:param password: Password.
:param enable_pass: Enable access.
:return: None
:raise InvalidParameterError: The parameters fqdn, user, password or
access type id are invalid or none.
:raise EquipamentoAcessoNaoExisteError: Equipment access type relationship 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 not informed.')
equipamento_acesso_map = dict()
equipamento_acesso_map['fqdn'] = fqdn
equipamento_acesso_map['user'] = user
equipamento_acesso_map['pass'] = password
equipamento_acesso_map['enable_pass'] = enable_pass
equipamento_acesso_map['id_tipo_acesso'] = id_tipo_acesso
equipamento_acesso_map['id_equip_acesso'] = id_equip_acesso
url = 'equipamentoacesso/edit/'
code, xml = self.submit(
{'equipamento_acesso': equipamento_acesso_map}, 'POST', url)
return self.response(code, xml) | [
"def",
"edit_by_id",
"(",
"self",
",",
"id_equip_acesso",
",",
"id_tipo_acesso",
",",
"fqdn",
",",
"user",
",",
"password",
",",
"enable_pass",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_tipo_acesso",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Access type id is invalid or not informed.'",
")",
"equipamento_acesso_map",
"=",
"dict",
"(",
")",
"equipamento_acesso_map",
"[",
"'fqdn'",
"]",
"=",
"fqdn",
"equipamento_acesso_map",
"[",
"'user'",
"]",
"=",
"user",
"equipamento_acesso_map",
"[",
"'pass'",
"]",
"=",
"password",
"equipamento_acesso_map",
"[",
"'enable_pass'",
"]",
"=",
"enable_pass",
"equipamento_acesso_map",
"[",
"'id_tipo_acesso'",
"]",
"=",
"id_tipo_acesso",
"equipamento_acesso_map",
"[",
"'id_equip_acesso'",
"]",
"=",
"id_equip_acesso",
"url",
"=",
"'equipamentoacesso/edit/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'equipamento_acesso'",
":",
"equipamento_acesso_map",
"}",
",",
"'POST'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Edit access type, fqdn, user, password and enable_pass of the relationship of
equipment and access type.
:param id_tipo_acesso: Access type identifier.
:param id_equip_acesso: Equipment identifier.
:param fqdn: Equipment FQDN.
:param user: User.
:param password: Password.
:param enable_pass: Enable access.
:return: None
:raise InvalidParameterError: The parameters fqdn, user, password or
access type id are invalid or none.
:raise EquipamentoAcessoNaoExisteError: Equipment access type relationship doesn't exist.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Edit",
"access",
"type",
"fqdn",
"user",
"password",
"and",
"enable_pass",
"of",
"the",
"relationship",
"of",
"equipment",
"and",
"access",
"type",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoAcesso.py#L162-L206 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoAcesso.py | EquipamentoAcesso.remover | def remover(self, id_tipo_acesso, id_equipamento):
"""Removes relationship between equipment and access type.
:param id_equipamento: Equipment identifier.
:param id_tipo_acesso: Access type identifier.
:return: None
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise EquipamentoAcessoNaoExisteError: Relationship between equipment and access type doesn't exist.
:raise InvalidParameterError: Equipment and/or access type id is/are invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_tipo_acesso):
raise InvalidParameterError(u'Access type id is invalid.')
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(u'Equipment id is invalid.')
url = 'equipamentoacesso/' + \
str(id_equipamento) + '/' + str(id_tipo_acesso) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | python | def remover(self, id_tipo_acesso, id_equipamento):
"""Removes relationship between equipment and access type.
:param id_equipamento: Equipment identifier.
:param id_tipo_acesso: Access type identifier.
:return: None
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise EquipamentoAcessoNaoExisteError: Relationship between equipment and access type doesn't exist.
:raise InvalidParameterError: Equipment and/or access type id is/are invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_tipo_acesso):
raise InvalidParameterError(u'Access type id is invalid.')
if not is_valid_int_param(id_equipamento):
raise InvalidParameterError(u'Equipment id is invalid.')
url = 'equipamentoacesso/' + \
str(id_equipamento) + '/' + str(id_tipo_acesso) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | [
"def",
"remover",
"(",
"self",
",",
"id_tipo_acesso",
",",
"id_equipamento",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_tipo_acesso",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Access type id is invalid.'",
")",
"if",
"not",
"is_valid_int_param",
"(",
"id_equipamento",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Equipment id is invalid.'",
")",
"url",
"=",
"'equipamentoacesso/'",
"+",
"str",
"(",
"id_equipamento",
")",
"+",
"'/'",
"+",
"str",
"(",
"id_tipo_acesso",
")",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'DELETE'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Removes relationship between equipment and access type.
:param id_equipamento: Equipment identifier.
:param id_tipo_acesso: Access type identifier.
:return: None
:raise EquipamentoNaoExisteError: Equipment doesn't exist.
:raise EquipamentoAcessoNaoExisteError: Relationship between equipment and access type doesn't exist.
:raise InvalidParameterError: Equipment and/or access type id is/are invalid.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Removes",
"relationship",
"between",
"equipment",
"and",
"access",
"type",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoAcesso.py#L208-L234 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Pool.py | Pool.set_poolmember_state | def set_poolmember_state(self, id_pools, pools):
"""
Enable/Disable pool member by list
"""
data = dict()
uri = "api/v3/pool/real/%s/member/status/" % ';'.join(id_pools)
data["server_pools"] = pools
return self.put(uri, data=data) | python | def set_poolmember_state(self, id_pools, pools):
"""
Enable/Disable pool member by list
"""
data = dict()
uri = "api/v3/pool/real/%s/member/status/" % ';'.join(id_pools)
data["server_pools"] = pools
return self.put(uri, data=data) | [
"def",
"set_poolmember_state",
"(",
"self",
",",
"id_pools",
",",
"pools",
")",
":",
"data",
"=",
"dict",
"(",
")",
"uri",
"=",
"\"api/v3/pool/real/%s/member/status/\"",
"%",
"';'",
".",
"join",
"(",
"id_pools",
")",
"data",
"[",
"\"server_pools\"",
"]",
"=",
"pools",
"return",
"self",
".",
"put",
"(",
"uri",
",",
"data",
"=",
"data",
")"
] | Enable/Disable pool member by list | [
"Enable",
"/",
"Disable",
"pool",
"member",
"by",
"list"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Pool.py#L37-L48 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Pool.py | Pool.get_poolmember_state | def get_poolmember_state(self, id_pools, checkstatus=0):
"""
Enable/Disable pool member by list
"""
uri = "api/v3/pool/real/%s/member/status/?checkstatus=%s" % (';'.join(id_pools), checkstatus)
return self.get(uri) | python | def get_poolmember_state(self, id_pools, checkstatus=0):
"""
Enable/Disable pool member by list
"""
uri = "api/v3/pool/real/%s/member/status/?checkstatus=%s" % (';'.join(id_pools), checkstatus)
return self.get(uri) | [
"def",
"get_poolmember_state",
"(",
"self",
",",
"id_pools",
",",
"checkstatus",
"=",
"0",
")",
":",
"uri",
"=",
"\"api/v3/pool/real/%s/member/status/?checkstatus=%s\"",
"%",
"(",
"';'",
".",
"join",
"(",
"id_pools",
")",
",",
"checkstatus",
")",
"return",
"self",
".",
"get",
"(",
"uri",
")"
] | Enable/Disable pool member by list | [
"Enable",
"/",
"Disable",
"pool",
"member",
"by",
"list"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Pool.py#L50-L57 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Pool.py | Pool.list_all | def list_all(self, environment_id, pagination):
"""
List All Pools To Populate Datatable
:param pagination: Object Pagination
:return: Following dictionary:{
"total" : < total >,
"pools" :[{
"id": < id >
"default_port": < default_port >,
"identifier": < identifier >,
"healthcheck": < healthcheck >,
}, ... too ... ]}
:raise NetworkAPIException: Falha ao acessar fonte de dados
"""
uri = "api/pools/"
data = dict()
data["start_record"] = pagination.start_record
data["end_record"] = pagination.end_record
data["asorting_cols"] = pagination.asorting_cols
data["searchable_columns"] = pagination.searchable_columns
data["custom_search"] = pagination.custom_search or None
data["environment_id"] = environment_id or None
return self.post(uri, data=data) | python | def list_all(self, environment_id, pagination):
"""
List All Pools To Populate Datatable
:param pagination: Object Pagination
:return: Following dictionary:{
"total" : < total >,
"pools" :[{
"id": < id >
"default_port": < default_port >,
"identifier": < identifier >,
"healthcheck": < healthcheck >,
}, ... too ... ]}
:raise NetworkAPIException: Falha ao acessar fonte de dados
"""
uri = "api/pools/"
data = dict()
data["start_record"] = pagination.start_record
data["end_record"] = pagination.end_record
data["asorting_cols"] = pagination.asorting_cols
data["searchable_columns"] = pagination.searchable_columns
data["custom_search"] = pagination.custom_search or None
data["environment_id"] = environment_id or None
return self.post(uri, data=data) | [
"def",
"list_all",
"(",
"self",
",",
"environment_id",
",",
"pagination",
")",
":",
"uri",
"=",
"\"api/pools/\"",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"\"start_record\"",
"]",
"=",
"pagination",
".",
"start_record",
"data",
"[",
"\"end_record\"",
"]",
"=",
"pagination",
".",
"end_record",
"data",
"[",
"\"asorting_cols\"",
"]",
"=",
"pagination",
".",
"asorting_cols",
"data",
"[",
"\"searchable_columns\"",
"]",
"=",
"pagination",
".",
"searchable_columns",
"data",
"[",
"\"custom_search\"",
"]",
"=",
"pagination",
".",
"custom_search",
"or",
"None",
"data",
"[",
"\"environment_id\"",
"]",
"=",
"environment_id",
"or",
"None",
"return",
"self",
".",
"post",
"(",
"uri",
",",
"data",
"=",
"data",
")"
] | List All Pools To Populate Datatable
:param pagination: Object Pagination
:return: Following dictionary:{
"total" : < total >,
"pools" :[{
"id": < id >
"default_port": < default_port >,
"identifier": < identifier >,
"healthcheck": < healthcheck >,
}, ... too ... ]}
:raise NetworkAPIException: Falha ao acessar fonte de dados | [
"List",
"All",
"Pools",
"To",
"Populate",
"Datatable"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Pool.py#L59-L88 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Pool.py | Pool.list_all_by_reqvip | def list_all_by_reqvip(self, id_vip, pagination):
"""
List All Pools To Populate Datatable
:param pagination: Object Pagination
:return: Following dictionary:{
"total" : < total >,
"pools" :[{
"id": < id >
"default_port": < default_port >,
"identifier": < identifier >,
"healthcheck": < healthcheck >,
}, ... too ... ]}
:raise NetworkAPIException: Falha ao acessar fonte de dados
"""
uri = "api/pools/pool_list_by_reqvip/"
data = dict()
data["start_record"] = pagination.start_record
data["end_record"] = pagination.end_record
data["asorting_cols"] = pagination.asorting_cols
data["searchable_columns"] = pagination.searchable_columns
data["custom_search"] = pagination.custom_search or None
data["id_vip"] = id_vip or None
return self.post(uri, data=data) | python | def list_all_by_reqvip(self, id_vip, pagination):
"""
List All Pools To Populate Datatable
:param pagination: Object Pagination
:return: Following dictionary:{
"total" : < total >,
"pools" :[{
"id": < id >
"default_port": < default_port >,
"identifier": < identifier >,
"healthcheck": < healthcheck >,
}, ... too ... ]}
:raise NetworkAPIException: Falha ao acessar fonte de dados
"""
uri = "api/pools/pool_list_by_reqvip/"
data = dict()
data["start_record"] = pagination.start_record
data["end_record"] = pagination.end_record
data["asorting_cols"] = pagination.asorting_cols
data["searchable_columns"] = pagination.searchable_columns
data["custom_search"] = pagination.custom_search or None
data["id_vip"] = id_vip or None
return self.post(uri, data=data) | [
"def",
"list_all_by_reqvip",
"(",
"self",
",",
"id_vip",
",",
"pagination",
")",
":",
"uri",
"=",
"\"api/pools/pool_list_by_reqvip/\"",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"\"start_record\"",
"]",
"=",
"pagination",
".",
"start_record",
"data",
"[",
"\"end_record\"",
"]",
"=",
"pagination",
".",
"end_record",
"data",
"[",
"\"asorting_cols\"",
"]",
"=",
"pagination",
".",
"asorting_cols",
"data",
"[",
"\"searchable_columns\"",
"]",
"=",
"pagination",
".",
"searchable_columns",
"data",
"[",
"\"custom_search\"",
"]",
"=",
"pagination",
".",
"custom_search",
"or",
"None",
"data",
"[",
"\"id_vip\"",
"]",
"=",
"id_vip",
"or",
"None",
"return",
"self",
".",
"post",
"(",
"uri",
",",
"data",
"=",
"data",
")"
] | List All Pools To Populate Datatable
:param pagination: Object Pagination
:return: Following dictionary:{
"total" : < total >,
"pools" :[{
"id": < id >
"default_port": < default_port >,
"identifier": < identifier >,
"healthcheck": < healthcheck >,
}, ... too ... ]}
:raise NetworkAPIException: Falha ao acessar fonte de dados | [
"List",
"All",
"Pools",
"To",
"Populate",
"Datatable"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Pool.py#L90-L119 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Pool.py | Pool.remove | def remove(self, pools):
"""
Remove Pools Running Script And Update to Not Created
:param ids: List of ids
:return: None on success
:raise ScriptRemovePoolException
:raise InvalidIdPoolException
:raise NetworkAPIException
"""
data = dict()
data["pools"] = pools
uri = "api/pools/v2/"
return self.delete(uri, data) | python | def remove(self, pools):
"""
Remove Pools Running Script And Update to Not Created
:param ids: List of ids
:return: None on success
:raise ScriptRemovePoolException
:raise InvalidIdPoolException
:raise NetworkAPIException
"""
data = dict()
data["pools"] = pools
uri = "api/pools/v2/"
return self.delete(uri, data) | [
"def",
"remove",
"(",
"self",
",",
"pools",
")",
":",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"\"pools\"",
"]",
"=",
"pools",
"uri",
"=",
"\"api/pools/v2/\"",
"return",
"self",
".",
"delete",
"(",
"uri",
",",
"data",
")"
] | Remove Pools Running Script And Update to Not Created
:param ids: List of ids
:return: None on success
:raise ScriptRemovePoolException
:raise InvalidIdPoolException
:raise NetworkAPIException | [
"Remove",
"Pools",
"Running",
"Script",
"And",
"Update",
"to",
"Not",
"Created"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Pool.py#L322-L340 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Pool.py | Pool.create | def create(self, pools):
"""
Create Pools Running Script And Update to Created
:param pools: List of pools
:return: None on success
:raise PoolDoesNotExistException
:raise ScriptCreatePoolException
:raise InvalidIdPoolException
:raise NetworkAPIException
"""
data = dict()
data["pools"] = pools
uri = "api/pools/v2/"
return self.put(uri, data) | python | def create(self, pools):
"""
Create Pools Running Script And Update to Created
:param pools: List of pools
:return: None on success
:raise PoolDoesNotExistException
:raise ScriptCreatePoolException
:raise InvalidIdPoolException
:raise NetworkAPIException
"""
data = dict()
data["pools"] = pools
uri = "api/pools/v2/"
return self.put(uri, data) | [
"def",
"create",
"(",
"self",
",",
"pools",
")",
":",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"\"pools\"",
"]",
"=",
"pools",
"uri",
"=",
"\"api/pools/v2/\"",
"return",
"self",
".",
"put",
"(",
"uri",
",",
"data",
")"
] | Create Pools Running Script And Update to Created
:param pools: List of pools
:return: None on success
:raise PoolDoesNotExistException
:raise ScriptCreatePoolException
:raise InvalidIdPoolException
:raise NetworkAPIException | [
"Create",
"Pools",
"Running",
"Script",
"And",
"Update",
"to",
"Created"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Pool.py#L342-L361 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Pool.py | Pool.enable | def enable(self, ids):
"""
Enable Pool Members Running Script
:param ids: List of ids
:return: None on success
:raise PoolMemberDoesNotExistException
:raise InvalidIdPoolMemberException
:raise ScriptEnablePoolException
:raise NetworkAPIException
"""
data = dict()
data["ids"] = ids
uri = "api/pools/enable/"
return self.post(uri, data) | python | def enable(self, ids):
"""
Enable Pool Members Running Script
:param ids: List of ids
:return: None on success
:raise PoolMemberDoesNotExistException
:raise InvalidIdPoolMemberException
:raise ScriptEnablePoolException
:raise NetworkAPIException
"""
data = dict()
data["ids"] = ids
uri = "api/pools/enable/"
return self.post(uri, data) | [
"def",
"enable",
"(",
"self",
",",
"ids",
")",
":",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"\"ids\"",
"]",
"=",
"ids",
"uri",
"=",
"\"api/pools/enable/\"",
"return",
"self",
".",
"post",
"(",
"uri",
",",
"data",
")"
] | Enable Pool Members Running Script
:param ids: List of ids
:return: None on success
:raise PoolMemberDoesNotExistException
:raise InvalidIdPoolMemberException
:raise ScriptEnablePoolException
:raise NetworkAPIException | [
"Enable",
"Pool",
"Members",
"Running",
"Script"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Pool.py#L363-L382 |
globocom/GloboNetworkAPI-client-python | networkapiclient/Pool.py | Pool.disable | def disable(self, ids):
"""
Disable Pool Members Running Script
:param ids: List of ids
:return: None on success
:raise PoolMemberDoesNotExistException
:raise InvalidIdPoolMemberException
:raise ScriptDisablePoolException
:raise NetworkAPIException
"""
data = dict()
data["ids"] = ids
uri = "api/pools/disable/"
return self.post(uri, data) | python | def disable(self, ids):
"""
Disable Pool Members Running Script
:param ids: List of ids
:return: None on success
:raise PoolMemberDoesNotExistException
:raise InvalidIdPoolMemberException
:raise ScriptDisablePoolException
:raise NetworkAPIException
"""
data = dict()
data["ids"] = ids
uri = "api/pools/disable/"
return self.post(uri, data) | [
"def",
"disable",
"(",
"self",
",",
"ids",
")",
":",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"\"ids\"",
"]",
"=",
"ids",
"uri",
"=",
"\"api/pools/disable/\"",
"return",
"self",
".",
"post",
"(",
"uri",
",",
"data",
")"
] | Disable Pool Members Running Script
:param ids: List of ids
:return: None on success
:raise PoolMemberDoesNotExistException
:raise InvalidIdPoolMemberException
:raise ScriptDisablePoolException
:raise NetworkAPIException | [
"Disable",
"Pool",
"Members",
"Running",
"Script"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/Pool.py#L384-L403 |
globocom/GloboNetworkAPI-client-python | networkapiclient/DireitoGrupoEquipamento.py | DireitoGrupoEquipamento.listar_por_grupo_usuario | def listar_por_grupo_usuario(self, id_grupo_usuario):
"""Lista todos os direitos de um grupo de usuário em grupos de equipamento.
:param id_grupo_usuario: Identificador do grupo de usuário para filtrar a pesquisa.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
[{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}, … demais direitos …]}
:raise InvalidParameterError: O identificador do grupo de usuário é 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_grupo_usuario):
raise InvalidParameterError(
u'O identificador do grupo de usuário é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/ugrupo/' + str(id_grupo_usuario) + '/'
code, map = self.submit(None, 'GET', url)
key = 'direito_grupo_equipamento'
return get_list_map(self.response(code, map, [key]), key) | python | def listar_por_grupo_usuario(self, id_grupo_usuario):
"""Lista todos os direitos de um grupo de usuário em grupos de equipamento.
:param id_grupo_usuario: Identificador do grupo de usuário para filtrar a pesquisa.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
[{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}, … demais direitos …]}
:raise InvalidParameterError: O identificador do grupo de usuário é 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_grupo_usuario):
raise InvalidParameterError(
u'O identificador do grupo de usuário é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/ugrupo/' + str(id_grupo_usuario) + '/'
code, map = self.submit(None, 'GET', url)
key = 'direito_grupo_equipamento'
return get_list_map(self.response(code, map, [key]), key) | [
"def",
"listar_por_grupo_usuario",
"(",
"self",
",",
"id_grupo_usuario",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_grupo_usuario",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'O identificador do grupo de usuário é inválido ou não foi informado.')",
"",
"url",
"=",
"'direitosgrupoequipamento/ugrupo/'",
"+",
"str",
"(",
"id_grupo_usuario",
")",
"+",
"'/'",
"code",
",",
"map",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'GET'",
",",
"url",
")",
"key",
"=",
"'direito_grupo_equipamento'",
"return",
"get_list_map",
"(",
"self",
".",
"response",
"(",
"code",
",",
"map",
",",
"[",
"key",
"]",
")",
",",
"key",
")"
] | Lista todos os direitos de um grupo de usuário em grupos de equipamento.
:param id_grupo_usuario: Identificador do grupo de usuário para filtrar a pesquisa.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
[{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}, … demais direitos …]}
:raise InvalidParameterError: O identificador do grupo de usuário é 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. | [
"Lista",
"todos",
"os",
"direitos",
"de",
"um",
"grupo",
"de",
"usuário",
"em",
"grupos",
"de",
"equipamento",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DireitoGrupoEquipamento.py#L64-L97 |
globocom/GloboNetworkAPI-client-python | networkapiclient/DireitoGrupoEquipamento.py | DireitoGrupoEquipamento.listar_por_grupo_equipamento | def listar_por_grupo_equipamento(self, id_grupo_equipamento):
"""Lista todos os direitos de grupos de usuário em um grupo de equipamento.
:param id_grupo_equipamento: Identificador do grupo de equipamento para filtrar a pesquisa.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
[{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}, … demais direitos …]}
:raise InvalidParameterError: O identificador do grupo de 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_grupo_equipamento):
raise InvalidParameterError(
u'O identificador do grupo de equipamento é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/egrupo/' + \
str(id_grupo_equipamento) + '/'
code, map = self.submit(None, 'GET', url)
key = 'direito_grupo_equipamento'
return get_list_map(self.response(code, map, [key]), key) | python | def listar_por_grupo_equipamento(self, id_grupo_equipamento):
"""Lista todos os direitos de grupos de usuário em um grupo de equipamento.
:param id_grupo_equipamento: Identificador do grupo de equipamento para filtrar a pesquisa.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
[{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}, … demais direitos …]}
:raise InvalidParameterError: O identificador do grupo de 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_grupo_equipamento):
raise InvalidParameterError(
u'O identificador do grupo de equipamento é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/egrupo/' + \
str(id_grupo_equipamento) + '/'
code, map = self.submit(None, 'GET', url)
key = 'direito_grupo_equipamento'
return get_list_map(self.response(code, map, [key]), key) | [
"def",
"listar_por_grupo_equipamento",
"(",
"self",
",",
"id_grupo_equipamento",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_grupo_equipamento",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'O identificador do grupo de equipamento é inválido ou não foi informado.')",
"",
"url",
"=",
"'direitosgrupoequipamento/egrupo/'",
"+",
"str",
"(",
"id_grupo_equipamento",
")",
"+",
"'/'",
"code",
",",
"map",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'GET'",
",",
"url",
")",
"key",
"=",
"'direito_grupo_equipamento'",
"return",
"get_list_map",
"(",
"self",
".",
"response",
"(",
"code",
",",
"map",
",",
"[",
"key",
"]",
")",
",",
"key",
")"
] | Lista todos os direitos de grupos de usuário em um grupo de equipamento.
:param id_grupo_equipamento: Identificador do grupo de equipamento para filtrar a pesquisa.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
[{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}, … demais direitos …]}
:raise InvalidParameterError: O identificador do grupo de 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. | [
"Lista",
"todos",
"os",
"direitos",
"de",
"grupos",
"de",
"usuário",
"em",
"um",
"grupo",
"de",
"equipamento",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DireitoGrupoEquipamento.py#L99-L133 |
globocom/GloboNetworkAPI-client-python | networkapiclient/DireitoGrupoEquipamento.py | DireitoGrupoEquipamento.buscar_por_id | def buscar_por_id(self, id_direito):
"""Obtém os direitos de um grupo de usuário e um grupo de equipamento.
:param id_direito: Identificador do direito grupo equipamento.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}}
:raise InvalidParameterError: O identificador do direito grupo equipamento é nulo ou inválido.
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento não cadastrado.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta.
"""
if not is_valid_int_param(id_direito):
raise InvalidParameterError(
u'O identificador do direito grupo equipamento é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/' + str(id_direito) + '/'
code, map = self.submit(None, 'GET', url)
return self.response(code, map) | python | def buscar_por_id(self, id_direito):
"""Obtém os direitos de um grupo de usuário e um grupo de equipamento.
:param id_direito: Identificador do direito grupo equipamento.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}}
:raise InvalidParameterError: O identificador do direito grupo equipamento é nulo ou inválido.
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento não cadastrado.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta.
"""
if not is_valid_int_param(id_direito):
raise InvalidParameterError(
u'O identificador do direito grupo equipamento é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/' + str(id_direito) + '/'
code, map = self.submit(None, 'GET', url)
return self.response(code, map) | [
"def",
"buscar_por_id",
"(",
"self",
",",
"id_direito",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_direito",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'O identificador do direito grupo equipamento é inválido ou não foi informado.')",
"",
"url",
"=",
"'direitosgrupoequipamento/'",
"+",
"str",
"(",
"id_direito",
")",
"+",
"'/'",
"code",
",",
"map",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'GET'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"map",
")"
] | Obtém os direitos de um grupo de usuário e um grupo de equipamento.
:param id_direito: Identificador do direito grupo equipamento.
:return: Dicionário com a seguinte estrutura:
::
{'direito_grupo_equipamento':
{'id_grupo_equipamento': < id_grupo_equipamento >,
'exclusao': < exclusao >,
'alterar_config': < alterar_config >,
'nome_grupo_equipamento': < nome_grupo_equipamento >,
'id_grupo_usuario': < id_grupo_usuario >,
'escrita': < escrita >,
'nome_grupo_usuario': < nome_grupo_usuario >,
'id': < id >,
'leitura': < leitura >}}
:raise InvalidParameterError: O identificador do direito grupo equipamento é nulo ou inválido.
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento não cadastrado.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao gerar o XML de resposta. | [
"Obtém",
"os",
"direitos",
"de",
"um",
"grupo",
"de",
"usuário",
"e",
"um",
"grupo",
"de",
"equipamento",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DireitoGrupoEquipamento.py#L135-L168 |
globocom/GloboNetworkAPI-client-python | networkapiclient/DireitoGrupoEquipamento.py | DireitoGrupoEquipamento.inserir | def inserir(
self,
id_grupo_usuario,
id_grupo_equipamento,
leitura,
escrita,
alterar_config,
exclusao):
"""Cria um novo direito de um grupo de usuário em um grupo de equipamento e retorna o seu identificador.
:param id_grupo_usuario: Identificador do grupo de usuário.
:param id_grupo_equipamento: Identificador do grupo de equipamento.
:param leitura: Indicação de permissão de leitura ('0' ou '1').
:param escrita: Indicação de permissão de escrita ('0' ou '1').
:param alterar_config: Indicação de permissão de alterar_config ('0' ou '1').
:param exclusao: Indicação de permissão de exclusão ('0' ou '1').
:return: Dicionário com a seguinte estrutura: {'direito_grupo_equipamento': {'id': < id>}}
:raise InvalidParameterError: Pelo menos um dos parâmetros é nulo ou inválido.
:raise GrupoEquipamentoNaoExisteError: Grupo de Equipamento não cadastrado.
:raise GrupoUsuarioNaoExisteError: Grupo de Usuário não cadastrado.
:raise ValorIndicacaoDireitoInvalidoError: Valor de leitura, escrita, alterar_config e/ou exclusão inválido.
:raise DireitoGrupoEquipamentoDuplicadoError: Já existe direitos cadastrados para o grupo de usuário e grupo
de equipamento informados.
: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.
"""
direito_map = dict()
direito_map['id_grupo_usuario'] = id_grupo_usuario
direito_map['id_grupo_equipamento'] = id_grupo_equipamento
direito_map['leitura'] = leitura
direito_map['escrita'] = escrita
direito_map['alterar_config'] = alterar_config
direito_map['exclusao'] = exclusao
code, xml = self.submit(
{'direito_grupo_equipamento': direito_map}, 'POST', 'direitosgrupoequipamento/')
return self.response(code, xml) | python | def inserir(
self,
id_grupo_usuario,
id_grupo_equipamento,
leitura,
escrita,
alterar_config,
exclusao):
"""Cria um novo direito de um grupo de usuário em um grupo de equipamento e retorna o seu identificador.
:param id_grupo_usuario: Identificador do grupo de usuário.
:param id_grupo_equipamento: Identificador do grupo de equipamento.
:param leitura: Indicação de permissão de leitura ('0' ou '1').
:param escrita: Indicação de permissão de escrita ('0' ou '1').
:param alterar_config: Indicação de permissão de alterar_config ('0' ou '1').
:param exclusao: Indicação de permissão de exclusão ('0' ou '1').
:return: Dicionário com a seguinte estrutura: {'direito_grupo_equipamento': {'id': < id>}}
:raise InvalidParameterError: Pelo menos um dos parâmetros é nulo ou inválido.
:raise GrupoEquipamentoNaoExisteError: Grupo de Equipamento não cadastrado.
:raise GrupoUsuarioNaoExisteError: Grupo de Usuário não cadastrado.
:raise ValorIndicacaoDireitoInvalidoError: Valor de leitura, escrita, alterar_config e/ou exclusão inválido.
:raise DireitoGrupoEquipamentoDuplicadoError: Já existe direitos cadastrados para o grupo de usuário e grupo
de equipamento informados.
: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.
"""
direito_map = dict()
direito_map['id_grupo_usuario'] = id_grupo_usuario
direito_map['id_grupo_equipamento'] = id_grupo_equipamento
direito_map['leitura'] = leitura
direito_map['escrita'] = escrita
direito_map['alterar_config'] = alterar_config
direito_map['exclusao'] = exclusao
code, xml = self.submit(
{'direito_grupo_equipamento': direito_map}, 'POST', 'direitosgrupoequipamento/')
return self.response(code, xml) | [
"def",
"inserir",
"(",
"self",
",",
"id_grupo_usuario",
",",
"id_grupo_equipamento",
",",
"leitura",
",",
"escrita",
",",
"alterar_config",
",",
"exclusao",
")",
":",
"direito_map",
"=",
"dict",
"(",
")",
"direito_map",
"[",
"'id_grupo_usuario'",
"]",
"=",
"id_grupo_usuario",
"direito_map",
"[",
"'id_grupo_equipamento'",
"]",
"=",
"id_grupo_equipamento",
"direito_map",
"[",
"'leitura'",
"]",
"=",
"leitura",
"direito_map",
"[",
"'escrita'",
"]",
"=",
"escrita",
"direito_map",
"[",
"'alterar_config'",
"]",
"=",
"alterar_config",
"direito_map",
"[",
"'exclusao'",
"]",
"=",
"exclusao",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'direito_grupo_equipamento'",
":",
"direito_map",
"}",
",",
"'POST'",
",",
"'direitosgrupoequipamento/'",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Cria um novo direito de um grupo de usuário em um grupo de equipamento e retorna o seu identificador.
:param id_grupo_usuario: Identificador do grupo de usuário.
:param id_grupo_equipamento: Identificador do grupo de equipamento.
:param leitura: Indicação de permissão de leitura ('0' ou '1').
:param escrita: Indicação de permissão de escrita ('0' ou '1').
:param alterar_config: Indicação de permissão de alterar_config ('0' ou '1').
:param exclusao: Indicação de permissão de exclusão ('0' ou '1').
:return: Dicionário com a seguinte estrutura: {'direito_grupo_equipamento': {'id': < id>}}
:raise InvalidParameterError: Pelo menos um dos parâmetros é nulo ou inválido.
:raise GrupoEquipamentoNaoExisteError: Grupo de Equipamento não cadastrado.
:raise GrupoUsuarioNaoExisteError: Grupo de Usuário não cadastrado.
:raise ValorIndicacaoDireitoInvalidoError: Valor de leitura, escrita, alterar_config e/ou exclusão inválido.
:raise DireitoGrupoEquipamentoDuplicadoError: Já existe direitos cadastrados para o grupo de usuário e grupo
de equipamento informados.
: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. | [
"Cria",
"um",
"novo",
"direito",
"de",
"um",
"grupo",
"de",
"usuário",
"em",
"um",
"grupo",
"de",
"equipamento",
"e",
"retorna",
"o",
"seu",
"identificador",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DireitoGrupoEquipamento.py#L170-L209 |
globocom/GloboNetworkAPI-client-python | networkapiclient/DireitoGrupoEquipamento.py | DireitoGrupoEquipamento.alterar | def alterar(self, id_direito, leitura, escrita, alterar_config, exclusao):
"""Altera os direitos de um grupo de usuário em um grupo de equipamento a partir do seu identificador.
:param id_direito: Identificador do direito grupo equipamento.
:param leitura: Indicação de permissão de leitura ('0' ou '1').
:param escrita: Indicação de permissão de escrita ('0' ou '1').
:param alterar_config: Indicação de permissão de alterar_config ('0' ou '1').
:param exclusao: Indicação de permissão de exclusão ('0' ou '1').
:return: None
:raise InvalidParameterError: Pelo menos um dos parâmetros é nulo ou inválido.
:raise ValorIndicacaoDireitoInvalidoError: Valor de leitura, escrita, alterar_config e/ou exclusão inválido.
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento não cadastrado.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
"""
if not is_valid_int_param(id_direito):
raise InvalidParameterError(
u'O identificador do direito grupo equipamento é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/' + str(id_direito) + '/'
direito_map = dict()
direito_map['leitura'] = leitura
direito_map['escrita'] = escrita
direito_map['alterar_config'] = alterar_config
direito_map['exclusao'] = exclusao
code, xml = self.submit(
{'direito_grupo_equipamento': direito_map}, 'PUT', url)
return self.response(code, xml) | python | def alterar(self, id_direito, leitura, escrita, alterar_config, exclusao):
"""Altera os direitos de um grupo de usuário em um grupo de equipamento a partir do seu identificador.
:param id_direito: Identificador do direito grupo equipamento.
:param leitura: Indicação de permissão de leitura ('0' ou '1').
:param escrita: Indicação de permissão de escrita ('0' ou '1').
:param alterar_config: Indicação de permissão de alterar_config ('0' ou '1').
:param exclusao: Indicação de permissão de exclusão ('0' ou '1').
:return: None
:raise InvalidParameterError: Pelo menos um dos parâmetros é nulo ou inválido.
:raise ValorIndicacaoDireitoInvalidoError: Valor de leitura, escrita, alterar_config e/ou exclusão inválido.
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento não cadastrado.
:raise DataBaseError: Falha na networkapi ao acessar o banco de dados.
:raise XMLError: Falha na networkapi ao ler o XML de requisição ou gerar o XML de resposta.
"""
if not is_valid_int_param(id_direito):
raise InvalidParameterError(
u'O identificador do direito grupo equipamento é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/' + str(id_direito) + '/'
direito_map = dict()
direito_map['leitura'] = leitura
direito_map['escrita'] = escrita
direito_map['alterar_config'] = alterar_config
direito_map['exclusao'] = exclusao
code, xml = self.submit(
{'direito_grupo_equipamento': direito_map}, 'PUT', url)
return self.response(code, xml) | [
"def",
"alterar",
"(",
"self",
",",
"id_direito",
",",
"leitura",
",",
"escrita",
",",
"alterar_config",
",",
"exclusao",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_direito",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'O identificador do direito grupo equipamento é inválido ou não foi informado.')",
"",
"url",
"=",
"'direitosgrupoequipamento/'",
"+",
"str",
"(",
"id_direito",
")",
"+",
"'/'",
"direito_map",
"=",
"dict",
"(",
")",
"direito_map",
"[",
"'leitura'",
"]",
"=",
"leitura",
"direito_map",
"[",
"'escrita'",
"]",
"=",
"escrita",
"direito_map",
"[",
"'alterar_config'",
"]",
"=",
"alterar_config",
"direito_map",
"[",
"'exclusao'",
"]",
"=",
"exclusao",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'direito_grupo_equipamento'",
":",
"direito_map",
"}",
",",
"'PUT'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Altera os direitos de um grupo de usuário em um grupo de equipamento a partir do seu identificador.
:param id_direito: Identificador do direito grupo equipamento.
:param leitura: Indicação de permissão de leitura ('0' ou '1').
:param escrita: Indicação de permissão de escrita ('0' ou '1').
:param alterar_config: Indicação de permissão de alterar_config ('0' ou '1').
:param exclusao: Indicação de permissão de exclusão ('0' ou '1').
:return: None
:raise InvalidParameterError: Pelo menos um dos parâmetros é nulo ou inválido.
:raise ValorIndicacaoDireitoInvalidoError: Valor de leitura, escrita, alterar_config e/ou exclusão inválido.
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento 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. | [
"Altera",
"os",
"direitos",
"de",
"um",
"grupo",
"de",
"usuário",
"em",
"um",
"grupo",
"de",
"equipamento",
"a",
"partir",
"do",
"seu",
"identificador",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DireitoGrupoEquipamento.py#L211-L243 |
globocom/GloboNetworkAPI-client-python | networkapiclient/DireitoGrupoEquipamento.py | DireitoGrupoEquipamento.remover | def remover(self, id_direito):
"""Remove os direitos de um grupo de usuário em um grupo de equipamento a partir do seu identificador.
:param id_direito: Identificador do direito grupo equipamento
:return: None
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento não cadastrado.
:raise InvalidParameterError: O identificador do direito grupo 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_direito):
raise InvalidParameterError(
u'O identificador do direito grupo equipamento é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/' + str(id_direito) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | python | def remover(self, id_direito):
"""Remove os direitos de um grupo de usuário em um grupo de equipamento a partir do seu identificador.
:param id_direito: Identificador do direito grupo equipamento
:return: None
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento não cadastrado.
:raise InvalidParameterError: O identificador do direito grupo 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_direito):
raise InvalidParameterError(
u'O identificador do direito grupo equipamento é inválido ou não foi informado.')
url = 'direitosgrupoequipamento/' + str(id_direito) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | [
"def",
"remover",
"(",
"self",
",",
"id_direito",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_direito",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'O identificador do direito grupo equipamento é inválido ou não foi informado.')",
"",
"url",
"=",
"'direitosgrupoequipamento/'",
"+",
"str",
"(",
"id_direito",
")",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'DELETE'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Remove os direitos de um grupo de usuário em um grupo de equipamento a partir do seu identificador.
:param id_direito: Identificador do direito grupo equipamento
:return: None
:raise DireitoGrupoEquipamentoNaoExisteError: Direito Grupo Equipamento não cadastrado.
:raise InvalidParameterError: O identificador do direito grupo 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. | [
"Remove",
"os",
"direitos",
"de",
"um",
"grupo",
"de",
"usuário",
"em",
"um",
"grupo",
"de",
"equipamento",
"a",
"partir",
"do",
"seu",
"identificador",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/DireitoGrupoEquipamento.py#L245-L265 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiObjectGroupPermission.py | ApiObjectGroupPermission.search | def search(self, **kwargs):
"""
Method to search object group permissions based on extends search.
:param search: Dict containing QuerySets to find object group permissions.
: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
"""
return super(ApiObjectGroupPermission, self).get(self.prepare_url('api/v3/object-group-perm/',
kwargs)) | python | def search(self, **kwargs):
"""
Method to search object group permissions based on extends search.
:param search: Dict containing QuerySets to find object group permissions.
: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
"""
return super(ApiObjectGroupPermission, self).get(self.prepare_url('api/v3/object-group-perm/',
kwargs)) | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"ApiObjectGroupPermission",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"'api/v3/object-group-perm/'",
",",
"kwargs",
")",
")"
] | Method to search object group permissions based on extends search.
:param search: Dict containing QuerySets to find object group permissions.
: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 | [
"Method",
"to",
"search",
"object",
"group",
"permissions",
"based",
"on",
"extends",
"search",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiObjectGroupPermission.py#L36-L49 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiObjectGroupPermission.py | ApiObjectGroupPermission.delete | def delete(self, ids):
"""
Method to delete object group permissions by their ids
:param ids: Identifiers of object group permissions
:return: None
"""
url = build_uri_with_ids('api/v3/object-group-perm/%s/', ids)
return super(ApiObjectGroupPermission, self).delete(url) | python | def delete(self, ids):
"""
Method to delete object group permissions by their ids
:param ids: Identifiers of object group permissions
:return: None
"""
url = build_uri_with_ids('api/v3/object-group-perm/%s/', ids)
return super(ApiObjectGroupPermission, self).delete(url) | [
"def",
"delete",
"(",
"self",
",",
"ids",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v3/object-group-perm/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiObjectGroupPermission",
",",
"self",
")",
".",
"delete",
"(",
"url",
")"
] | Method to delete object group permissions by their ids
:param ids: Identifiers of object group permissions
:return: None | [
"Method",
"to",
"delete",
"object",
"group",
"permissions",
"by",
"their",
"ids"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiObjectGroupPermission.py#L65-L73 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiObjectGroupPermission.py | ApiObjectGroupPermission.update | def update(self, ogps):
"""
Method to update object group permissions
:param ogps: List containing object group permissions desired to updated
:return: None
"""
data = {'ogps': ogps}
ogps_ids = [str(ogp.get('id')) for ogp in ogps]
return super(ApiObjectGroupPermission, self).put('api/v3/object-group-perm/%s/' %
';'.join(ogps_ids), data) | python | def update(self, ogps):
"""
Method to update object group permissions
:param ogps: List containing object group permissions desired to updated
:return: None
"""
data = {'ogps': ogps}
ogps_ids = [str(ogp.get('id')) for ogp in ogps]
return super(ApiObjectGroupPermission, self).put('api/v3/object-group-perm/%s/' %
';'.join(ogps_ids), data) | [
"def",
"update",
"(",
"self",
",",
"ogps",
")",
":",
"data",
"=",
"{",
"'ogps'",
":",
"ogps",
"}",
"ogps_ids",
"=",
"[",
"str",
"(",
"ogp",
".",
"get",
"(",
"'id'",
")",
")",
"for",
"ogp",
"in",
"ogps",
"]",
"return",
"super",
"(",
"ApiObjectGroupPermission",
",",
"self",
")",
".",
"put",
"(",
"'api/v3/object-group-perm/%s/'",
"%",
"';'",
".",
"join",
"(",
"ogps_ids",
")",
",",
"data",
")"
] | Method to update object group permissions
:param ogps: List containing object group permissions desired to updated
:return: None | [
"Method",
"to",
"update",
"object",
"group",
"permissions"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiObjectGroupPermission.py#L75-L87 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiObjectGroupPermission.py | ApiObjectGroupPermission.create | def create(self, ogps):
"""
Method to create object group permissions
:param ogps: List containing vrf desired to be created on database
:return: None
"""
data = {'ogps': ogps}
return super(ApiObjectGroupPermission, self).post('api/v3/object-group-perm/', data) | python | def create(self, ogps):
"""
Method to create object group permissions
:param ogps: List containing vrf desired to be created on database
:return: None
"""
data = {'ogps': ogps}
return super(ApiObjectGroupPermission, self).post('api/v3/object-group-perm/', data) | [
"def",
"create",
"(",
"self",
",",
"ogps",
")",
":",
"data",
"=",
"{",
"'ogps'",
":",
"ogps",
"}",
"return",
"super",
"(",
"ApiObjectGroupPermission",
",",
"self",
")",
".",
"post",
"(",
"'api/v3/object-group-perm/'",
",",
"data",
")"
] | Method to create object group permissions
:param ogps: List containing vrf desired to be created on database
:return: None | [
"Method",
"to",
"create",
"object",
"group",
"permissions"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiObjectGroupPermission.py#L89-L98 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoRoteiro.py | EquipamentoRoteiro.inserir | def inserir(self, id_equipment, id_script):
"""Inserts a new Related Equipment with Script and returns its identifier
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_script: Identifier of the Script. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'equipamento_roteiro': {'id': < id_equipment_script >}}
:raise InvalidParameterError: The identifier of Equipment or Script is null and invalid.
:raise RoteiroNaoExisteError: Script not registered.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise EquipamentoRoteiroError: Equipment is already associated with the script.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
equipment_script_map = dict()
equipment_script_map['id_equipment'] = id_equipment
equipment_script_map['id_script'] = id_script
code, xml = self.submit(
{'equipment_script': equipment_script_map}, 'POST', 'equipmentscript/')
return self.response(code, xml) | python | def inserir(self, id_equipment, id_script):
"""Inserts a new Related Equipment with Script and returns its identifier
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_script: Identifier of the Script. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'equipamento_roteiro': {'id': < id_equipment_script >}}
:raise InvalidParameterError: The identifier of Equipment or Script is null and invalid.
:raise RoteiroNaoExisteError: Script not registered.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise EquipamentoRoteiroError: Equipment is already associated with the script.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
equipment_script_map = dict()
equipment_script_map['id_equipment'] = id_equipment
equipment_script_map['id_script'] = id_script
code, xml = self.submit(
{'equipment_script': equipment_script_map}, 'POST', 'equipmentscript/')
return self.response(code, xml) | [
"def",
"inserir",
"(",
"self",
",",
"id_equipment",
",",
"id_script",
")",
":",
"equipment_script_map",
"=",
"dict",
"(",
")",
"equipment_script_map",
"[",
"'id_equipment'",
"]",
"=",
"id_equipment",
"equipment_script_map",
"[",
"'id_script'",
"]",
"=",
"id_script",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'equipment_script'",
":",
"equipment_script_map",
"}",
",",
"'POST'",
",",
"'equipmentscript/'",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Inserts a new Related Equipment with Script and returns its identifier
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_script: Identifier of the Script. Integer value and greater than zero.
:return: Dictionary with the following structure:
::
{'equipamento_roteiro': {'id': < id_equipment_script >}}
:raise InvalidParameterError: The identifier of Equipment or Script is null and invalid.
:raise RoteiroNaoExisteError: Script not registered.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise EquipamentoRoteiroError: Equipment is already associated with the script.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response | [
"Inserts",
"a",
"new",
"Related",
"Equipment",
"with",
"Script",
"and",
"returns",
"its",
"identifier"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoRoteiro.py#L105-L131 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiVrf.py | ApiVrf.search | def search(self, **kwargs):
"""
Method to search vrf's based on extends search.
:param search: Dict containing QuerySets to find vrf'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 vrf's
"""
return super(ApiVrf, self).get(self.prepare_url('api/v3/vrf/',
kwargs)) | python | def search(self, **kwargs):
"""
Method to search vrf's based on extends search.
:param search: Dict containing QuerySets to find vrf'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 vrf's
"""
return super(ApiVrf, self).get(self.prepare_url('api/v3/vrf/',
kwargs)) | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"ApiVrf",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"'api/v3/vrf/'",
",",
"kwargs",
")",
")"
] | Method to search vrf's based on extends search.
:param search: Dict containing QuerySets to find vrf'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 vrf's | [
"Method",
"to",
"search",
"vrf",
"s",
"based",
"on",
"extends",
"search",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiVrf.py#L36-L49 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiVrf.py | ApiVrf.delete | def delete(self, ids):
"""
Method to delete vrf's by their id's
:param ids: Identifiers of vrf's
:return: None
"""
url = build_uri_with_ids('api/v3/vrf/%s/', ids)
return super(ApiVrf, self).delete(url) | python | def delete(self, ids):
"""
Method to delete vrf's by their id's
:param ids: Identifiers of vrf's
:return: None
"""
url = build_uri_with_ids('api/v3/vrf/%s/', ids)
return super(ApiVrf, self).delete(url) | [
"def",
"delete",
"(",
"self",
",",
"ids",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v3/vrf/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiVrf",
",",
"self",
")",
".",
"delete",
"(",
"url",
")"
] | Method to delete vrf's by their id's
:param ids: Identifiers of vrf's
:return: None | [
"Method",
"to",
"delete",
"vrf",
"s",
"by",
"their",
"id",
"s"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiVrf.py#L66-L75 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiVrf.py | ApiVrf.update | def update(self, vrfs):
"""
Method to update vrf's
:param vrfs: List containing vrf's desired to updated
:return: None
"""
data = {'vrfs': vrfs}
vrfs_ids = [str(vrf.get('id')) for vrf in vrfs]
return super(ApiVrf, self).put('api/v3/vrf/%s/' %
';'.join(vrfs_ids), data) | python | def update(self, vrfs):
"""
Method to update vrf's
:param vrfs: List containing vrf's desired to updated
:return: None
"""
data = {'vrfs': vrfs}
vrfs_ids = [str(vrf.get('id')) for vrf in vrfs]
return super(ApiVrf, self).put('api/v3/vrf/%s/' %
';'.join(vrfs_ids), data) | [
"def",
"update",
"(",
"self",
",",
"vrfs",
")",
":",
"data",
"=",
"{",
"'vrfs'",
":",
"vrfs",
"}",
"vrfs_ids",
"=",
"[",
"str",
"(",
"vrf",
".",
"get",
"(",
"'id'",
")",
")",
"for",
"vrf",
"in",
"vrfs",
"]",
"return",
"super",
"(",
"ApiVrf",
",",
"self",
")",
".",
"put",
"(",
"'api/v3/vrf/%s/'",
"%",
"';'",
".",
"join",
"(",
"vrfs_ids",
")",
",",
"data",
")"
] | Method to update vrf's
:param vrfs: List containing vrf's desired to updated
:return: None | [
"Method",
"to",
"update",
"vrf",
"s"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiVrf.py#L77-L89 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiVrf.py | ApiVrf.create | def create(self, vrfs):
"""
Method to create vrf's
:param vrfs: List containing vrf's desired to be created on database
:return: None
"""
data = {'vrfs': vrfs}
return super(ApiVrf, self).post('api/v3/vrf/', data) | python | def create(self, vrfs):
"""
Method to create vrf's
:param vrfs: List containing vrf's desired to be created on database
:return: None
"""
data = {'vrfs': vrfs}
return super(ApiVrf, self).post('api/v3/vrf/', data) | [
"def",
"create",
"(",
"self",
",",
"vrfs",
")",
":",
"data",
"=",
"{",
"'vrfs'",
":",
"vrfs",
"}",
"return",
"super",
"(",
"ApiVrf",
",",
"self",
")",
".",
"post",
"(",
"'api/v3/vrf/'",
",",
"data",
")"
] | Method to create vrf's
:param vrfs: List containing vrf's desired to be created on database
:return: None | [
"Method",
"to",
"create",
"vrf",
"s"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiVrf.py#L91-L100 |
globocom/GloboNetworkAPI-client-python | networkapiclient/TipoEquipamento.py | TipoEquipamento.inserir | def inserir(self, name):
"""Inserts a new Equipment Type and returns its identifier
:param name: Equipment Type name. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'tipo_equipamento': {'id': < id_equipment_ype >}}
:raise InvalidParameterError: Name is null and invalid.
:raise EquipamentoError: There is already a registered Equipment Type with the value of name.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
equipment_type_map = dict()
equipment_type_map['name'] = name
url = 'equipmenttype/'
code, xml = self.submit(
{'equipment_type': equipment_type_map}, 'POST', url)
return self.response(code, xml) | python | def inserir(self, name):
"""Inserts a new Equipment Type and returns its identifier
:param name: Equipment Type name. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'tipo_equipamento': {'id': < id_equipment_ype >}}
:raise InvalidParameterError: Name is null and invalid.
:raise EquipamentoError: There is already a registered Equipment Type with the value of name.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response
"""
equipment_type_map = dict()
equipment_type_map['name'] = name
url = 'equipmenttype/'
code, xml = self.submit(
{'equipment_type': equipment_type_map}, 'POST', url)
return self.response(code, xml) | [
"def",
"inserir",
"(",
"self",
",",
"name",
")",
":",
"equipment_type_map",
"=",
"dict",
"(",
")",
"equipment_type_map",
"[",
"'name'",
"]",
"=",
"name",
"url",
"=",
"'equipmenttype/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'equipment_type'",
":",
"equipment_type_map",
"}",
",",
"'POST'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Inserts a new Equipment Type and returns its identifier
:param name: Equipment Type name. String with a minimum 3 and maximum of 100 characters
:return: Dictionary with the following structure:
::
{'tipo_equipamento': {'id': < id_equipment_ype >}}
:raise InvalidParameterError: Name is null and invalid.
:raise EquipamentoError: There is already a registered Equipment Type with the value of name.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response | [
"Inserts",
"a",
"new",
"Equipment",
"Type",
"and",
"returns",
"its",
"identifier"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/TipoEquipamento.py#L55-L79 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoAmbiente.py | EquipamentoAmbiente.inserir | def inserir(self, id_equipment, id_environment, is_router=0):
"""Inserts a new Related Equipment with Environment and returns its identifier
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param is_router: Identifier of the Environment. Boolean value.
:return: Dictionary with the following structure:
::
{'equipamento_ambiente': {'id': < id_equipment_environment >}}
:raise InvalidParameterError: The identifier of Equipment or Environment is null and invalid.
:raise AmbienteNaoExisteError: Environment not registered.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise EquipamentoAmbienteError: Equipment is already associated with the Environment.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
equipment_environment_map = dict()
equipment_environment_map['id_equipamento'] = id_equipment
equipment_environment_map['id_ambiente'] = id_environment
equipment_environment_map['is_router'] = is_router
code, xml = self.submit(
{'equipamento_ambiente': equipment_environment_map}, 'POST', 'equipamentoambiente/')
return self.response(code, xml) | python | def inserir(self, id_equipment, id_environment, is_router=0):
"""Inserts a new Related Equipment with Environment and returns its identifier
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param is_router: Identifier of the Environment. Boolean value.
:return: Dictionary with the following structure:
::
{'equipamento_ambiente': {'id': < id_equipment_environment >}}
:raise InvalidParameterError: The identifier of Equipment or Environment is null and invalid.
:raise AmbienteNaoExisteError: Environment not registered.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise EquipamentoAmbienteError: Equipment is already associated with the Environment.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
equipment_environment_map = dict()
equipment_environment_map['id_equipamento'] = id_equipment
equipment_environment_map['id_ambiente'] = id_environment
equipment_environment_map['is_router'] = is_router
code, xml = self.submit(
{'equipamento_ambiente': equipment_environment_map}, 'POST', 'equipamentoambiente/')
return self.response(code, xml) | [
"def",
"inserir",
"(",
"self",
",",
"id_equipment",
",",
"id_environment",
",",
"is_router",
"=",
"0",
")",
":",
"equipment_environment_map",
"=",
"dict",
"(",
")",
"equipment_environment_map",
"[",
"'id_equipamento'",
"]",
"=",
"id_equipment",
"equipment_environment_map",
"[",
"'id_ambiente'",
"]",
"=",
"id_environment",
"equipment_environment_map",
"[",
"'is_router'",
"]",
"=",
"is_router",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'equipamento_ambiente'",
":",
"equipment_environment_map",
"}",
",",
"'POST'",
",",
"'equipamentoambiente/'",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Inserts a new Related Equipment with Environment and returns its identifier
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param is_router: Identifier of the Environment. Boolean value.
:return: Dictionary with the following structure:
::
{'equipamento_ambiente': {'id': < id_equipment_environment >}}
:raise InvalidParameterError: The identifier of Equipment or Environment is null and invalid.
:raise AmbienteNaoExisteError: Environment not registered.
:raise EquipamentoNaoExisteError: Equipment not registered.
:raise EquipamentoAmbienteError: Equipment is already associated with the Environment.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Inserts",
"a",
"new",
"Related",
"Equipment",
"with",
"Environment",
"and",
"returns",
"its",
"identifier"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoAmbiente.py#L38-L66 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoAmbiente.py | EquipamentoAmbiente.remover | def remover(self, id_equipment, id_environment):
"""Remove Related Equipment with Environment from by the identifier.
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid.
:raise EquipamentoNotFoundError: Equipment not registered.
:raise EquipamentoAmbienteNaoExisteError: Environment not registered.
:raise VipIpError: IP-related equipment is being used for a request VIP.
:raise XMLError: Networkapi failed to generate the XML response.
:raise DataBaseError: Networkapi failed to access the database.
"""
if not is_valid_int_param(id_equipment):
raise InvalidParameterError(
u'The identifier of Equipment is invalid or was not informed.')
if not is_valid_int_param(id_environment):
raise InvalidParameterError(
u'The identifier of Environment is invalid or was not informed.')
url = 'equipment/' + \
str(id_equipment) + '/environment/' + str(id_environment) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | python | def remover(self, id_equipment, id_environment):
"""Remove Related Equipment with Environment from by the identifier.
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid.
:raise EquipamentoNotFoundError: Equipment not registered.
:raise EquipamentoAmbienteNaoExisteError: Environment not registered.
:raise VipIpError: IP-related equipment is being used for a request VIP.
:raise XMLError: Networkapi failed to generate the XML response.
:raise DataBaseError: Networkapi failed to access the database.
"""
if not is_valid_int_param(id_equipment):
raise InvalidParameterError(
u'The identifier of Equipment is invalid or was not informed.')
if not is_valid_int_param(id_environment):
raise InvalidParameterError(
u'The identifier of Environment is invalid or was not informed.')
url = 'equipment/' + \
str(id_equipment) + '/environment/' + str(id_environment) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | [
"def",
"remover",
"(",
"self",
",",
"id_equipment",
",",
"id_environment",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_equipment",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Equipment is invalid or was not informed.'",
")",
"if",
"not",
"is_valid_int_param",
"(",
"id_environment",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Environment is invalid or was not informed.'",
")",
"url",
"=",
"'equipment/'",
"+",
"str",
"(",
"id_equipment",
")",
"+",
"'/environment/'",
"+",
"str",
"(",
"id_environment",
")",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'DELETE'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Remove Related Equipment with Environment from by the identifier.
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid.
:raise EquipamentoNotFoundError: Equipment not registered.
:raise EquipamentoAmbienteNaoExisteError: Environment not registered.
:raise VipIpError: IP-related equipment is being used for a request VIP.
:raise XMLError: Networkapi failed to generate the XML response.
:raise DataBaseError: Networkapi failed to access the database. | [
"Remove",
"Related",
"Equipment",
"with",
"Environment",
"from",
"by",
"the",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoAmbiente.py#L68-L97 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EquipamentoAmbiente.py | EquipamentoAmbiente.update | def update(self, id_equipment, id_environment, is_router):
"""Remove Related Equipment with Environment from by the identifier.
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param is_router: Identifier of the Environment. Boolean value.
:return: None
:raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid.
:raise EquipamentoNotFoundError: Equipment not registered.
:raise EquipamentoAmbienteNaoExisteError: Environment not registered.
:raise VipIpError: IP-related equipment is being used for a request VIP.
:raise XMLError: Networkapi failed to generate the XML response.
:raise DataBaseError: Networkapi failed to access the database.
"""
if not is_valid_int_param(id_equipment):
raise InvalidParameterError(
u'The identifier of Equipment is invalid or was not informed.')
if not is_valid_int_param(id_environment):
raise InvalidParameterError(
u'The identifier of Environment is invalid or was not informed.')
equipment_environment_map = dict()
equipment_environment_map['id_equipamento'] = id_equipment
equipment_environment_map['id_ambiente'] = id_environment
equipment_environment_map['is_router'] = is_router
code, xml = self.submit(
{'equipamento_ambiente': equipment_environment_map}, 'PUT', 'equipamentoambiente/update/')
return self.response(code, xml) | python | def update(self, id_equipment, id_environment, is_router):
"""Remove Related Equipment with Environment from by the identifier.
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param is_router: Identifier of the Environment. Boolean value.
:return: None
:raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid.
:raise EquipamentoNotFoundError: Equipment not registered.
:raise EquipamentoAmbienteNaoExisteError: Environment not registered.
:raise VipIpError: IP-related equipment is being used for a request VIP.
:raise XMLError: Networkapi failed to generate the XML response.
:raise DataBaseError: Networkapi failed to access the database.
"""
if not is_valid_int_param(id_equipment):
raise InvalidParameterError(
u'The identifier of Equipment is invalid or was not informed.')
if not is_valid_int_param(id_environment):
raise InvalidParameterError(
u'The identifier of Environment is invalid or was not informed.')
equipment_environment_map = dict()
equipment_environment_map['id_equipamento'] = id_equipment
equipment_environment_map['id_ambiente'] = id_environment
equipment_environment_map['is_router'] = is_router
code, xml = self.submit(
{'equipamento_ambiente': equipment_environment_map}, 'PUT', 'equipamentoambiente/update/')
return self.response(code, xml) | [
"def",
"update",
"(",
"self",
",",
"id_equipment",
",",
"id_environment",
",",
"is_router",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_equipment",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Equipment is invalid or was not informed.'",
")",
"if",
"not",
"is_valid_int_param",
"(",
"id_environment",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Environment is invalid or was not informed.'",
")",
"equipment_environment_map",
"=",
"dict",
"(",
")",
"equipment_environment_map",
"[",
"'id_equipamento'",
"]",
"=",
"id_equipment",
"equipment_environment_map",
"[",
"'id_ambiente'",
"]",
"=",
"id_environment",
"equipment_environment_map",
"[",
"'is_router'",
"]",
"=",
"is_router",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'equipamento_ambiente'",
":",
"equipment_environment_map",
"}",
",",
"'PUT'",
",",
"'equipamentoambiente/update/'",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Remove Related Equipment with Environment from by the identifier.
:param id_equipment: Identifier of the Equipment. Integer value and greater than zero.
:param id_environment: Identifier of the Environment. Integer value and greater than zero.
:param is_router: Identifier of the Environment. Boolean value.
:return: None
:raise InvalidParameterError: The identifier of Environment, Equipament is null and invalid.
:raise EquipamentoNotFoundError: Equipment not registered.
:raise EquipamentoAmbienteNaoExisteError: Environment not registered.
:raise VipIpError: IP-related equipment is being used for a request VIP.
:raise XMLError: Networkapi failed to generate the XML response.
:raise DataBaseError: Networkapi failed to access the database. | [
"Remove",
"Related",
"Equipment",
"with",
"Environment",
"from",
"by",
"the",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EquipamentoAmbiente.py#L99-L132 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.remove_connection | def remove_connection(self, interface1, interface2):
"""Remove a connection between two interfaces"""
uri = "api/interface/disconnect/%s/%s/" % (interface1, interface2)
return self.delete(uri) | python | def remove_connection(self, interface1, interface2):
"""Remove a connection between two interfaces"""
uri = "api/interface/disconnect/%s/%s/" % (interface1, interface2)
return self.delete(uri) | [
"def",
"remove_connection",
"(",
"self",
",",
"interface1",
",",
"interface2",
")",
":",
"uri",
"=",
"\"api/interface/disconnect/%s/%s/\"",
"%",
"(",
"interface1",
",",
"interface2",
")",
"return",
"self",
".",
"delete",
"(",
"uri",
")"
] | Remove a connection between two interfaces | [
"Remove",
"a",
"connection",
"between",
"two",
"interfaces"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L56-L61 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.search | def search(self, **kwargs):
"""
Method to search interfaces based on extends search.
:return: Dict containing interfaces.
"""
return super(ApiInterfaceRequest, self).get(self.prepare_url('api/v3/interface/', kwargs)) | python | def search(self, **kwargs):
"""
Method to search interfaces based on extends search.
:return: Dict containing interfaces.
"""
return super(ApiInterfaceRequest, self).get(self.prepare_url('api/v3/interface/', kwargs)) | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"'api/v3/interface/'",
",",
"kwargs",
")",
")"
] | Method to search interfaces based on extends search.
:return: Dict containing interfaces. | [
"Method",
"to",
"search",
"interfaces",
"based",
"on",
"extends",
"search",
".",
":",
"return",
":",
"Dict",
"containing",
"interfaces",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L63-L69 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.get | def get(self, ids, **kwargs):
"""
Method to get interfaces by their ids.
:param ids: List containing identifiers of interfaces.
:return: Dict containing interfaces.
"""
url = build_uri_with_ids('api/v3/interface/%s/', ids)
return super(ApiInterfaceRequest, self).get(self.prepare_url(url, kwargs)) | python | def get(self, ids, **kwargs):
"""
Method to get interfaces by their ids.
:param ids: List containing identifiers of interfaces.
:return: Dict containing interfaces.
"""
url = build_uri_with_ids('api/v3/interface/%s/', ids)
return super(ApiInterfaceRequest, self).get(self.prepare_url(url, kwargs)) | [
"def",
"get",
"(",
"self",
",",
"ids",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v3/interface/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"url",
",",
"kwargs",
")",
")"
] | Method to get interfaces by their ids.
:param ids: List containing identifiers of interfaces.
:return: Dict containing interfaces. | [
"Method",
"to",
"get",
"interfaces",
"by",
"their",
"ids",
".",
":",
"param",
"ids",
":",
"List",
"containing",
"identifiers",
"of",
"interfaces",
".",
":",
"return",
":",
"Dict",
"containing",
"interfaces",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L71-L80 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.remove | def remove(self, ids, **kwargs):
"""
Method to delete interface by id.
:param ids: List containing identifiers of interfaces.
"""
url = build_uri_with_ids('api/v3/interface/%s/', ids)
return super(ApiInterfaceRequest, self).delete(self.prepare_url(url, kwargs)) | python | def remove(self, ids, **kwargs):
"""
Method to delete interface by id.
:param ids: List containing identifiers of interfaces.
"""
url = build_uri_with_ids('api/v3/interface/%s/', ids)
return super(ApiInterfaceRequest, self).delete(self.prepare_url(url, kwargs)) | [
"def",
"remove",
"(",
"self",
",",
"ids",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v3/interface/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"delete",
"(",
"self",
".",
"prepare_url",
"(",
"url",
",",
"kwargs",
")",
")"
] | Method to delete interface by id.
:param ids: List containing identifiers of interfaces. | [
"Method",
"to",
"delete",
"interface",
"by",
"id",
".",
":",
"param",
"ids",
":",
"List",
"containing",
"identifiers",
"of",
"interfaces",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L82-L89 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.create | def create(self, interface):
"""
Method to add an interface.
:param interface: List containing interface's desired to be created on database.
:return: Id.
"""
data = {'interfaces': interface}
return super(ApiInterfaceRequest, self).post('api/v3/interface/', data) | python | def create(self, interface):
"""
Method to add an interface.
:param interface: List containing interface's desired to be created on database.
:return: Id.
"""
data = {'interfaces': interface}
return super(ApiInterfaceRequest, self).post('api/v3/interface/', data) | [
"def",
"create",
"(",
"self",
",",
"interface",
")",
":",
"data",
"=",
"{",
"'interfaces'",
":",
"interface",
"}",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"post",
"(",
"'api/v3/interface/'",
",",
"data",
")"
] | Method to add an interface.
:param interface: List containing interface's desired to be created on database.
:return: Id. | [
"Method",
"to",
"add",
"an",
"interface",
".",
":",
"param",
"interface",
":",
"List",
"containing",
"interface",
"s",
"desired",
"to",
"be",
"created",
"on",
"database",
".",
":",
"return",
":",
"Id",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L91-L99 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.update | def update(self, interfaces=None):
"""
Method to update interface.
:param interfaces: List containing interface's desired to be updated on database.
:return: None.
"""
data = {'interfaces': interfaces}
return super(ApiInterfaceRequest, self).put('api/v3/interface/', data) | python | def update(self, interfaces=None):
"""
Method to update interface.
:param interfaces: List containing interface's desired to be updated on database.
:return: None.
"""
data = {'interfaces': interfaces}
return super(ApiInterfaceRequest, self).put('api/v3/interface/', data) | [
"def",
"update",
"(",
"self",
",",
"interfaces",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'interfaces'",
":",
"interfaces",
"}",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"put",
"(",
"'api/v3/interface/'",
",",
"data",
")"
] | Method to update interface.
:param interfaces: List containing interface's desired to be updated on database.
:return: None. | [
"Method",
"to",
"update",
"interface",
".",
":",
"param",
"interfaces",
":",
"List",
"containing",
"interface",
"s",
"desired",
"to",
"be",
"updated",
"on",
"database",
".",
":",
"return",
":",
"None",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L115-L124 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.associate_interface_environments | def associate_interface_environments(self, int_env_map):
"""
Method to add an interface.
:param int_env_map: List containing interfaces and environments ids desired to be associates.
:return: Id.
"""
data = {'interface_environments': int_env_map}
return super(ApiInterfaceRequest, self).post('api/v3/interface/environments/', data) | python | def associate_interface_environments(self, int_env_map):
"""
Method to add an interface.
:param int_env_map: List containing interfaces and environments ids desired to be associates.
:return: Id.
"""
data = {'interface_environments': int_env_map}
return super(ApiInterfaceRequest, self).post('api/v3/interface/environments/', data) | [
"def",
"associate_interface_environments",
"(",
"self",
",",
"int_env_map",
")",
":",
"data",
"=",
"{",
"'interface_environments'",
":",
"int_env_map",
"}",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"post",
"(",
"'api/v3/interface/environments/'",
",",
"data",
")"
] | Method to add an interface.
:param int_env_map: List containing interfaces and environments ids desired to be associates.
:return: Id. | [
"Method",
"to",
"add",
"an",
"interface",
".",
":",
"param",
"int_env_map",
":",
"List",
"containing",
"interfaces",
"and",
"environments",
"ids",
"desired",
"to",
"be",
"associates",
".",
":",
"return",
":",
"Id",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L140-L148 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.connecting_interfaces | def connecting_interfaces(self, interfaces):
"""
Method to connecting interfaces.
:param interfaces: List containing a dictionary with the interfaces ids and front or back.
:return: 200 OK.
"""
data = {'interfaces': interfaces}
url = 'api/v3/connections/' + str(interfaces[0].get('id')) + '/' + str(interfaces[1].get('id')) + '/'
return super(ApiInterfaceRequest, self).post(url, data) | python | def connecting_interfaces(self, interfaces):
"""
Method to connecting interfaces.
:param interfaces: List containing a dictionary with the interfaces ids and front or back.
:return: 200 OK.
"""
data = {'interfaces': interfaces}
url = 'api/v3/connections/' + str(interfaces[0].get('id')) + '/' + str(interfaces[1].get('id')) + '/'
return super(ApiInterfaceRequest, self).post(url, data) | [
"def",
"connecting_interfaces",
"(",
"self",
",",
"interfaces",
")",
":",
"data",
"=",
"{",
"'interfaces'",
":",
"interfaces",
"}",
"url",
"=",
"'api/v3/connections/'",
"+",
"str",
"(",
"interfaces",
"[",
"0",
"]",
".",
"get",
"(",
"'id'",
")",
")",
"+",
"'/'",
"+",
"str",
"(",
"interfaces",
"[",
"1",
"]",
".",
"get",
"(",
"'id'",
")",
")",
"+",
"'/'",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"post",
"(",
"url",
",",
"data",
")"
] | Method to connecting interfaces.
:param interfaces: List containing a dictionary with the interfaces ids and front or back.
:return: 200 OK. | [
"Method",
"to",
"connecting",
"interfaces",
".",
":",
"param",
"interfaces",
":",
"List",
"containing",
"a",
"dictionary",
"with",
"the",
"interfaces",
"ids",
"and",
"front",
"or",
"back",
".",
":",
"return",
":",
"200",
"OK",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L161-L172 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.disconnecting_interfaces | def disconnecting_interfaces(self, interfaces, **kwargs):
"""
Method to remove the link between interfaces.
:param interfaces: List of ids.
:return: 200 OK.
"""
url = 'api/v3/connections/' + str(interfaces[0]) + '/' + str(interfaces[1]) + '/'
return super(ApiInterfaceRequest, self).delete(self.prepare_url(url, kwargs)) | python | def disconnecting_interfaces(self, interfaces, **kwargs):
"""
Method to remove the link between interfaces.
:param interfaces: List of ids.
:return: 200 OK.
"""
url = 'api/v3/connections/' + str(interfaces[0]) + '/' + str(interfaces[1]) + '/'
return super(ApiInterfaceRequest, self).delete(self.prepare_url(url, kwargs)) | [
"def",
"disconnecting_interfaces",
"(",
"self",
",",
"interfaces",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"'api/v3/connections/'",
"+",
"str",
"(",
"interfaces",
"[",
"0",
"]",
")",
"+",
"'/'",
"+",
"str",
"(",
"interfaces",
"[",
"1",
"]",
")",
"+",
"'/'",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"delete",
"(",
"self",
".",
"prepare_url",
"(",
"url",
",",
"kwargs",
")",
")"
] | Method to remove the link between interfaces.
:param interfaces: List of ids.
:return: 200 OK. | [
"Method",
"to",
"remove",
"the",
"link",
"between",
"interfaces",
".",
":",
"param",
"interfaces",
":",
"List",
"of",
"ids",
".",
":",
"return",
":",
"200",
"OK",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L174-L183 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.create_channel | def create_channel(self, channel):
"""
Method to create a channel.
:param channel: List containing channel's desired to be created on database.
:return: Id.
"""
data = {'channels': channel}
return super(ApiInterfaceRequest, self).post('api/v3/channel/', data) | python | def create_channel(self, channel):
"""
Method to create a channel.
:param channel: List containing channel's desired to be created on database.
:return: Id.
"""
data = {'channels': channel}
return super(ApiInterfaceRequest, self).post('api/v3/channel/', data) | [
"def",
"create_channel",
"(",
"self",
",",
"channel",
")",
":",
"data",
"=",
"{",
"'channels'",
":",
"channel",
"}",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"post",
"(",
"'api/v3/channel/'",
",",
"data",
")"
] | Method to create a channel.
:param channel: List containing channel's desired to be created on database.
:return: Id. | [
"Method",
"to",
"create",
"a",
"channel",
".",
":",
"param",
"channel",
":",
"List",
"containing",
"channel",
"s",
"desired",
"to",
"be",
"created",
"on",
"database",
".",
":",
"return",
":",
"Id",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L187-L195 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiInterface.py | ApiInterfaceRequest.update_channel | def update_channel(self, channel):
"""
Method to update a channel.
:param channel: List containing channel's desired to be created on database.
:return: Id.
"""
data = {'channels': channel}
return super(ApiInterfaceRequest, self).put('api/v3/channel/', data) | python | def update_channel(self, channel):
"""
Method to update a channel.
:param channel: List containing channel's desired to be created on database.
:return: Id.
"""
data = {'channels': channel}
return super(ApiInterfaceRequest, self).put('api/v3/channel/', data) | [
"def",
"update_channel",
"(",
"self",
",",
"channel",
")",
":",
"data",
"=",
"{",
"'channels'",
":",
"channel",
"}",
"return",
"super",
"(",
"ApiInterfaceRequest",
",",
"self",
")",
".",
"put",
"(",
"'api/v3/channel/'",
",",
"data",
")"
] | Method to update a channel.
:param channel: List containing channel's desired to be created on database.
:return: Id. | [
"Method",
"to",
"update",
"a",
"channel",
".",
":",
"param",
"channel",
":",
"List",
"containing",
"channel",
"s",
"desired",
"to",
"be",
"created",
"on",
"database",
".",
":",
"return",
":",
"Id",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiInterface.py#L197-L205 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GrupoL3.py | GrupoL3.inserir | def inserir(self, name):
"""Inserts a new Group L3 and returns its identifier.
:param name: Group L3 name. String with a minimum 2 and maximum of 80 characters
:return: Dictionary with the following structure:
::
{'group_l3': {'id': < id_group_l3 >}}
:raise InvalidParameterError: Name is null and invalid.
:raise NomeGrupoL3DuplicadoError: There is already a registered Group L3 with the value of name.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
group_l3_map = dict()
group_l3_map['name'] = name
code, xml = self.submit({'group_l3': group_l3_map}, 'POST', 'groupl3/')
return self.response(code, xml) | python | def inserir(self, name):
"""Inserts a new Group L3 and returns its identifier.
:param name: Group L3 name. String with a minimum 2 and maximum of 80 characters
:return: Dictionary with the following structure:
::
{'group_l3': {'id': < id_group_l3 >}}
:raise InvalidParameterError: Name is null and invalid.
:raise NomeGrupoL3DuplicadoError: There is already a registered Group L3 with the value of name.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
group_l3_map = dict()
group_l3_map['name'] = name
code, xml = self.submit({'group_l3': group_l3_map}, 'POST', 'groupl3/')
return self.response(code, xml) | [
"def",
"inserir",
"(",
"self",
",",
"name",
")",
":",
"group_l3_map",
"=",
"dict",
"(",
")",
"group_l3_map",
"[",
"'name'",
"]",
"=",
"name",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'group_l3'",
":",
"group_l3_map",
"}",
",",
"'POST'",
",",
"'groupl3/'",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Inserts a new Group L3 and returns its identifier.
:param name: Group L3 name. String with a minimum 2 and maximum of 80 characters
:return: Dictionary with the following structure:
::
{'group_l3': {'id': < id_group_l3 >}}
:raise InvalidParameterError: Name is null and invalid.
:raise NomeGrupoL3DuplicadoError: There is already a registered Group L3 with the value of name.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Inserts",
"a",
"new",
"Group",
"L3",
"and",
"returns",
"its",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GrupoL3.py#L58-L80 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GrupoL3.py | GrupoL3.alterar | def alterar(self, id_groupl3, name):
"""Change Group L3 from by the identifier.
:param id_groupl3: Identifier of the Group L3. Integer value and greater than zero.
:param name: Group L3 name. String with a minimum 2 and maximum of 80 characters
:return: None
:raise InvalidParameterError: The identifier of Group L3 or name is null and invalid.
:raise NomeGrupoL3DuplicadoError: There is already a registered Group L3 with the value of name.
:raise GrupoL3NaoExisteError: Group L3 not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_groupl3):
raise InvalidParameterError(
u'The identifier of Group L3 is invalid or was not informed.')
url = 'groupl3/' + str(id_groupl3) + '/'
group_l3_map = dict()
group_l3_map['name'] = name
code, xml = self.submit({'groupl3': group_l3_map}, 'PUT', url)
return self.response(code, xml) | python | def alterar(self, id_groupl3, name):
"""Change Group L3 from by the identifier.
:param id_groupl3: Identifier of the Group L3. Integer value and greater than zero.
:param name: Group L3 name. String with a minimum 2 and maximum of 80 characters
:return: None
:raise InvalidParameterError: The identifier of Group L3 or name is null and invalid.
:raise NomeGrupoL3DuplicadoError: There is already a registered Group L3 with the value of name.
:raise GrupoL3NaoExisteError: Group L3 not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_groupl3):
raise InvalidParameterError(
u'The identifier of Group L3 is invalid or was not informed.')
url = 'groupl3/' + str(id_groupl3) + '/'
group_l3_map = dict()
group_l3_map['name'] = name
code, xml = self.submit({'groupl3': group_l3_map}, 'PUT', url)
return self.response(code, xml) | [
"def",
"alterar",
"(",
"self",
",",
"id_groupl3",
",",
"name",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_groupl3",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Group L3 is invalid or was not informed.'",
")",
"url",
"=",
"'groupl3/'",
"+",
"str",
"(",
"id_groupl3",
")",
"+",
"'/'",
"group_l3_map",
"=",
"dict",
"(",
")",
"group_l3_map",
"[",
"'name'",
"]",
"=",
"name",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'groupl3'",
":",
"group_l3_map",
"}",
",",
"'PUT'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Change Group L3 from by the identifier.
:param id_groupl3: Identifier of the Group L3. Integer value and greater than zero.
:param name: Group L3 name. String with a minimum 2 and maximum of 80 characters
:return: None
:raise InvalidParameterError: The identifier of Group L3 or name is null and invalid.
:raise NomeGrupoL3DuplicadoError: There is already a registered Group L3 with the value of name.
:raise GrupoL3NaoExisteError: Group L3 not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Change",
"Group",
"L3",
"from",
"by",
"the",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GrupoL3.py#L82-L108 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GrupoL3.py | GrupoL3.remover | def remover(self, id_groupl3):
"""Remove Group L3 from by the identifier.
:param id_groupl3: Identifier of the Group L3. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Group L3 is null and invalid.
:raise GrupoL3NaoExisteError: Group L3 not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_groupl3):
raise InvalidParameterError(
u'The identifier of Group L3 is invalid or was not informed.')
url = 'groupl3/' + str(id_groupl3) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | python | def remover(self, id_groupl3):
"""Remove Group L3 from by the identifier.
:param id_groupl3: Identifier of the Group L3. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Group L3 is null and invalid.
:raise GrupoL3NaoExisteError: Group L3 not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response.
"""
if not is_valid_int_param(id_groupl3):
raise InvalidParameterError(
u'The identifier of Group L3 is invalid or was not informed.')
url = 'groupl3/' + str(id_groupl3) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | [
"def",
"remover",
"(",
"self",
",",
"id_groupl3",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_groupl3",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Group L3 is invalid or was not informed.'",
")",
"url",
"=",
"'groupl3/'",
"+",
"str",
"(",
"id_groupl3",
")",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'DELETE'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Remove Group L3 from by the identifier.
:param id_groupl3: Identifier of the Group L3. Integer value and greater than zero.
:return: None
:raise InvalidParameterError: The identifier of Group L3 is null and invalid.
:raise GrupoL3NaoExisteError: Group L3 not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Remove",
"Group",
"L3",
"from",
"by",
"the",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GrupoL3.py#L110-L131 |
globocom/GloboNetworkAPI-client-python | networkapiclient/rest.py | Rest.get | def get(self, url, auth_map=None):
"""Envia uma requisição GET para a URL informada.
Se auth_map é diferente de None, então deverá conter as
chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar
a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
:param url: URL para enviar a requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
try:
LOG.debug('GET %s', url)
request = Request(url)
if auth_map is not None:
for key in auth_map.iterkeys():
request.add_header(key, auth_map[key])
# request.add_header('NETWORKAPI_PASSWORD', auth_map['NETWORKAPI_PASSWORD'])
# request.add_header('NETWORKAPI_USERNAME', auth_map['NETWORKAPI_USERNAME'])
content = urlopen(request).read()
response_code = 200
LOG.debug('GET %s returns %s\n%s', url, response_code, content)
return response_code, content
except HTTPError as e:
response_code = e.code
content = ''
if int(e.code) == 500:
content = e.read()
LOG.debug('GET %s returns %s\n%s', url, response_code, content)
return response_code, content
except URLError as e:
raise ConnectionError(e)
except Exception as e:
raise RestError(e, e.message) | python | def get(self, url, auth_map=None):
"""Envia uma requisição GET para a URL informada.
Se auth_map é diferente de None, então deverá conter as
chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar
a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
:param url: URL para enviar a requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
try:
LOG.debug('GET %s', url)
request = Request(url)
if auth_map is not None:
for key in auth_map.iterkeys():
request.add_header(key, auth_map[key])
# request.add_header('NETWORKAPI_PASSWORD', auth_map['NETWORKAPI_PASSWORD'])
# request.add_header('NETWORKAPI_USERNAME', auth_map['NETWORKAPI_USERNAME'])
content = urlopen(request).read()
response_code = 200
LOG.debug('GET %s returns %s\n%s', url, response_code, content)
return response_code, content
except HTTPError as e:
response_code = e.code
content = ''
if int(e.code) == 500:
content = e.read()
LOG.debug('GET %s returns %s\n%s', url, response_code, content)
return response_code, content
except URLError as e:
raise ConnectionError(e)
except Exception as e:
raise RestError(e, e.message) | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"auth_map",
"=",
"None",
")",
":",
"try",
":",
"LOG",
".",
"debug",
"(",
"'GET %s'",
",",
"url",
")",
"request",
"=",
"Request",
"(",
"url",
")",
"if",
"auth_map",
"is",
"not",
"None",
":",
"for",
"key",
"in",
"auth_map",
".",
"iterkeys",
"(",
")",
":",
"request",
".",
"add_header",
"(",
"key",
",",
"auth_map",
"[",
"key",
"]",
")",
"# request.add_header('NETWORKAPI_PASSWORD', auth_map['NETWORKAPI_PASSWORD'])",
"# request.add_header('NETWORKAPI_USERNAME', auth_map['NETWORKAPI_USERNAME'])",
"content",
"=",
"urlopen",
"(",
"request",
")",
".",
"read",
"(",
")",
"response_code",
"=",
"200",
"LOG",
".",
"debug",
"(",
"'GET %s returns %s\\n%s'",
",",
"url",
",",
"response_code",
",",
"content",
")",
"return",
"response_code",
",",
"content",
"except",
"HTTPError",
"as",
"e",
":",
"response_code",
"=",
"e",
".",
"code",
"content",
"=",
"''",
"if",
"int",
"(",
"e",
".",
"code",
")",
"==",
"500",
":",
"content",
"=",
"e",
".",
"read",
"(",
")",
"LOG",
".",
"debug",
"(",
"'GET %s returns %s\\n%s'",
",",
"url",
",",
"response_code",
",",
"content",
")",
"return",
"response_code",
",",
"content",
"except",
"URLError",
"as",
"e",
":",
"raise",
"ConnectionError",
"(",
"e",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"RestError",
"(",
"e",
",",
"e",
".",
"message",
")"
] | Envia uma requisição GET para a URL informada.
Se auth_map é diferente de None, então deverá conter as
chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar
a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
:param url: URL para enviar a requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI. | [
"Envia",
"uma",
"requisição",
"GET",
"para",
"a",
"URL",
"informada",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L78-L117 |
globocom/GloboNetworkAPI-client-python | networkapiclient/rest.py | Rest.put | def put(self, url, request_data, content_type=None, auth_map=None):
"""Envia uma requisição PUT para a URL informada.
Se auth_map é diferente de None, então deverá conter as
chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar
a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
:param url: URL para enviar a requisição HTTP.
:param request_data: Descrição para enviar no corpo da requisição HTTP.
:param content_type: Tipo do conteúdo enviado em request_data. O valor deste
parâmetro será adicionado no header "Content-Type" da requisição.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
::
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
try:
LOG.debug('PUT %s\n%s', url, request_data)
parsed_url = urlparse(url)
if parsed_url.scheme == 'https':
connection = HTTPSConnection(
parsed_url.hostname,
parsed_url.port)
else:
connection = HTTPConnection(
parsed_url.hostname,
parsed_url.port)
try:
headers_map = dict()
if auth_map is not None:
headers_map.update(auth_map)
if content_type is not None:
headers_map['Content-Type'] = content_type
connection.request(
'PUT',
parsed_url.path,
request_data,
headers_map)
response = connection.getresponse()
body = response.read()
LOG.debug('PUT %s returns %s\n%s', url, response.status, body)
return response.status, body
finally:
connection.close()
except URLError as e:
raise ConnectionError(e)
except Exception as e:
raise RestError(e, e.message) | python | def put(self, url, request_data, content_type=None, auth_map=None):
"""Envia uma requisição PUT para a URL informada.
Se auth_map é diferente de None, então deverá conter as
chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar
a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
:param url: URL para enviar a requisição HTTP.
:param request_data: Descrição para enviar no corpo da requisição HTTP.
:param content_type: Tipo do conteúdo enviado em request_data. O valor deste
parâmetro será adicionado no header "Content-Type" da requisição.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
::
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
try:
LOG.debug('PUT %s\n%s', url, request_data)
parsed_url = urlparse(url)
if parsed_url.scheme == 'https':
connection = HTTPSConnection(
parsed_url.hostname,
parsed_url.port)
else:
connection = HTTPConnection(
parsed_url.hostname,
parsed_url.port)
try:
headers_map = dict()
if auth_map is not None:
headers_map.update(auth_map)
if content_type is not None:
headers_map['Content-Type'] = content_type
connection.request(
'PUT',
parsed_url.path,
request_data,
headers_map)
response = connection.getresponse()
body = response.read()
LOG.debug('PUT %s returns %s\n%s', url, response.status, body)
return response.status, body
finally:
connection.close()
except URLError as e:
raise ConnectionError(e)
except Exception as e:
raise RestError(e, e.message) | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"request_data",
",",
"content_type",
"=",
"None",
",",
"auth_map",
"=",
"None",
")",
":",
"try",
":",
"LOG",
".",
"debug",
"(",
"'PUT %s\\n%s'",
",",
"url",
",",
"request_data",
")",
"parsed_url",
"=",
"urlparse",
"(",
"url",
")",
"if",
"parsed_url",
".",
"scheme",
"==",
"'https'",
":",
"connection",
"=",
"HTTPSConnection",
"(",
"parsed_url",
".",
"hostname",
",",
"parsed_url",
".",
"port",
")",
"else",
":",
"connection",
"=",
"HTTPConnection",
"(",
"parsed_url",
".",
"hostname",
",",
"parsed_url",
".",
"port",
")",
"try",
":",
"headers_map",
"=",
"dict",
"(",
")",
"if",
"auth_map",
"is",
"not",
"None",
":",
"headers_map",
".",
"update",
"(",
"auth_map",
")",
"if",
"content_type",
"is",
"not",
"None",
":",
"headers_map",
"[",
"'Content-Type'",
"]",
"=",
"content_type",
"connection",
".",
"request",
"(",
"'PUT'",
",",
"parsed_url",
".",
"path",
",",
"request_data",
",",
"headers_map",
")",
"response",
"=",
"connection",
".",
"getresponse",
"(",
")",
"body",
"=",
"response",
".",
"read",
"(",
")",
"LOG",
".",
"debug",
"(",
"'PUT %s returns %s\\n%s'",
",",
"url",
",",
"response",
".",
"status",
",",
"body",
")",
"return",
"response",
".",
"status",
",",
"body",
"finally",
":",
"connection",
".",
"close",
"(",
")",
"except",
"URLError",
"as",
"e",
":",
"raise",
"ConnectionError",
"(",
"e",
")",
"except",
"Exception",
"as",
"e",
":",
"raise",
"RestError",
"(",
"e",
",",
"e",
".",
"message",
")"
] | Envia uma requisição PUT para a URL informada.
Se auth_map é diferente de None, então deverá conter as
chaves NETWORKAPI_PASSWORD e NETWORKAPI_USERNAME para realizar
a autenticação na networkAPI.
As chaves e os seus valores são enviados no header da requisição.
:param url: URL para enviar a requisição HTTP.
:param request_data: Descrição para enviar no corpo da requisição HTTP.
:param content_type: Tipo do conteúdo enviado em request_data. O valor deste
parâmetro será adicionado no header "Content-Type" da requisição.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
::
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI. | [
"Envia",
"uma",
"requisição",
"PUT",
"para",
"a",
"URL",
"informada",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L235-L294 |
globocom/GloboNetworkAPI-client-python | networkapiclient/rest.py | Rest.post_map | def post_map(self, url, map, auth_map=None):
"""Gera um XML a partir dos dados do dicionário e o envia através de uma requisição POST.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
xml = dumps_networkapi(map)
response_code, content = self.post(url, xml, 'text/plain', auth_map)
return response_code, content | python | def post_map(self, url, map, auth_map=None):
"""Gera um XML a partir dos dados do dicionário e o envia através de uma requisição POST.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
xml = dumps_networkapi(map)
response_code, content = self.post(url, xml, 'text/plain', auth_map)
return response_code, content | [
"def",
"post_map",
"(",
"self",
",",
"url",
",",
"map",
",",
"auth_map",
"=",
"None",
")",
":",
"xml",
"=",
"dumps_networkapi",
"(",
"map",
")",
"response_code",
",",
"content",
"=",
"self",
".",
"post",
"(",
"url",
",",
"xml",
",",
"'text/plain'",
",",
"auth_map",
")",
"return",
"response_code",
",",
"content"
] | Gera um XML a partir dos dados do dicionário e o envia através de uma requisição POST.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI. | [
"Gera",
"um",
"XML",
"a",
"partir",
"dos",
"dados",
"do",
"dicionário",
"e",
"o",
"envia",
"através",
"de",
"uma",
"requisição",
"POST",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L296-L311 |
globocom/GloboNetworkAPI-client-python | networkapiclient/rest.py | Rest.put_map | def put_map(self, url, map, auth_map=None):
"""Gera um XML a partir dos dados do dicionário e o envia através de uma requisição PUT.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http>, < corpo da resposta>).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
xml = dumps_networkapi(map)
response_code, content = self.put(url, xml, 'text/plain', auth_map)
return response_code, content | python | def put_map(self, url, map, auth_map=None):
"""Gera um XML a partir dos dados do dicionário e o envia através de uma requisição PUT.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http>, < corpo da resposta>).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
xml = dumps_networkapi(map)
response_code, content = self.put(url, xml, 'text/plain', auth_map)
return response_code, content | [
"def",
"put_map",
"(",
"self",
",",
"url",
",",
"map",
",",
"auth_map",
"=",
"None",
")",
":",
"xml",
"=",
"dumps_networkapi",
"(",
"map",
")",
"response_code",
",",
"content",
"=",
"self",
".",
"put",
"(",
"url",
",",
"xml",
",",
"'text/plain'",
",",
"auth_map",
")",
"return",
"response_code",
",",
"content"
] | Gera um XML a partir dos dados do dicionário e o envia através de uma requisição PUT.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http>, < corpo da resposta>).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI. | [
"Gera",
"um",
"XML",
"a",
"partir",
"dos",
"dados",
"do",
"dicionário",
"e",
"o",
"envia",
"através",
"de",
"uma",
"requisição",
"PUT",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L313-L328 |
globocom/GloboNetworkAPI-client-python | networkapiclient/rest.py | Rest.get_map | def get_map(self, url, auth_map=None):
"""Envia uma requisição GET.
:param url: URL para enviar a requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
response_code, content = self.get(url, auth_map)
return response_code, content | python | def get_map(self, url, auth_map=None):
"""Envia uma requisição GET.
:param url: URL para enviar a requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
response_code, content = self.get(url, auth_map)
return response_code, content | [
"def",
"get_map",
"(",
"self",
",",
"url",
",",
"auth_map",
"=",
"None",
")",
":",
"response_code",
",",
"content",
"=",
"self",
".",
"get",
"(",
"url",
",",
"auth_map",
")",
"return",
"response_code",
",",
"content"
] | Envia uma requisição GET.
:param url: URL para enviar a requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI. | [
"Envia",
"uma",
"requisição",
"GET",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L330-L343 |
globocom/GloboNetworkAPI-client-python | networkapiclient/rest.py | Rest.delete_map | def delete_map(self, url, map=None, auth_map=None):
"""Gera um XML a partir dos dados do dicionário e o envia através de uma requisição DELETE.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
xml = None
if map is not None:
xml = dumps_networkapi(map)
response_code, content = self.delete(url, xml, 'text/plain', auth_map)
return response_code, content | python | def delete_map(self, url, map=None, auth_map=None):
"""Gera um XML a partir dos dados do dicionário e o envia através de uma requisição DELETE.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
"""
xml = None
if map is not None:
xml = dumps_networkapi(map)
response_code, content = self.delete(url, xml, 'text/plain', auth_map)
return response_code, content | [
"def",
"delete_map",
"(",
"self",
",",
"url",
",",
"map",
"=",
"None",
",",
"auth_map",
"=",
"None",
")",
":",
"xml",
"=",
"None",
"if",
"map",
"is",
"not",
"None",
":",
"xml",
"=",
"dumps_networkapi",
"(",
"map",
")",
"response_code",
",",
"content",
"=",
"self",
".",
"delete",
"(",
"url",
",",
"xml",
",",
"'text/plain'",
",",
"auth_map",
")",
"return",
"response_code",
",",
"content"
] | Gera um XML a partir dos dados do dicionário e o envia através de uma requisição DELETE.
:param url: URL para enviar a requisição HTTP.
:param map: Dicionário com os dados do corpo da requisição HTTP.
:param auth_map: Dicionário com as informações para autenticação na networkAPI.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI. | [
"Gera",
"um",
"XML",
"a",
"partir",
"dos",
"dados",
"do",
"dicionário",
"e",
"o",
"envia",
"através",
"de",
"uma",
"requisição",
"DELETE",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L345-L362 |
globocom/GloboNetworkAPI-client-python | networkapiclient/rest.py | Rest.get_full_url | def get_full_url(self, parsed_url):
""" Returns url path with querystring """
full_path = parsed_url.path
if parsed_url.query:
full_path = '%s?%s' % (full_path, parsed_url.query)
return full_path | python | def get_full_url(self, parsed_url):
""" Returns url path with querystring """
full_path = parsed_url.path
if parsed_url.query:
full_path = '%s?%s' % (full_path, parsed_url.query)
return full_path | [
"def",
"get_full_url",
"(",
"self",
",",
"parsed_url",
")",
":",
"full_path",
"=",
"parsed_url",
".",
"path",
"if",
"parsed_url",
".",
"query",
":",
"full_path",
"=",
"'%s?%s'",
"%",
"(",
"full_path",
",",
"parsed_url",
".",
"query",
")",
"return",
"full_path"
] | Returns url path with querystring | [
"Returns",
"url",
"path",
"with",
"querystring"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L371-L376 |
globocom/GloboNetworkAPI-client-python | networkapiclient/rest.py | RestRequest.submit | def submit(self, map):
'''Envia a requisição HTTP de acordo com os parâmetros informados no construtor.
:param map: Dicionário com os dados do corpo da requisição.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
'''
# print "Requição em %s %s com corpo: %s" % (self.method, self.url,
# map)
rest = Rest()
if self.method == 'POST':
code, response = rest.post_map(self.url, map, self.auth_map)
elif self.method == 'PUT':
code, response = rest.put_map(self.url, map, self.auth_map)
elif self.method == 'GET':
code, response = rest.get_map(self.url, self.auth_map)
elif self.method == 'DELETE':
code, response = rest.delete_map(self.url, map, self.auth_map)
return code, response | python | def submit(self, map):
'''Envia a requisição HTTP de acordo com os parâmetros informados no construtor.
:param map: Dicionário com os dados do corpo da requisição.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI.
'''
# print "Requição em %s %s com corpo: %s" % (self.method, self.url,
# map)
rest = Rest()
if self.method == 'POST':
code, response = rest.post_map(self.url, map, self.auth_map)
elif self.method == 'PUT':
code, response = rest.put_map(self.url, map, self.auth_map)
elif self.method == 'GET':
code, response = rest.get_map(self.url, self.auth_map)
elif self.method == 'DELETE':
code, response = rest.delete_map(self.url, map, self.auth_map)
return code, response | [
"def",
"submit",
"(",
"self",
",",
"map",
")",
":",
"# print \"Requição em %s %s com corpo: %s\" % (self.method, self.url,",
"# map)",
"rest",
"=",
"Rest",
"(",
")",
"if",
"self",
".",
"method",
"==",
"'POST'",
":",
"code",
",",
"response",
"=",
"rest",
".",
"post_map",
"(",
"self",
".",
"url",
",",
"map",
",",
"self",
".",
"auth_map",
")",
"elif",
"self",
".",
"method",
"==",
"'PUT'",
":",
"code",
",",
"response",
"=",
"rest",
".",
"put_map",
"(",
"self",
".",
"url",
",",
"map",
",",
"self",
".",
"auth_map",
")",
"elif",
"self",
".",
"method",
"==",
"'GET'",
":",
"code",
",",
"response",
"=",
"rest",
".",
"get_map",
"(",
"self",
".",
"url",
",",
"self",
".",
"auth_map",
")",
"elif",
"self",
".",
"method",
"==",
"'DELETE'",
":",
"code",
",",
"response",
"=",
"rest",
".",
"delete_map",
"(",
"self",
".",
"url",
",",
"map",
",",
"self",
".",
"auth_map",
")",
"return",
"code",
",",
"response"
] | Envia a requisição HTTP de acordo com os parâmetros informados no construtor.
:param map: Dicionário com os dados do corpo da requisição.
:return: Retorna uma tupla contendo:
(< código de resposta http >, < corpo da resposta >).
:raise ConnectionError: Falha na conexão com a networkAPI.
:raise RestError: Falha no acesso à networkAPI. | [
"Envia",
"a",
"requisição",
"HTTP",
"de",
"acordo",
"com",
"os",
"parâmetros",
"informados",
"no",
"construtor",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/rest.py#L400-L423 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4VirtualInterface.py | ApiV4VirtualInterface.search | def search(self, **kwargs):
"""
Method to search Virtual Interfaces based on extends search.
:param search: Dict containing QuerySets to find Virtual Interfaces.
: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 Virtual Interfaces
"""
return super(ApiV4VirtualInterface, self).get(self.prepare_url(
'api/v4/virtual-interface/', kwargs)) | python | def search(self, **kwargs):
"""
Method to search Virtual Interfaces based on extends search.
:param search: Dict containing QuerySets to find Virtual Interfaces.
: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 Virtual Interfaces
"""
return super(ApiV4VirtualInterface, self).get(self.prepare_url(
'api/v4/virtual-interface/', kwargs)) | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"ApiV4VirtualInterface",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"'api/v4/virtual-interface/'",
",",
"kwargs",
")",
")"
] | Method to search Virtual Interfaces based on extends search.
:param search: Dict containing QuerySets to find Virtual Interfaces.
: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 Virtual Interfaces | [
"Method",
"to",
"search",
"Virtual",
"Interfaces",
"based",
"on",
"extends",
"search",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4VirtualInterface.py#L36-L49 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4VirtualInterface.py | ApiV4VirtualInterface.delete | def delete(self, ids):
"""
Method to delete Virtual Interfaces by their id's
:param ids: Identifiers of Virtual Interfaces
:return: None
"""
url = build_uri_with_ids('api/v4/virtual-interface/%s/', ids)
return super(ApiV4VirtualInterface, self).delete(url) | python | def delete(self, ids):
"""
Method to delete Virtual Interfaces by their id's
:param ids: Identifiers of Virtual Interfaces
:return: None
"""
url = build_uri_with_ids('api/v4/virtual-interface/%s/', ids)
return super(ApiV4VirtualInterface, self).delete(url) | [
"def",
"delete",
"(",
"self",
",",
"ids",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v4/virtual-interface/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiV4VirtualInterface",
",",
"self",
")",
".",
"delete",
"(",
"url",
")"
] | Method to delete Virtual Interfaces by their id's
:param ids: Identifiers of Virtual Interfaces
:return: None | [
"Method",
"to",
"delete",
"Virtual",
"Interfaces",
"by",
"their",
"id",
"s"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4VirtualInterface.py#L65-L73 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4VirtualInterface.py | ApiV4VirtualInterface.update | def update(self, virtual_interfaces):
"""
Method to update Virtual Interfaces
:param Virtual Interfaces: List containing Virtual Interfaces desired to updated
:return: None
"""
data = {'virtual_interfaces': virtual_interfaces}
virtual_interfaces_ids = [str(env.get('id')) for env in virtual_interfaces]
return super(ApiV4VirtualInterface, self).put\
('api/v4/virtual-interface/%s/' % ';'.join(virtual_interfaces_ids), data) | python | def update(self, virtual_interfaces):
"""
Method to update Virtual Interfaces
:param Virtual Interfaces: List containing Virtual Interfaces desired to updated
:return: None
"""
data = {'virtual_interfaces': virtual_interfaces}
virtual_interfaces_ids = [str(env.get('id')) for env in virtual_interfaces]
return super(ApiV4VirtualInterface, self).put\
('api/v4/virtual-interface/%s/' % ';'.join(virtual_interfaces_ids), data) | [
"def",
"update",
"(",
"self",
",",
"virtual_interfaces",
")",
":",
"data",
"=",
"{",
"'virtual_interfaces'",
":",
"virtual_interfaces",
"}",
"virtual_interfaces_ids",
"=",
"[",
"str",
"(",
"env",
".",
"get",
"(",
"'id'",
")",
")",
"for",
"env",
"in",
"virtual_interfaces",
"]",
"return",
"super",
"(",
"ApiV4VirtualInterface",
",",
"self",
")",
".",
"put",
"(",
"'api/v4/virtual-interface/%s/'",
"%",
"';'",
".",
"join",
"(",
"virtual_interfaces_ids",
")",
",",
"data",
")"
] | Method to update Virtual Interfaces
:param Virtual Interfaces: List containing Virtual Interfaces desired to updated
:return: None | [
"Method",
"to",
"update",
"Virtual",
"Interfaces"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4VirtualInterface.py#L75-L87 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4VirtualInterface.py | ApiV4VirtualInterface.create | def create(self, virtual_interfaces):
"""
Method to create Virtual Interfaces
:param Virtual Interfaces: List containing Virtual Interfaces desired to be created on database
:return: None
"""
data = {'virtual_interfaces': virtual_interfaces}
return super(ApiV4VirtualInterface, self).post\
('api/v4/virtual-interface/', data) | python | def create(self, virtual_interfaces):
"""
Method to create Virtual Interfaces
:param Virtual Interfaces: List containing Virtual Interfaces desired to be created on database
:return: None
"""
data = {'virtual_interfaces': virtual_interfaces}
return super(ApiV4VirtualInterface, self).post\
('api/v4/virtual-interface/', data) | [
"def",
"create",
"(",
"self",
",",
"virtual_interfaces",
")",
":",
"data",
"=",
"{",
"'virtual_interfaces'",
":",
"virtual_interfaces",
"}",
"return",
"super",
"(",
"ApiV4VirtualInterface",
",",
"self",
")",
".",
"post",
"(",
"'api/v4/virtual-interface/'",
",",
"data",
")"
] | Method to create Virtual Interfaces
:param Virtual Interfaces: List containing Virtual Interfaces desired to be created on database
:return: None | [
"Method",
"to",
"create",
"Virtual",
"Interfaces"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4VirtualInterface.py#L89-L99 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GrupoUsuario.py | GrupoUsuario.search | def search(self, id_ugroup):
"""Search Group User by its identifier.
:param id_ugroup: Identifier of the Group User. Integer value and greater than zero.
:return: Following dictionary:
::
{‘user_group’: {'escrita': < escrita >,
'nome': < nome >,
'exclusao': < exclusao >,
'edicao': < edicao >,
'id': < id >,
'leitura': < leitura >}}
:raise InvalidParameterError: Group User identifier is none or invalid.
:raise GrupoUsuarioNaoExisteError: Group 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_ugroup):
raise InvalidParameterError(
u'The identifier of Group User is invalid or was not informed.')
url = 'ugroup/get/' + str(id_ugroup) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | python | def search(self, id_ugroup):
"""Search Group User by its identifier.
:param id_ugroup: Identifier of the Group User. Integer value and greater than zero.
:return: Following dictionary:
::
{‘user_group’: {'escrita': < escrita >,
'nome': < nome >,
'exclusao': < exclusao >,
'edicao': < edicao >,
'id': < id >,
'leitura': < leitura >}}
:raise InvalidParameterError: Group User identifier is none or invalid.
:raise GrupoUsuarioNaoExisteError: Group 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_ugroup):
raise InvalidParameterError(
u'The identifier of Group User is invalid or was not informed.')
url = 'ugroup/get/' + str(id_ugroup) + '/'
code, xml = self.submit(None, 'GET', url)
return self.response(code, xml) | [
"def",
"search",
"(",
"self",
",",
"id_ugroup",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_ugroup",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'The identifier of Group User is invalid or was not informed.'",
")",
"url",
"=",
"'ugroup/get/'",
"+",
"str",
"(",
"id_ugroup",
")",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'GET'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Search Group User by its identifier.
:param id_ugroup: Identifier of the Group User. Integer value and greater than zero.
:return: Following dictionary:
::
{‘user_group’: {'escrita': < escrita >,
'nome': < nome >,
'exclusao': < exclusao >,
'edicao': < edicao >,
'id': < id >,
'leitura': < leitura >}}
:raise InvalidParameterError: Group User identifier is none or invalid.
:raise GrupoUsuarioNaoExisteError: Group User not registered.
:raise DataBaseError: Networkapi failed to access the database.
:raise XMLError: Networkapi failed to generate the XML response. | [
"Search",
"Group",
"User",
"by",
"its",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GrupoUsuario.py#L38-L68 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GrupoUsuario.py | GrupoUsuario.inserir | def inserir(self, name, read, write, edit, remove):
"""Insert new user group and returns its identifier.
:param name: User group's name.
:param read: If user group has read permission ('S' ou 'N').
:param write: If user group has write permission ('S' ou 'N').
:param edit: If user group has edit permission ('S' ou 'N').
:param remove: If user group has remove permission ('S' ou 'N').
:return: Dictionary with structure: {'user_group': {'id': < id >}}
:raise InvalidParameterError: At least one of the parameters is invalid or none..
:raise NomeGrupoUsuarioDuplicadoError: User group name already exists.
:raise ValorIndicacaoPermissaoInvalidoError: Read, write, edit or remove value is invalid.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML.
"""
ugroup_map = dict()
ugroup_map['nome'] = name
ugroup_map['leitura'] = read
ugroup_map['escrita'] = write
ugroup_map['edicao'] = edit
ugroup_map['exclusao'] = remove
code, xml = self.submit({'user_group': ugroup_map}, 'POST', 'ugroup/')
return self.response(code, xml) | python | def inserir(self, name, read, write, edit, remove):
"""Insert new user group and returns its identifier.
:param name: User group's name.
:param read: If user group has read permission ('S' ou 'N').
:param write: If user group has write permission ('S' ou 'N').
:param edit: If user group has edit permission ('S' ou 'N').
:param remove: If user group has remove permission ('S' ou 'N').
:return: Dictionary with structure: {'user_group': {'id': < id >}}
:raise InvalidParameterError: At least one of the parameters is invalid or none..
:raise NomeGrupoUsuarioDuplicadoError: User group name already exists.
:raise ValorIndicacaoPermissaoInvalidoError: Read, write, edit or remove value is invalid.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML.
"""
ugroup_map = dict()
ugroup_map['nome'] = name
ugroup_map['leitura'] = read
ugroup_map['escrita'] = write
ugroup_map['edicao'] = edit
ugroup_map['exclusao'] = remove
code, xml = self.submit({'user_group': ugroup_map}, 'POST', 'ugroup/')
return self.response(code, xml) | [
"def",
"inserir",
"(",
"self",
",",
"name",
",",
"read",
",",
"write",
",",
"edit",
",",
"remove",
")",
":",
"ugroup_map",
"=",
"dict",
"(",
")",
"ugroup_map",
"[",
"'nome'",
"]",
"=",
"name",
"ugroup_map",
"[",
"'leitura'",
"]",
"=",
"read",
"ugroup_map",
"[",
"'escrita'",
"]",
"=",
"write",
"ugroup_map",
"[",
"'edicao'",
"]",
"=",
"edit",
"ugroup_map",
"[",
"'exclusao'",
"]",
"=",
"remove",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'user_group'",
":",
"ugroup_map",
"}",
",",
"'POST'",
",",
"'ugroup/'",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Insert new user group and returns its identifier.
:param name: User group's name.
:param read: If user group has read permission ('S' ou 'N').
:param write: If user group has write permission ('S' ou 'N').
:param edit: If user group has edit permission ('S' ou 'N').
:param remove: If user group has remove permission ('S' ou 'N').
:return: Dictionary with structure: {'user_group': {'id': < id >}}
:raise InvalidParameterError: At least one of the parameters is invalid or none..
:raise NomeGrupoUsuarioDuplicadoError: User group name already exists.
:raise ValorIndicacaoPermissaoInvalidoError: Read, write, edit or remove value is invalid.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML. | [
"Insert",
"new",
"user",
"group",
"and",
"returns",
"its",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GrupoUsuario.py#L93-L119 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GrupoUsuario.py | GrupoUsuario.alterar | def alterar(self, id_user_group, name, read, write, edit, remove):
"""Edit user group data from its identifier.
:param id_user_group: User group id.
:param name: User group name.
:param read: If user group has read permission ('S' ou 'N').
:param write: If user group has write permission ('S' ou 'N').
:param edit: If user group has edit permission ('S' ou 'N').
:param remove: If user group has remove permission ('S' ou 'N').
:return: None
:raise NomeGrupoUsuarioDuplicadoError: User group name already exists.
:raise ValorIndicacaoPermissaoInvalidoError: Read, write, edit or remove value is invalid.
:raise GrupoUsuarioNaoExisteError: User Group not found.
:raise InvalidParameterError: At least one of the parameters is invalid or none.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML.
"""
if not is_valid_int_param(id_user_group):
raise InvalidParameterError(
u'Invalid or inexistent user group id.')
url = 'ugroup/' + str(id_user_group) + '/'
ugroup_map = dict()
ugroup_map['nome'] = name
ugroup_map['leitura'] = read
ugroup_map['escrita'] = write
ugroup_map['edicao'] = edit
ugroup_map['exclusao'] = remove
code, xml = self.submit({'user_group': ugroup_map}, 'PUT', url)
return self.response(code, xml) | python | def alterar(self, id_user_group, name, read, write, edit, remove):
"""Edit user group data from its identifier.
:param id_user_group: User group id.
:param name: User group name.
:param read: If user group has read permission ('S' ou 'N').
:param write: If user group has write permission ('S' ou 'N').
:param edit: If user group has edit permission ('S' ou 'N').
:param remove: If user group has remove permission ('S' ou 'N').
:return: None
:raise NomeGrupoUsuarioDuplicadoError: User group name already exists.
:raise ValorIndicacaoPermissaoInvalidoError: Read, write, edit or remove value is invalid.
:raise GrupoUsuarioNaoExisteError: User Group not found.
:raise InvalidParameterError: At least one of the parameters is invalid or none.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML.
"""
if not is_valid_int_param(id_user_group):
raise InvalidParameterError(
u'Invalid or inexistent user group id.')
url = 'ugroup/' + str(id_user_group) + '/'
ugroup_map = dict()
ugroup_map['nome'] = name
ugroup_map['leitura'] = read
ugroup_map['escrita'] = write
ugroup_map['edicao'] = edit
ugroup_map['exclusao'] = remove
code, xml = self.submit({'user_group': ugroup_map}, 'PUT', url)
return self.response(code, xml) | [
"def",
"alterar",
"(",
"self",
",",
"id_user_group",
",",
"name",
",",
"read",
",",
"write",
",",
"edit",
",",
"remove",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_user_group",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Invalid or inexistent user group id.'",
")",
"url",
"=",
"'ugroup/'",
"+",
"str",
"(",
"id_user_group",
")",
"+",
"'/'",
"ugroup_map",
"=",
"dict",
"(",
")",
"ugroup_map",
"[",
"'nome'",
"]",
"=",
"name",
"ugroup_map",
"[",
"'leitura'",
"]",
"=",
"read",
"ugroup_map",
"[",
"'escrita'",
"]",
"=",
"write",
"ugroup_map",
"[",
"'edicao'",
"]",
"=",
"edit",
"ugroup_map",
"[",
"'exclusao'",
"]",
"=",
"remove",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'user_group'",
":",
"ugroup_map",
"}",
",",
"'PUT'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Edit user group data from its identifier.
:param id_user_group: User group id.
:param name: User group name.
:param read: If user group has read permission ('S' ou 'N').
:param write: If user group has write permission ('S' ou 'N').
:param edit: If user group has edit permission ('S' ou 'N').
:param remove: If user group has remove permission ('S' ou 'N').
:return: None
:raise NomeGrupoUsuarioDuplicadoError: User group name already exists.
:raise ValorIndicacaoPermissaoInvalidoError: Read, write, edit or remove value is invalid.
:raise GrupoUsuarioNaoExisteError: User Group not found.
:raise InvalidParameterError: At least one of the parameters is invalid or none.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML. | [
"Edit",
"user",
"group",
"data",
"from",
"its",
"identifier",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GrupoUsuario.py#L121-L155 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GrupoUsuario.py | GrupoUsuario.remover | def remover(self, id_user_group):
"""Removes a user group by its id.
:param id_user_group: User Group's identifier. Valid integer greater than zero.
:return: None
:raise GrupoUsuarioNaoExisteError: User Group not found.
:raise InvalidParameterError: User Group id is invalid or none.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML.
"""
if not is_valid_int_param(id_user_group):
raise InvalidParameterError(
u'Invalid or inexistent user group id.')
url = 'ugroup/' + str(id_user_group) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | python | def remover(self, id_user_group):
"""Removes a user group by its id.
:param id_user_group: User Group's identifier. Valid integer greater than zero.
:return: None
:raise GrupoUsuarioNaoExisteError: User Group not found.
:raise InvalidParameterError: User Group id is invalid or none.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML.
"""
if not is_valid_int_param(id_user_group):
raise InvalidParameterError(
u'Invalid or inexistent user group id.')
url = 'ugroup/' + str(id_user_group) + '/'
code, xml = self.submit(None, 'DELETE', url)
return self.response(code, xml) | [
"def",
"remover",
"(",
"self",
",",
"id_user_group",
")",
":",
"if",
"not",
"is_valid_int_param",
"(",
"id_user_group",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u'Invalid or inexistent user group id.'",
")",
"url",
"=",
"'ugroup/'",
"+",
"str",
"(",
"id_user_group",
")",
"+",
"'/'",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"None",
",",
"'DELETE'",
",",
"url",
")",
"return",
"self",
".",
"response",
"(",
"code",
",",
"xml",
")"
] | Removes a user group by its id.
:param id_user_group: User Group's identifier. Valid integer greater than zero.
:return: None
:raise GrupoUsuarioNaoExisteError: User Group not found.
:raise InvalidParameterError: User Group id is invalid or none.
:raise DataBaseError: Networkapi failed to access database.
:raise XMLError: Networkapi fails generating response XML. | [
"Removes",
"a",
"user",
"group",
"by",
"its",
"id",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GrupoUsuario.py#L157-L177 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiEnvironment.py | ApiEnvironment.get_environment | def get_environment(self, environment_ids):
"""
Method to get environment
"""
uri = 'api/v3/environment/%s/' % environment_ids
return super(ApiEnvironment, self).get(uri) | python | def get_environment(self, environment_ids):
"""
Method to get environment
"""
uri = 'api/v3/environment/%s/' % environment_ids
return super(ApiEnvironment, self).get(uri) | [
"def",
"get_environment",
"(",
"self",
",",
"environment_ids",
")",
":",
"uri",
"=",
"'api/v3/environment/%s/'",
"%",
"environment_ids",
"return",
"super",
"(",
"ApiEnvironment",
",",
"self",
")",
".",
"get",
"(",
"uri",
")"
] | Method to get environment | [
"Method",
"to",
"get",
"environment"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEnvironment.py#L45-L52 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiEnvironment.py | ApiEnvironment.create_environment | 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) | python | 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) | [
"def",
"create_environment",
"(",
"self",
",",
"environment",
")",
":",
"uri",
"=",
"'api/v3/environment/'",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"'environments'",
"]",
"=",
"list",
"(",
")",
"data",
"[",
"'environments'",
"]",
".",
"append",
"(",
"environment",
")",
"return",
"super",
"(",
"ApiEnvironment",
",",
"self",
")",
".",
"post",
"(",
"uri",
",",
"data",
")"
] | Method to create environment | [
"Method",
"to",
"create",
"environment"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEnvironment.py#L54-L65 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiEnvironment.py | ApiEnvironment.update_environment | 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) | python | 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) | [
"def",
"update_environment",
"(",
"self",
",",
"environment",
",",
"environment_ids",
")",
":",
"uri",
"=",
"'api/v3/environment/%s/'",
"%",
"environment_ids",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"'environments'",
"]",
"=",
"list",
"(",
")",
"data",
"[",
"'environments'",
"]",
".",
"append",
"(",
"environment",
")",
"return",
"super",
"(",
"ApiEnvironment",
",",
"self",
")",
".",
"put",
"(",
"uri",
",",
"data",
")"
] | Method to update environment
:param environment_ids: Ids of Environment | [
"Method",
"to",
"update",
"environment"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEnvironment.py#L67-L80 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiEnvironment.py | ApiEnvironment.delete_environment | 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) | python | 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) | [
"def",
"delete_environment",
"(",
"self",
",",
"environment_ids",
")",
":",
"uri",
"=",
"'api/v3/environment/%s/'",
"%",
"environment_ids",
"return",
"super",
"(",
"ApiEnvironment",
",",
"self",
")",
".",
"delete",
"(",
"uri",
")"
] | Method to delete environment
:param environment_ids: Ids of Environment | [
"Method",
"to",
"delete",
"environment"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEnvironment.py#L82-L90 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiEnvironment.py | ApiEnvironment.search | 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)) | python | 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)) | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"ApiEnvironment",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"'api/v3/environment/'",
",",
"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 | [
"Method",
"to",
"search",
"environments",
"based",
"on",
"extends",
"search",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEnvironment.py#L92-L105 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiEnvironment.py | ApiEnvironment.delete | 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) | python | 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) | [
"def",
"delete",
"(",
"self",
",",
"ids",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v3/environment/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiEnvironment",
",",
"self",
")",
".",
"delete",
"(",
"url",
")"
] | Method to delete environments by their id's
:param ids: Identifiers of environments
:return: None | [
"Method",
"to",
"delete",
"environments",
"by",
"their",
"id",
"s"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEnvironment.py#L121-L129 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiEnvironment.py | ApiEnvironment.update | 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) | python | 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) | [
"def",
"update",
"(",
"self",
",",
"environments",
")",
":",
"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",
")"
] | Method to update environments
:param environments: List containing environments desired to updated
:return: None | [
"Method",
"to",
"update",
"environments"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEnvironment.py#L131-L143 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiEnvironment.py | ApiEnvironment.create | 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) | python | 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) | [
"def",
"create",
"(",
"self",
",",
"environments",
")",
":",
"data",
"=",
"{",
"'environments'",
":",
"environments",
"}",
"return",
"super",
"(",
"ApiEnvironment",
",",
"self",
")",
".",
"post",
"(",
"'api/v3/environment/'",
",",
"data",
")"
] | Method to create environments
:param environments: Dict containing environments desired to be created on database
:return: None | [
"Method",
"to",
"create",
"environments"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiEnvironment.py#L145-L154 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4As.py | ApiV4As.search | 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)) | python | 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)) | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"ApiV4As",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"'api/v4/as/'",
",",
"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 | [
"Method",
"to",
"search",
"asns",
"based",
"on",
"extends",
"search",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4As.py#L36-L49 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4As.py | ApiV4As.delete | 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) | python | 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) | [
"def",
"delete",
"(",
"self",
",",
"ids",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v4/as/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiV4As",
",",
"self",
")",
".",
"delete",
"(",
"url",
")"
] | Method to delete asns by their id's
:param ids: Identifiers of asns
:return: None | [
"Method",
"to",
"delete",
"asns",
"by",
"their",
"id",
"s"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4As.py#L65-L73 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4As.py | ApiV4As.update | 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) | python | 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) | [
"def",
"update",
"(",
"self",
",",
"asns",
")",
":",
"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",
")"
] | Method to update asns
:param asns: List containing asns desired to updated
:return: None | [
"Method",
"to",
"update",
"asns"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4As.py#L75-L87 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4As.py | ApiV4As.create | 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) | python | 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) | [
"def",
"create",
"(",
"self",
",",
"asns",
")",
":",
"data",
"=",
"{",
"'asns'",
":",
"asns",
"}",
"return",
"super",
"(",
"ApiV4As",
",",
"self",
")",
".",
"post",
"(",
"'api/v4/as/'",
",",
"data",
")"
] | Method to create asns
:param asns: List containing asns desired to be created on database
:return: None | [
"Method",
"to",
"create",
"asns"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4As.py#L89-L98 |
globocom/GloboNetworkAPI-client-python | networkapiclient/EventLog.py | EventLog.find_logs | def find_logs(
self,
user_name,
first_date,
start_time,
last_date,
end_time,
action,
functionality,
parameter,
pagination):
"""
Search all logs, filtering by the given parameters.
:param user_name: Filter by user_name
:param first_date: Sets initial date for begin of the filter
:param start_time: Sets initial time
:param last_date: Sets final date
:param end_time: Sets final time and ends the filter. That defines the searching gap
:param action: Filter by action (Create, Update or Delete)
:param functionality: Filter by class
:param parameter: Filter by parameter
:param pagination: Class with all data needed to paginate
:return: Following dictionary:
::
{'eventlog': {'id_usuario' : < id_user >,
'hora_evento': < hora_evento >,
'acao': < acao >,
'funcionalidade': < funcionalidade >,
'parametro_anterior': < parametro_anterior >,
'parametro_atual': < parametro_atual > }
'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'.")
eventlog_map = dict()
eventlog_map["start_record"] = pagination.start_record
eventlog_map["end_record"] = pagination.end_record
eventlog_map["asorting_cols"] = pagination.asorting_cols
eventlog_map["searchable_columns"] = pagination.searchable_columns
eventlog_map["custom_search"] = pagination.custom_search
eventlog_map["usuario"] = user_name
eventlog_map["data_inicial"] = first_date
eventlog_map["hora_inicial"] = start_time
eventlog_map["data_final"] = last_date
eventlog_map["hora_final"] = end_time
eventlog_map["acao"] = action
eventlog_map["funcionalidade"] = functionality
eventlog_map["parametro"] = parameter
url = "eventlog/find/"
code, xml = self.submit({'eventlog': eventlog_map}, 'POST', url)
key = "eventlog"
return get_list_map(self.response(code, xml, key), key) | python | def find_logs(
self,
user_name,
first_date,
start_time,
last_date,
end_time,
action,
functionality,
parameter,
pagination):
"""
Search all logs, filtering by the given parameters.
:param user_name: Filter by user_name
:param first_date: Sets initial date for begin of the filter
:param start_time: Sets initial time
:param last_date: Sets final date
:param end_time: Sets final time and ends the filter. That defines the searching gap
:param action: Filter by action (Create, Update or Delete)
:param functionality: Filter by class
:param parameter: Filter by parameter
:param pagination: Class with all data needed to paginate
:return: Following dictionary:
::
{'eventlog': {'id_usuario' : < id_user >,
'hora_evento': < hora_evento >,
'acao': < acao >,
'funcionalidade': < funcionalidade >,
'parametro_anterior': < parametro_anterior >,
'parametro_atual': < parametro_atual > }
'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'.")
eventlog_map = dict()
eventlog_map["start_record"] = pagination.start_record
eventlog_map["end_record"] = pagination.end_record
eventlog_map["asorting_cols"] = pagination.asorting_cols
eventlog_map["searchable_columns"] = pagination.searchable_columns
eventlog_map["custom_search"] = pagination.custom_search
eventlog_map["usuario"] = user_name
eventlog_map["data_inicial"] = first_date
eventlog_map["hora_inicial"] = start_time
eventlog_map["data_final"] = last_date
eventlog_map["hora_final"] = end_time
eventlog_map["acao"] = action
eventlog_map["funcionalidade"] = functionality
eventlog_map["parametro"] = parameter
url = "eventlog/find/"
code, xml = self.submit({'eventlog': eventlog_map}, 'POST', url)
key = "eventlog"
return get_list_map(self.response(code, xml, key), key) | [
"def",
"find_logs",
"(",
"self",
",",
"user_name",
",",
"first_date",
",",
"start_time",
",",
"last_date",
",",
"end_time",
",",
"action",
",",
"functionality",
",",
"parameter",
",",
"pagination",
")",
":",
"if",
"not",
"isinstance",
"(",
"pagination",
",",
"Pagination",
")",
":",
"raise",
"InvalidParameterError",
"(",
"u\"Invalid parameter: pagination must be a class of type 'Pagination'.\"",
")",
"eventlog_map",
"=",
"dict",
"(",
")",
"eventlog_map",
"[",
"\"start_record\"",
"]",
"=",
"pagination",
".",
"start_record",
"eventlog_map",
"[",
"\"end_record\"",
"]",
"=",
"pagination",
".",
"end_record",
"eventlog_map",
"[",
"\"asorting_cols\"",
"]",
"=",
"pagination",
".",
"asorting_cols",
"eventlog_map",
"[",
"\"searchable_columns\"",
"]",
"=",
"pagination",
".",
"searchable_columns",
"eventlog_map",
"[",
"\"custom_search\"",
"]",
"=",
"pagination",
".",
"custom_search",
"eventlog_map",
"[",
"\"usuario\"",
"]",
"=",
"user_name",
"eventlog_map",
"[",
"\"data_inicial\"",
"]",
"=",
"first_date",
"eventlog_map",
"[",
"\"hora_inicial\"",
"]",
"=",
"start_time",
"eventlog_map",
"[",
"\"data_final\"",
"]",
"=",
"last_date",
"eventlog_map",
"[",
"\"hora_final\"",
"]",
"=",
"end_time",
"eventlog_map",
"[",
"\"acao\"",
"]",
"=",
"action",
"eventlog_map",
"[",
"\"funcionalidade\"",
"]",
"=",
"functionality",
"eventlog_map",
"[",
"\"parametro\"",
"]",
"=",
"parameter",
"url",
"=",
"\"eventlog/find/\"",
"code",
",",
"xml",
"=",
"self",
".",
"submit",
"(",
"{",
"'eventlog'",
":",
"eventlog_map",
"}",
",",
"'POST'",
",",
"url",
")",
"key",
"=",
"\"eventlog\"",
"return",
"get_list_map",
"(",
"self",
".",
"response",
"(",
"code",
",",
"xml",
",",
"key",
")",
",",
"key",
")"
] | Search all logs, filtering by the given parameters.
:param user_name: Filter by user_name
:param first_date: Sets initial date for begin of the filter
:param start_time: Sets initial time
:param last_date: Sets final date
:param end_time: Sets final time and ends the filter. That defines the searching gap
:param action: Filter by action (Create, Update or Delete)
:param functionality: Filter by class
:param parameter: Filter by parameter
:param pagination: Class with all data needed to paginate
:return: Following dictionary:
::
{'eventlog': {'id_usuario' : < id_user >,
'hora_evento': < hora_evento >,
'acao': < acao >,
'funcionalidade': < funcionalidade >,
'parametro_anterior': < parametro_anterior >,
'parametro_atual': < parametro_atual > }
'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. | [
"Search",
"all",
"logs",
"filtering",
"by",
"the",
"given",
"parameters",
".",
":",
"param",
"user_name",
":",
"Filter",
"by",
"user_name",
":",
"param",
"first_date",
":",
"Sets",
"initial",
"date",
"for",
"begin",
"of",
"the",
"filter",
":",
"param",
"start_time",
":",
"Sets",
"initial",
"time",
":",
"param",
"last_date",
":",
"Sets",
"final",
"date",
":",
"param",
"end_time",
":",
"Sets",
"final",
"time",
"and",
"ends",
"the",
"filter",
".",
"That",
"defines",
"the",
"searching",
"gap",
":",
"param",
"action",
":",
"Filter",
"by",
"action",
"(",
"Create",
"Update",
"or",
"Delete",
")",
":",
"param",
"functionality",
":",
"Filter",
"by",
"class",
":",
"param",
"parameter",
":",
"Filter",
"by",
"parameter",
":",
"param",
"pagination",
":",
"Class",
"with",
"all",
"data",
"needed",
"to",
"paginate"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/EventLog.py#L40-L106 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4Equipment.py | ApiV4Equipment.search | def search(self, **kwargs):
"""
Method to search equipments based on extends search.
:param search: Dict containing QuerySets to find equipments.
:param include: Array containing fields to include on response.
:param exclude: Array containing fields to exclude on response.
:param fields: Array containing fields to override default fields.
:param kind: Determine if result will be detailed ('detail') or basic ('basic').
:return: Dict containing equipments
"""
return super(ApiV4Equipment, self).get(self.prepare_url(
'api/v4/equipment/', kwargs)) | python | def search(self, **kwargs):
"""
Method to search equipments based on extends search.
:param search: Dict containing QuerySets to find equipments.
:param include: Array containing fields to include on response.
:param exclude: Array containing fields to exclude on response.
:param fields: Array containing fields to override default fields.
:param kind: Determine if result will be detailed ('detail') or basic ('basic').
:return: Dict containing equipments
"""
return super(ApiV4Equipment, self).get(self.prepare_url(
'api/v4/equipment/', kwargs)) | [
"def",
"search",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"ApiV4Equipment",
",",
"self",
")",
".",
"get",
"(",
"self",
".",
"prepare_url",
"(",
"'api/v4/equipment/'",
",",
"kwargs",
")",
")"
] | Method to search equipments based on extends search.
:param search: Dict containing QuerySets to find equipments.
:param include: Array containing fields to include on response.
:param exclude: Array containing fields to exclude on response.
:param fields: Array containing fields to override default fields.
:param kind: Determine if result will be detailed ('detail') or basic ('basic').
:return: Dict containing equipments | [
"Method",
"to",
"search",
"equipments",
"based",
"on",
"extends",
"search",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4Equipment.py#L36-L49 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4Equipment.py | ApiV4Equipment.delete | def delete(self, ids):
"""
Method to delete equipments by their id's
:param ids: Identifiers of equipments
:return: None
"""
url = build_uri_with_ids('api/v4/equipment/%s/', ids)
return super(ApiV4Equipment, self).delete(url) | python | def delete(self, ids):
"""
Method to delete equipments by their id's
:param ids: Identifiers of equipments
:return: None
"""
url = build_uri_with_ids('api/v4/equipment/%s/', ids)
return super(ApiV4Equipment, self).delete(url) | [
"def",
"delete",
"(",
"self",
",",
"ids",
")",
":",
"url",
"=",
"build_uri_with_ids",
"(",
"'api/v4/equipment/%s/'",
",",
"ids",
")",
"return",
"super",
"(",
"ApiV4Equipment",
",",
"self",
")",
".",
"delete",
"(",
"url",
")"
] | Method to delete equipments by their id's
:param ids: Identifiers of equipments
:return: None | [
"Method",
"to",
"delete",
"equipments",
"by",
"their",
"id",
"s"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4Equipment.py#L65-L73 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4Equipment.py | ApiV4Equipment.update | 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) | python | 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) | [
"def",
"update",
"(",
"self",
",",
"equipments",
")",
":",
"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",
")"
] | Method to update equipments
:param equipments: List containing equipments desired to updated
:return: None | [
"Method",
"to",
"update",
"equipments"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4Equipment.py#L75-L87 |
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiV4Equipment.py | ApiV4Equipment.create | def create(self, equipments):
"""
Method to create equipments
:param equipments: List containing equipments desired to be created on database
:return: None
"""
data = {'equipments': equipments}
return super(ApiV4Equipment, self).post('api/v4/equipment/', data) | python | def create(self, equipments):
"""
Method to create equipments
:param equipments: List containing equipments desired to be created on database
:return: None
"""
data = {'equipments': equipments}
return super(ApiV4Equipment, self).post('api/v4/equipment/', data) | [
"def",
"create",
"(",
"self",
",",
"equipments",
")",
":",
"data",
"=",
"{",
"'equipments'",
":",
"equipments",
"}",
"return",
"super",
"(",
"ApiV4Equipment",
",",
"self",
")",
".",
"post",
"(",
"'api/v4/equipment/'",
",",
"data",
")"
] | Method to create equipments
:param equipments: List containing equipments desired to be created on database
:return: None | [
"Method",
"to",
"create",
"equipments"
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiV4Equipment.py#L89-L98 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GenericClient.py | GenericClient.submit | def submit(self, map, method, postfix):
'''Realiza um requisição HTTP para a networkAPI.
:param map: Dicionário com os dados para gerar o XML enviado no corpo da requisição HTTP.
:param method: Método da requisição HTTP ('GET', 'POST', 'PUT' ou 'DELETE').
:param postfix: Posfixo a ser colocado na URL básica de acesso à networkAPI. Ex: /ambiente
:return: Tupla com o código e o corpo da resposta HTTP:
(< codigo>, < descricao>)
:raise NetworkAPIClientError: Erro durante a chamada HTTP para acesso à networkAPI.
'''
try:
rest_request = RestRequest(
self.get_url(postfix),
method,
self.user,
self.password,
self.user_ldap)
return rest_request.submit(map)
except RestError as e:
raise ErrorHandler.handle(None, str(e)) | python | def submit(self, map, method, postfix):
'''Realiza um requisição HTTP para a networkAPI.
:param map: Dicionário com os dados para gerar o XML enviado no corpo da requisição HTTP.
:param method: Método da requisição HTTP ('GET', 'POST', 'PUT' ou 'DELETE').
:param postfix: Posfixo a ser colocado na URL básica de acesso à networkAPI. Ex: /ambiente
:return: Tupla com o código e o corpo da resposta HTTP:
(< codigo>, < descricao>)
:raise NetworkAPIClientError: Erro durante a chamada HTTP para acesso à networkAPI.
'''
try:
rest_request = RestRequest(
self.get_url(postfix),
method,
self.user,
self.password,
self.user_ldap)
return rest_request.submit(map)
except RestError as e:
raise ErrorHandler.handle(None, str(e)) | [
"def",
"submit",
"(",
"self",
",",
"map",
",",
"method",
",",
"postfix",
")",
":",
"try",
":",
"rest_request",
"=",
"RestRequest",
"(",
"self",
".",
"get_url",
"(",
"postfix",
")",
",",
"method",
",",
"self",
".",
"user",
",",
"self",
".",
"password",
",",
"self",
".",
"user_ldap",
")",
"return",
"rest_request",
".",
"submit",
"(",
"map",
")",
"except",
"RestError",
"as",
"e",
":",
"raise",
"ErrorHandler",
".",
"handle",
"(",
"None",
",",
"str",
"(",
"e",
")",
")"
] | Realiza um requisição HTTP para a networkAPI.
:param map: Dicionário com os dados para gerar o XML enviado no corpo da requisição HTTP.
:param method: Método da requisição HTTP ('GET', 'POST', 'PUT' ou 'DELETE').
:param postfix: Posfixo a ser colocado na URL básica de acesso à networkAPI. Ex: /ambiente
:return: Tupla com o código e o corpo da resposta HTTP:
(< codigo>, < descricao>)
:raise NetworkAPIClientError: Erro durante a chamada HTTP para acesso à networkAPI. | [
"Realiza",
"um",
"requisição",
"HTTP",
"para",
"a",
"networkAPI",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GenericClient.py#L47-L68 |
globocom/GloboNetworkAPI-client-python | networkapiclient/GenericClient.py | GenericClient.get_error | def get_error(self, xml):
'''Obtem do XML de resposta, o código e a descrição do erro.
O XML corresponde ao corpo da resposta HTTP de código 500.
:param xml: XML contido na resposta da requisição HTTP.
:return: Tupla com o código e a descrição do erro contido no XML:
(< codigo_erro>, < descricao_erro>)
'''
map = loads(xml)
network_map = map['networkapi']
error_map = network_map['erro']
return int(error_map['codigo']), str(error_map['descricao']) | python | def get_error(self, xml):
'''Obtem do XML de resposta, o código e a descrição do erro.
O XML corresponde ao corpo da resposta HTTP de código 500.
:param xml: XML contido na resposta da requisição HTTP.
:return: Tupla com o código e a descrição do erro contido no XML:
(< codigo_erro>, < descricao_erro>)
'''
map = loads(xml)
network_map = map['networkapi']
error_map = network_map['erro']
return int(error_map['codigo']), str(error_map['descricao']) | [
"def",
"get_error",
"(",
"self",
",",
"xml",
")",
":",
"map",
"=",
"loads",
"(",
"xml",
")",
"network_map",
"=",
"map",
"[",
"'networkapi'",
"]",
"error_map",
"=",
"network_map",
"[",
"'erro'",
"]",
"return",
"int",
"(",
"error_map",
"[",
"'codigo'",
"]",
")",
",",
"str",
"(",
"error_map",
"[",
"'descricao'",
"]",
")"
] | Obtem do XML de resposta, o código e a descrição do erro.
O XML corresponde ao corpo da resposta HTTP de código 500.
:param xml: XML contido na resposta da requisição HTTP.
:return: Tupla com o código e a descrição do erro contido no XML:
(< codigo_erro>, < descricao_erro>) | [
"Obtem",
"do",
"XML",
"de",
"resposta",
"o",
"código",
"e",
"a",
"descrição",
"do",
"erro",
"."
] | train | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/GenericClient.py#L70-L83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.