repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
cloudendpoints/endpoints-python | endpoints/users_id_token.py | get_verified_jwt | def get_verified_jwt(
providers, audiences,
check_authorization_header=True, check_query_arg=True,
request=None, cache=memcache):
"""
This function will extract, verify, and parse a JWT token from the
Authorization header or access_token query argument.
The JWT is assumed to contain an issuer and a... | python | def get_verified_jwt(
providers, audiences,
check_authorization_header=True, check_query_arg=True,
request=None, cache=memcache):
"""
This function will extract, verify, and parse a JWT token from the
Authorization header or access_token query argument.
The JWT is assumed to contain an issuer and a... | [
"def",
"get_verified_jwt",
"(",
"providers",
",",
"audiences",
",",
"check_authorization_header",
"=",
"True",
",",
"check_query_arg",
"=",
"True",
",",
"request",
"=",
"None",
",",
"cache",
"=",
"memcache",
")",
":",
"if",
"not",
"(",
"check_authorization_heade... | This function will extract, verify, and parse a JWT token from the
Authorization header or access_token query argument.
The JWT is assumed to contain an issuer and audience claim, as well
as issued-at and expiration timestamps. The signature will be
cryptographically verified, the claims and timestamps will be... | [
"This",
"function",
"will",
"extract",
"verify",
"and",
"parse",
"a",
"JWT",
"token",
"from",
"the",
"Authorization",
"header",
"or",
"access_token",
"query",
"argument",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/users_id_token.py#L750-L794 | train |
cloudendpoints/endpoints-python | endpoints/directory_list_generator.py | DirectoryListGenerator.__item_descriptor | def __item_descriptor(self, config):
"""Builds an item descriptor for a service configuration.
Args:
config: A dictionary containing the service configuration to describe.
Returns:
A dictionary that describes the service configuration.
"""
descriptor = {
'kind': 'discovery#dire... | python | def __item_descriptor(self, config):
"""Builds an item descriptor for a service configuration.
Args:
config: A dictionary containing the service configuration to describe.
Returns:
A dictionary that describes the service configuration.
"""
descriptor = {
'kind': 'discovery#dire... | [
"def",
"__item_descriptor",
"(",
"self",
",",
"config",
")",
":",
"descriptor",
"=",
"{",
"'kind'",
":",
"'discovery#directoryItem'",
",",
"'icons'",
":",
"{",
"'x16'",
":",
"'https://www.gstatic.com/images/branding/product/1x/'",
"'googleg_16dp.png'",
",",
"'x32'",
"... | Builds an item descriptor for a service configuration.
Args:
config: A dictionary containing the service configuration to describe.
Returns:
A dictionary that describes the service configuration. | [
"Builds",
"an",
"item",
"descriptor",
"for",
"a",
"service",
"configuration",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/directory_list_generator.py#L56-L99 | train |
cloudendpoints/endpoints-python | endpoints/directory_list_generator.py | DirectoryListGenerator.__directory_list_descriptor | def __directory_list_descriptor(self, configs):
"""Builds a directory list for an API.
Args:
configs: List of dicts containing the service configurations to list.
Returns:
A dictionary that can be deserialized into JSON in discovery list format.
Raises:
ApiConfigurationError: If the... | python | def __directory_list_descriptor(self, configs):
"""Builds a directory list for an API.
Args:
configs: List of dicts containing the service configurations to list.
Returns:
A dictionary that can be deserialized into JSON in discovery list format.
Raises:
ApiConfigurationError: If the... | [
"def",
"__directory_list_descriptor",
"(",
"self",
",",
"configs",
")",
":",
"descriptor",
"=",
"{",
"'kind'",
":",
"'discovery#directoryList'",
",",
"'discoveryVersion'",
":",
"'v1'",
",",
"}",
"items",
"=",
"[",
"]",
"for",
"config",
"in",
"configs",
":",
... | Builds a directory list for an API.
Args:
configs: List of dicts containing the service configurations to list.
Returns:
A dictionary that can be deserialized into JSON in discovery list format.
Raises:
ApiConfigurationError: If there's something wrong with the API
configuration... | [
"Builds",
"a",
"directory",
"list",
"for",
"an",
"API",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/directory_list_generator.py#L101-L130 | train |
cloudendpoints/endpoints-python | endpoints/directory_list_generator.py | DirectoryListGenerator.get_directory_list_doc | def get_directory_list_doc(self, configs):
"""JSON dict description of a protorpc.remote.Service in list format.
Args:
configs: Either a single dict or a list of dicts containing the service
configurations to list.
Returns:
dict, The directory list document as a JSON dict.
"""
... | python | def get_directory_list_doc(self, configs):
"""JSON dict description of a protorpc.remote.Service in list format.
Args:
configs: Either a single dict or a list of dicts containing the service
configurations to list.
Returns:
dict, The directory list document as a JSON dict.
"""
... | [
"def",
"get_directory_list_doc",
"(",
"self",
",",
"configs",
")",
":",
"if",
"not",
"isinstance",
"(",
"configs",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"configs",
"=",
"[",
"configs",
"]",
"util",
".",
"check_list_type",
"(",
"configs",
",",
... | JSON dict description of a protorpc.remote.Service in list format.
Args:
configs: Either a single dict or a list of dicts containing the service
configurations to list.
Returns:
dict, The directory list document as a JSON dict. | [
"JSON",
"dict",
"description",
"of",
"a",
"protorpc",
".",
"remote",
".",
"Service",
"in",
"list",
"format",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/directory_list_generator.py#L132-L148 | train |
cloudendpoints/endpoints-python | endpoints/directory_list_generator.py | DirectoryListGenerator.pretty_print_config_to_json | def pretty_print_config_to_json(self, configs):
"""JSON string description of a protorpc.remote.Service in a discovery doc.
Args:
configs: Either a single dict or a list of dicts containing the service
configurations to list.
Returns:
string, The directory list document as a JSON strin... | python | def pretty_print_config_to_json(self, configs):
"""JSON string description of a protorpc.remote.Service in a discovery doc.
Args:
configs: Either a single dict or a list of dicts containing the service
configurations to list.
Returns:
string, The directory list document as a JSON strin... | [
"def",
"pretty_print_config_to_json",
"(",
"self",
",",
"configs",
")",
":",
"descriptor",
"=",
"self",
".",
"get_directory_list_doc",
"(",
"configs",
")",
"return",
"json",
".",
"dumps",
"(",
"descriptor",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
... | JSON string description of a protorpc.remote.Service in a discovery doc.
Args:
configs: Either a single dict or a list of dicts containing the service
configurations to list.
Returns:
string, The directory list document as a JSON string. | [
"JSON",
"string",
"description",
"of",
"a",
"protorpc",
".",
"remote",
".",
"Service",
"in",
"a",
"discovery",
"doc",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/directory_list_generator.py#L150-L162 | train |
cloudendpoints/endpoints-python | endpoints/errors.py | RequestError.__format_error | def __format_error(self, error_list_tag):
"""Format this error into a JSON response.
Args:
error_list_tag: A string specifying the name of the tag to use for the
error list.
Returns:
A dict containing the reformatted JSON error response.
"""
error = {'domain': self.domain(),
... | python | def __format_error(self, error_list_tag):
"""Format this error into a JSON response.
Args:
error_list_tag: A string specifying the name of the tag to use for the
error list.
Returns:
A dict containing the reformatted JSON error response.
"""
error = {'domain': self.domain(),
... | [
"def",
"__format_error",
"(",
"self",
",",
"error_list_tag",
")",
":",
"error",
"=",
"{",
"'domain'",
":",
"self",
".",
"domain",
"(",
")",
",",
"'reason'",
":",
"self",
".",
"reason",
"(",
")",
",",
"'message'",
":",
"self",
".",
"message",
"(",
")"... | Format this error into a JSON response.
Args:
error_list_tag: A string specifying the name of the tag to use for the
error list.
Returns:
A dict containing the reformatted JSON error response. | [
"Format",
"this",
"error",
"into",
"a",
"JSON",
"response",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/errors.py#L100-L116 | train |
cloudendpoints/endpoints-python | endpoints/errors.py | RequestError.rest_error | def rest_error(self):
"""Format this error into a response to a REST request.
Returns:
A string containing the reformatted error response.
"""
error_json = self.__format_error('errors')
return json.dumps(error_json, indent=1, sort_keys=True) | python | def rest_error(self):
"""Format this error into a response to a REST request.
Returns:
A string containing the reformatted error response.
"""
error_json = self.__format_error('errors')
return json.dumps(error_json, indent=1, sort_keys=True) | [
"def",
"rest_error",
"(",
"self",
")",
":",
"error_json",
"=",
"self",
".",
"__format_error",
"(",
"'errors'",
")",
"return",
"json",
".",
"dumps",
"(",
"error_json",
",",
"indent",
"=",
"1",
",",
"sort_keys",
"=",
"True",
")"
] | Format this error into a response to a REST request.
Returns:
A string containing the reformatted error response. | [
"Format",
"this",
"error",
"into",
"a",
"response",
"to",
"a",
"REST",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/errors.py#L118-L125 | train |
cloudendpoints/endpoints-python | endpoints/errors.py | BackendError._get_status_code | def _get_status_code(self, http_status):
"""Get the HTTP status code from an HTTP status string.
Args:
http_status: A string containing a HTTP status code and reason.
Returns:
An integer with the status code number from http_status.
"""
try:
return int(http_status.split(' ', 1)[0... | python | def _get_status_code(self, http_status):
"""Get the HTTP status code from an HTTP status string.
Args:
http_status: A string containing a HTTP status code and reason.
Returns:
An integer with the status code number from http_status.
"""
try:
return int(http_status.split(' ', 1)[0... | [
"def",
"_get_status_code",
"(",
"self",
",",
"http_status",
")",
":",
"try",
":",
"return",
"int",
"(",
"http_status",
".",
"split",
"(",
"' '",
",",
"1",
")",
"[",
"0",
"]",
")",
"except",
"TypeError",
":",
"_logger",
".",
"warning",
"(",
"'Unable to ... | Get the HTTP status code from an HTTP status string.
Args:
http_status: A string containing a HTTP status code and reason.
Returns:
An integer with the status code number from http_status. | [
"Get",
"the",
"HTTP",
"status",
"code",
"from",
"an",
"HTTP",
"status",
"string",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/errors.py#L239-L253 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager.process_api_config_response | def process_api_config_response(self, config_json):
"""Parses a JSON API config and registers methods for dispatch.
Side effects:
Parses method name, etc. for all methods and updates the indexing
data structures with the information.
Args:
config_json: A dict, the JSON body of the getApi... | python | def process_api_config_response(self, config_json):
"""Parses a JSON API config and registers methods for dispatch.
Side effects:
Parses method name, etc. for all methods and updates the indexing
data structures with the information.
Args:
config_json: A dict, the JSON body of the getApi... | [
"def",
"process_api_config_response",
"(",
"self",
",",
"config_json",
")",
":",
"with",
"self",
".",
"_config_lock",
":",
"self",
".",
"_add_discovery_config",
"(",
")",
"for",
"config",
"in",
"config_json",
".",
"get",
"(",
"'items'",
",",
"[",
"]",
")",
... | Parses a JSON API config and registers methods for dispatch.
Side effects:
Parses method name, etc. for all methods and updates the indexing
data structures with the information.
Args:
config_json: A dict, the JSON body of the getApiConfigs response. | [
"Parses",
"a",
"JSON",
"API",
"config",
"and",
"registers",
"methods",
"for",
"dispatch",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L53-L77 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager._get_sorted_methods | def _get_sorted_methods(self, methods):
"""Get a copy of 'methods' sorted the way they would be on the live server.
Args:
methods: JSON configuration of an API's methods.
Returns:
The same configuration with the methods sorted based on what order
they'll be checked by the server.
"""... | python | def _get_sorted_methods(self, methods):
"""Get a copy of 'methods' sorted the way they would be on the live server.
Args:
methods: JSON configuration of an API's methods.
Returns:
The same configuration with the methods sorted based on what order
they'll be checked by the server.
"""... | [
"def",
"_get_sorted_methods",
"(",
"self",
",",
"methods",
")",
":",
"if",
"not",
"methods",
":",
"return",
"methods",
"def",
"_sorted_methods_comparison",
"(",
"method_info1",
",",
"method_info2",
")",
":",
"def",
"_score_path",
"(",
"path",
")",
":",
"score"... | Get a copy of 'methods' sorted the way they would be on the live server.
Args:
methods: JSON configuration of an API's methods.
Returns:
The same configuration with the methods sorted based on what order
they'll be checked by the server. | [
"Get",
"a",
"copy",
"of",
"methods",
"sorted",
"the",
"way",
"they",
"would",
"be",
"on",
"the",
"live",
"server",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L79-L150 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager._get_path_params | def _get_path_params(match):
"""Gets path parameters from a regular expression match.
Args:
match: A regular expression Match object for a path.
Returns:
A dictionary containing the variable names converted from base64.
"""
result = {}
for var_name, value in match.groupdict().iteri... | python | def _get_path_params(match):
"""Gets path parameters from a regular expression match.
Args:
match: A regular expression Match object for a path.
Returns:
A dictionary containing the variable names converted from base64.
"""
result = {}
for var_name, value in match.groupdict().iteri... | [
"def",
"_get_path_params",
"(",
"match",
")",
":",
"result",
"=",
"{",
"}",
"for",
"var_name",
",",
"value",
"in",
"match",
".",
"groupdict",
"(",
")",
".",
"iteritems",
"(",
")",
":",
"actual_var_name",
"=",
"ApiConfigManager",
".",
"_from_safe_path_param_n... | Gets path parameters from a regular expression match.
Args:
match: A regular expression Match object for a path.
Returns:
A dictionary containing the variable names converted from base64. | [
"Gets",
"path",
"parameters",
"from",
"a",
"regular",
"expression",
"match",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L153-L166 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager.lookup_rest_method | def lookup_rest_method(self, path, request_uri, http_method):
"""Look up the rest method at call time.
The method is looked up in self._rest_methods, the list it is saved
in for SaveRestMethod.
Args:
path: A string containing the path from the URL of the request.
http_method: A string cont... | python | def lookup_rest_method(self, path, request_uri, http_method):
"""Look up the rest method at call time.
The method is looked up in self._rest_methods, the list it is saved
in for SaveRestMethod.
Args:
path: A string containing the path from the URL of the request.
http_method: A string cont... | [
"def",
"lookup_rest_method",
"(",
"self",
",",
"path",
",",
"request_uri",
",",
"http_method",
")",
":",
"method_key",
"=",
"http_method",
".",
"lower",
"(",
")",
"with",
"self",
".",
"_config_lock",
":",
"for",
"compiled_path_pattern",
",",
"unused_path",
","... | Look up the rest method at call time.
The method is looked up in self._rest_methods, the list it is saved
in for SaveRestMethod.
Args:
path: A string containing the path from the URL of the request.
http_method: A string containing HTTP method of the request.
Returns:
Tuple of (<met... | [
"Look",
"up",
"the",
"rest",
"method",
"at",
"call",
"time",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L168-L202 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager._add_discovery_config | def _add_discovery_config(self):
"""Add the Discovery configuration to our list of configs.
This should only be called with self._config_lock. The code here assumes
the lock is held.
"""
lookup_key = (discovery_service.DiscoveryService.API_CONFIG['name'],
discovery_service.Discov... | python | def _add_discovery_config(self):
"""Add the Discovery configuration to our list of configs.
This should only be called with self._config_lock. The code here assumes
the lock is held.
"""
lookup_key = (discovery_service.DiscoveryService.API_CONFIG['name'],
discovery_service.Discov... | [
"def",
"_add_discovery_config",
"(",
"self",
")",
":",
"lookup_key",
"=",
"(",
"discovery_service",
".",
"DiscoveryService",
".",
"API_CONFIG",
"[",
"'name'",
"]",
",",
"discovery_service",
".",
"DiscoveryService",
".",
"API_CONFIG",
"[",
"'version'",
"]",
")",
... | Add the Discovery configuration to our list of configs.
This should only be called with self._config_lock. The code here assumes
the lock is held. | [
"Add",
"the",
"Discovery",
"configuration",
"to",
"our",
"list",
"of",
"configs",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L204-L212 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager.save_config | def save_config(self, lookup_key, config):
"""Save a configuration to the cache of configs.
Args:
lookup_key: A string containing the cache lookup key.
config: The dict containing the configuration to save to the cache.
"""
with self._config_lock:
self._configs[lookup_key] = config | python | def save_config(self, lookup_key, config):
"""Save a configuration to the cache of configs.
Args:
lookup_key: A string containing the cache lookup key.
config: The dict containing the configuration to save to the cache.
"""
with self._config_lock:
self._configs[lookup_key] = config | [
"def",
"save_config",
"(",
"self",
",",
"lookup_key",
",",
"config",
")",
":",
"with",
"self",
".",
"_config_lock",
":",
"self",
".",
"_configs",
"[",
"lookup_key",
"]",
"=",
"config"
] | Save a configuration to the cache of configs.
Args:
lookup_key: A string containing the cache lookup key.
config: The dict containing the configuration to save to the cache. | [
"Save",
"a",
"configuration",
"to",
"the",
"cache",
"of",
"configs",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L214-L222 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager._from_safe_path_param_name | def _from_safe_path_param_name(safe_parameter):
"""Takes a safe regex group name and converts it back to the original value.
Only alphanumeric characters and underscore are allowed in variable name
tokens, and numeric are not allowed as the first character.
The safe_parameter is a base32 representatio... | python | def _from_safe_path_param_name(safe_parameter):
"""Takes a safe regex group name and converts it back to the original value.
Only alphanumeric characters and underscore are allowed in variable name
tokens, and numeric are not allowed as the first character.
The safe_parameter is a base32 representatio... | [
"def",
"_from_safe_path_param_name",
"(",
"safe_parameter",
")",
":",
"assert",
"safe_parameter",
".",
"startswith",
"(",
"'_'",
")",
"safe_parameter_as_base32",
"=",
"safe_parameter",
"[",
"1",
":",
"]",
"padding_length",
"=",
"-",
"len",
"(",
"safe_parameter_as_ba... | Takes a safe regex group name and converts it back to the original value.
Only alphanumeric characters and underscore are allowed in variable name
tokens, and numeric are not allowed as the first character.
The safe_parameter is a base32 representation of the actual value.
Args:
safe_parameter:... | [
"Takes",
"a",
"safe",
"regex",
"group",
"name",
"and",
"converts",
"it",
"back",
"to",
"the",
"original",
"value",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L245-L264 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager._compile_path_pattern | def _compile_path_pattern(pattern):
r"""Generates a compiled regex pattern for a path pattern.
e.g. '/MyApi/v1/notes/{id}'
returns re.compile(r'/MyApi/v1/notes/(?P<id>[^/?#\[\]{}]*)')
Args:
pattern: A string, the parameterized path pattern to be checked.
Returns:
A compiled regex obje... | python | def _compile_path_pattern(pattern):
r"""Generates a compiled regex pattern for a path pattern.
e.g. '/MyApi/v1/notes/{id}'
returns re.compile(r'/MyApi/v1/notes/(?P<id>[^/?#\[\]{}]*)')
Args:
pattern: A string, the parameterized path pattern to be checked.
Returns:
A compiled regex obje... | [
"def",
"_compile_path_pattern",
"(",
"pattern",
")",
":",
"r",
"def",
"replace_variable",
"(",
"match",
")",
":",
"if",
"match",
".",
"lastindex",
">",
"1",
":",
"var_name",
"=",
"ApiConfigManager",
".",
"_to_safe_path_param_name",
"(",
"match",
".",
"group",
... | r"""Generates a compiled regex pattern for a path pattern.
e.g. '/MyApi/v1/notes/{id}'
returns re.compile(r'/MyApi/v1/notes/(?P<id>[^/?#\[\]{}]*)')
Args:
pattern: A string, the parameterized path pattern to be checked.
Returns:
A compiled regex object to match this path pattern. | [
"r",
"Generates",
"a",
"compiled",
"regex",
"pattern",
"for",
"a",
"path",
"pattern",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L267-L304 | train |
cloudendpoints/endpoints-python | endpoints/api_config_manager.py | ApiConfigManager._save_rest_method | def _save_rest_method(self, method_name, api_name, version, method):
"""Store Rest api methods in a list for lookup at call time.
The list is self._rest_methods, a list of tuples:
[(<compiled_path>, <path_pattern>, <method_dict>), ...]
where:
<compiled_path> is a compiled regex to match against... | python | def _save_rest_method(self, method_name, api_name, version, method):
"""Store Rest api methods in a list for lookup at call time.
The list is self._rest_methods, a list of tuples:
[(<compiled_path>, <path_pattern>, <method_dict>), ...]
where:
<compiled_path> is a compiled regex to match against... | [
"def",
"_save_rest_method",
"(",
"self",
",",
"method_name",
",",
"api_name",
",",
"version",
",",
"method",
")",
":",
"path_pattern",
"=",
"'/'",
".",
"join",
"(",
"(",
"api_name",
",",
"version",
",",
"method",
".",
"get",
"(",
"'path'",
",",
"''",
"... | Store Rest api methods in a list for lookup at call time.
The list is self._rest_methods, a list of tuples:
[(<compiled_path>, <path_pattern>, <method_dict>), ...]
where:
<compiled_path> is a compiled regex to match against the incoming URL
<path_pattern> is a string representing the original... | [
"Store",
"Rest",
"api",
"methods",
"in",
"a",
"list",
"for",
"lookup",
"at",
"call",
"time",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config_manager.py#L306-L350 | train |
cloudendpoints/endpoints-python | endpoints/apiserving.py | api_server | def api_server(api_services, **kwargs):
"""Create an api_server.
The primary function of this method is to set up the WSGIApplication
instance for the service handlers described by the services passed in.
Additionally, it registers each API in ApiConfigRegistry for later use
in the BackendService.getApiConfi... | python | def api_server(api_services, **kwargs):
"""Create an api_server.
The primary function of this method is to set up the WSGIApplication
instance for the service handlers described by the services passed in.
Additionally, it registers each API in ApiConfigRegistry for later use
in the BackendService.getApiConfi... | [
"def",
"api_server",
"(",
"api_services",
",",
"**",
"kwargs",
")",
":",
"if",
"'protocols'",
"in",
"kwargs",
":",
"raise",
"TypeError",
"(",
"\"__init__() got an unexpected keyword argument 'protocols'\"",
")",
"from",
".",
"import",
"_logger",
"as",
"endpoints_logge... | Create an api_server.
The primary function of this method is to set up the WSGIApplication
instance for the service handlers described by the services passed in.
Additionally, it registers each API in ApiConfigRegistry for later use
in the BackendService.getApiConfigs() (API config enumeration service).
It a... | [
"Create",
"an",
"api_server",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L541-L606 | train |
cloudendpoints/endpoints-python | endpoints/apiserving.py | ApiConfigRegistry.register_backend | def register_backend(self, config_contents):
"""Register a single API and its config contents.
Args:
config_contents: Dict containing API configuration.
"""
if config_contents is None:
return
self.__register_class(config_contents)
self.__api_configs.append(config_contents)
self.... | python | def register_backend(self, config_contents):
"""Register a single API and its config contents.
Args:
config_contents: Dict containing API configuration.
"""
if config_contents is None:
return
self.__register_class(config_contents)
self.__api_configs.append(config_contents)
self.... | [
"def",
"register_backend",
"(",
"self",
",",
"config_contents",
")",
":",
"if",
"config_contents",
"is",
"None",
":",
"return",
"self",
".",
"__register_class",
"(",
"config_contents",
")",
"self",
".",
"__api_configs",
".",
"append",
"(",
"config_contents",
")"... | Register a single API and its config contents.
Args:
config_contents: Dict containing API configuration. | [
"Register",
"a",
"single",
"API",
"and",
"its",
"config",
"contents",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L197-L207 | train |
cloudendpoints/endpoints-python | endpoints/apiserving.py | ApiConfigRegistry.__register_class | def __register_class(self, parsed_config):
"""Register the class implementing this config, so we only add it once.
Args:
parsed_config: The JSON object with the API configuration being added.
Raises:
ApiConfigurationError: If the class has already been registered.
"""
methods = parsed_... | python | def __register_class(self, parsed_config):
"""Register the class implementing this config, so we only add it once.
Args:
parsed_config: The JSON object with the API configuration being added.
Raises:
ApiConfigurationError: If the class has already been registered.
"""
methods = parsed_... | [
"def",
"__register_class",
"(",
"self",
",",
"parsed_config",
")",
":",
"methods",
"=",
"parsed_config",
".",
"get",
"(",
"'methods'",
")",
"if",
"not",
"methods",
":",
"return",
"service_classes",
"=",
"set",
"(",
")",
"for",
"method",
"in",
"methods",
".... | Register the class implementing this config, so we only add it once.
Args:
parsed_config: The JSON object with the API configuration being added.
Raises:
ApiConfigurationError: If the class has already been registered. | [
"Register",
"the",
"class",
"implementing",
"this",
"config",
"so",
"we",
"only",
"add",
"it",
"once",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L209-L234 | train |
cloudendpoints/endpoints-python | endpoints/apiserving.py | ApiConfigRegistry.__register_methods | def __register_methods(self, parsed_config):
"""Register all methods from the given api config file.
Methods are stored in a map from method_name to rosyMethod,
the name of the ProtoRPC method to be called on the backend.
If no rosyMethod was specified the value will be None.
Args:
parsed_co... | python | def __register_methods(self, parsed_config):
"""Register all methods from the given api config file.
Methods are stored in a map from method_name to rosyMethod,
the name of the ProtoRPC method to be called on the backend.
If no rosyMethod was specified the value will be None.
Args:
parsed_co... | [
"def",
"__register_methods",
"(",
"self",
",",
"parsed_config",
")",
":",
"methods",
"=",
"parsed_config",
".",
"get",
"(",
"'methods'",
")",
"if",
"not",
"methods",
":",
"return",
"for",
"method_name",
",",
"method",
"in",
"methods",
".",
"iteritems",
"(",
... | Register all methods from the given api config file.
Methods are stored in a map from method_name to rosyMethod,
the name of the ProtoRPC method to be called on the backend.
If no rosyMethod was specified the value will be None.
Args:
parsed_config: The JSON object with the API configuration bei... | [
"Register",
"all",
"methods",
"from",
"the",
"given",
"api",
"config",
"file",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L236-L251 | train |
cloudendpoints/endpoints-python | endpoints/apiserving.py | _ApiServer.__register_services | def __register_services(api_name_version_map, api_config_registry):
"""Register & return a list of each URL and class that handles that URL.
This finds every service class in api_name_version_map, registers it with
the given ApiConfigRegistry, builds the URL for that class, and adds
the URL and its fac... | python | def __register_services(api_name_version_map, api_config_registry):
"""Register & return a list of each URL and class that handles that URL.
This finds every service class in api_name_version_map, registers it with
the given ApiConfigRegistry, builds the URL for that class, and adds
the URL and its fac... | [
"def",
"__register_services",
"(",
"api_name_version_map",
",",
"api_config_registry",
")",
":",
"generator",
"=",
"api_config",
".",
"ApiConfigGenerator",
"(",
")",
"protorpc_services",
"=",
"[",
"]",
"for",
"service_factories",
"in",
"api_name_version_map",
".",
"it... | Register & return a list of each URL and class that handles that URL.
This finds every service class in api_name_version_map, registers it with
the given ApiConfigRegistry, builds the URL for that class, and adds
the URL and its factory to a list that's returned.
Args:
api_name_version_map: A ma... | [
"Register",
"&",
"return",
"a",
"list",
"of",
"each",
"URL",
"and",
"class",
"that",
"handles",
"that",
"URL",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L392-L432 | train |
cloudendpoints/endpoints-python | endpoints/apiserving.py | _ApiServer.__is_json_error | def __is_json_error(self, status, headers):
"""Determine if response is an error.
Args:
status: HTTP status code.
headers: Dictionary of (lowercase) header name to value.
Returns:
True if the response was an error, else False.
"""
content_header = headers.get('content-type', '')
... | python | def __is_json_error(self, status, headers):
"""Determine if response is an error.
Args:
status: HTTP status code.
headers: Dictionary of (lowercase) header name to value.
Returns:
True if the response was an error, else False.
"""
content_header = headers.get('content-type', '')
... | [
"def",
"__is_json_error",
"(",
"self",
",",
"status",
",",
"headers",
")",
":",
"content_header",
"=",
"headers",
".",
"get",
"(",
"'content-type'",
",",
"''",
")",
"content_type",
",",
"unused_params",
"=",
"cgi",
".",
"parse_header",
"(",
"content_header",
... | Determine if response is an error.
Args:
status: HTTP status code.
headers: Dictionary of (lowercase) header name to value.
Returns:
True if the response was an error, else False. | [
"Determine",
"if",
"response",
"is",
"an",
"error",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L434-L447 | train |
cloudendpoints/endpoints-python | endpoints/apiserving.py | _ApiServer.__write_error | def __write_error(self, status_code, error_message=None):
"""Return the HTTP status line and body for a given error code and message.
Args:
status_code: HTTP status code to be returned.
error_message: Error message to be returned.
Returns:
Tuple (http_status, body):
http_status: ... | python | def __write_error(self, status_code, error_message=None):
"""Return the HTTP status line and body for a given error code and message.
Args:
status_code: HTTP status code to be returned.
error_message: Error message to be returned.
Returns:
Tuple (http_status, body):
http_status: ... | [
"def",
"__write_error",
"(",
"self",
",",
"status_code",
",",
"error_message",
"=",
"None",
")",
":",
"if",
"error_message",
"is",
"None",
":",
"error_message",
"=",
"httplib",
".",
"responses",
"[",
"status_code",
"]",
"status",
"=",
"'%d %s'",
"%",
"(",
... | Return the HTTP status line and body for a given error code and message.
Args:
status_code: HTTP status code to be returned.
error_message: Error message to be returned.
Returns:
Tuple (http_status, body):
http_status: HTTP status line, e.g. 200 OK.
body: Body of the HTTP req... | [
"Return",
"the",
"HTTP",
"status",
"line",
"and",
"body",
"for",
"a",
"given",
"error",
"code",
"and",
"message",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L449-L467 | train |
cloudendpoints/endpoints-python | endpoints/apiserving.py | _ApiServer.protorpc_to_endpoints_error | def protorpc_to_endpoints_error(self, status, body):
"""Convert a ProtoRPC error to the format expected by Google Endpoints.
If the body does not contain an ProtoRPC message in state APPLICATION_ERROR
the status and body will be returned unchanged.
Args:
status: HTTP status of the response from ... | python | def protorpc_to_endpoints_error(self, status, body):
"""Convert a ProtoRPC error to the format expected by Google Endpoints.
If the body does not contain an ProtoRPC message in state APPLICATION_ERROR
the status and body will be returned unchanged.
Args:
status: HTTP status of the response from ... | [
"def",
"protorpc_to_endpoints_error",
"(",
"self",
",",
"status",
",",
"body",
")",
":",
"try",
":",
"rpc_error",
"=",
"self",
".",
"__PROTOJSON",
".",
"decode_message",
"(",
"remote",
".",
"RpcStatus",
",",
"body",
")",
"except",
"(",
"ValueError",
",",
"... | Convert a ProtoRPC error to the format expected by Google Endpoints.
If the body does not contain an ProtoRPC message in state APPLICATION_ERROR
the status and body will be returned unchanged.
Args:
status: HTTP status of the response from the backend
body: JSON-encoded error in format expecte... | [
"Convert",
"a",
"ProtoRPC",
"error",
"to",
"the",
"format",
"expected",
"by",
"Google",
"Endpoints",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L469-L494 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware._add_dispatcher | def _add_dispatcher(self, path_regex, dispatch_function):
"""Add a request path and dispatch handler.
Args:
path_regex: A string regex, the path to match against incoming requests.
dispatch_function: The function to call for these requests. The function
should take (request, start_response... | python | def _add_dispatcher(self, path_regex, dispatch_function):
"""Add a request path and dispatch handler.
Args:
path_regex: A string regex, the path to match against incoming requests.
dispatch_function: The function to call for these requests. The function
should take (request, start_response... | [
"def",
"_add_dispatcher",
"(",
"self",
",",
"path_regex",
",",
"dispatch_function",
")",
":",
"self",
".",
"_dispatchers",
".",
"append",
"(",
"(",
"re",
".",
"compile",
"(",
"path_regex",
")",
",",
"dispatch_function",
")",
")"
] | Add a request path and dispatch handler.
Args:
path_regex: A string regex, the path to match against incoming requests.
dispatch_function: The function to call for these requests. The function
should take (request, start_response) as arguments and
return the contents of the response bo... | [
"Add",
"a",
"request",
"path",
"and",
"dispatch",
"handler",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L103-L112 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.dispatch | def dispatch(self, request, start_response):
"""Handles dispatch to apiserver handlers.
This typically ends up calling start_response and returning the entire
body of the response.
Args:
request: An ApiRequest, the request from the user.
start_response: A function with semantics defined ... | python | def dispatch(self, request, start_response):
"""Handles dispatch to apiserver handlers.
This typically ends up calling start_response and returning the entire
body of the response.
Args:
request: An ApiRequest, the request from the user.
start_response: A function with semantics defined ... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"start_response",
")",
":",
"dispatched_response",
"=",
"self",
".",
"dispatch_non_api_requests",
"(",
"request",
",",
"start_response",
")",
"if",
"dispatched_response",
"is",
"not",
"None",
":",
"return",
"d... | Handles dispatch to apiserver handlers.
This typically ends up calling start_response and returning the entire
body of the response.
Args:
request: An ApiRequest, the request from the user.
start_response: A function with semantics defined in PEP-333.
Returns:
A string, the body o... | [
"Handles",
"dispatch",
"to",
"apiserver",
"handlers",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L149-L172 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.dispatch_non_api_requests | def dispatch_non_api_requests(self, request, start_response):
"""Dispatch this request if this is a request to a reserved URL.
If the request matches one of our reserved URLs, this calls
start_response and returns the response body. This also handles OPTIONS
CORS requests.
Args:
request: An... | python | def dispatch_non_api_requests(self, request, start_response):
"""Dispatch this request if this is a request to a reserved URL.
If the request matches one of our reserved URLs, this calls
start_response and returns the response body. This also handles OPTIONS
CORS requests.
Args:
request: An... | [
"def",
"dispatch_non_api_requests",
"(",
"self",
",",
"request",
",",
"start_response",
")",
":",
"for",
"path_regex",
",",
"dispatch_function",
"in",
"self",
".",
"_dispatchers",
":",
"if",
"path_regex",
".",
"match",
"(",
"request",
".",
"relative_url",
")",
... | Dispatch this request if this is a request to a reserved URL.
If the request matches one of our reserved URLs, this calls
start_response and returns the response body. This also handles OPTIONS
CORS requests.
Args:
request: An ApiRequest, the request from the user.
start_response: A funct... | [
"Dispatch",
"this",
"request",
"if",
"this",
"is",
"a",
"request",
"to",
"a",
"reserved",
"URL",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L174-L200 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.verify_response | def verify_response(response, status_code, content_type=None):
"""Verifies that a response has the expected status and content type.
Args:
response: The ResponseTuple to be checked.
status_code: An int, the HTTP status code to be compared with response
status.
content_type: A string w... | python | def verify_response(response, status_code, content_type=None):
"""Verifies that a response has the expected status and content type.
Args:
response: The ResponseTuple to be checked.
status_code: An int, the HTTP status code to be compared with response
status.
content_type: A string w... | [
"def",
"verify_response",
"(",
"response",
",",
"status_code",
",",
"content_type",
"=",
"None",
")",
":",
"status",
"=",
"int",
"(",
"response",
".",
"status",
".",
"split",
"(",
"' '",
",",
"1",
")",
"[",
"0",
"]",
")",
"if",
"status",
"!=",
"statu... | Verifies that a response has the expected status and content type.
Args:
response: The ResponseTuple to be checked.
status_code: An int, the HTTP status code to be compared with response
status.
content_type: A string with the acceptable Content-Type header value.
None allows any ... | [
"Verifies",
"that",
"a",
"response",
"has",
"the",
"expected",
"status",
"and",
"content",
"type",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L246-L271 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.prepare_backend_environ | def prepare_backend_environ(self, host, method, relative_url, headers, body,
source_ip, port):
"""Build an environ object for the backend to consume.
Args:
host: A string containing the host serving the request.
method: A string containing the HTTP method of the reques... | python | def prepare_backend_environ(self, host, method, relative_url, headers, body,
source_ip, port):
"""Build an environ object for the backend to consume.
Args:
host: A string containing the host serving the request.
method: A string containing the HTTP method of the reques... | [
"def",
"prepare_backend_environ",
"(",
"self",
",",
"host",
",",
"method",
",",
"relative_url",
",",
"headers",
",",
"body",
",",
"source_ip",
",",
"port",
")",
":",
"if",
"isinstance",
"(",
"body",
",",
"unicode",
")",
":",
"body",
"=",
"body",
".",
"... | Build an environ object for the backend to consume.
Args:
host: A string containing the host serving the request.
method: A string containing the HTTP method of the request.
relative_url: A string containing path and query string of the request.
headers: A list of (key, value) tuples where ... | [
"Build",
"an",
"environ",
"object",
"for",
"the",
"backend",
"to",
"consume",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L273-L315 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.handle_backend_response | def handle_backend_response(self, orig_request, backend_request,
response_status, response_headers,
response_body, method_config, start_response):
"""Handle backend response, transforming output as needed.
This calls start_response and returns the res... | python | def handle_backend_response(self, orig_request, backend_request,
response_status, response_headers,
response_body, method_config, start_response):
"""Handle backend response, transforming output as needed.
This calls start_response and returns the res... | [
"def",
"handle_backend_response",
"(",
"self",
",",
"orig_request",
",",
"backend_request",
",",
"response_status",
",",
"response_headers",
",",
"response_body",
",",
"method_config",
",",
"start_response",
")",
":",
"for",
"header",
",",
"value",
"in",
"response_h... | Handle backend response, transforming output as needed.
This calls start_response and returns the response body.
Args:
orig_request: An ApiRequest, the original request from the user.
backend_request: An ApiRequest, the transformed request that was
sent to the backend handle... | [
"Handle",
"backend",
"response",
"transforming",
"output",
"as",
"needed",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L415-L457 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.fail_request | def fail_request(self, orig_request, message, start_response):
"""Write an immediate failure response to outfile, no redirect.
This calls start_response and returns the error body.
Args:
orig_request: An ApiRequest, the original request from the user.
message: A string containing the error mes... | python | def fail_request(self, orig_request, message, start_response):
"""Write an immediate failure response to outfile, no redirect.
This calls start_response and returns the error body.
Args:
orig_request: An ApiRequest, the original request from the user.
message: A string containing the error mes... | [
"def",
"fail_request",
"(",
"self",
",",
"orig_request",
",",
"message",
",",
"start_response",
")",
":",
"cors_handler",
"=",
"self",
".",
"_create_cors_handler",
"(",
"orig_request",
")",
"return",
"util",
".",
"send_wsgi_error_response",
"(",
"message",
",",
... | Write an immediate failure response to outfile, no redirect.
This calls start_response and returns the error body.
Args:
orig_request: An ApiRequest, the original request from the user.
message: A string containing the error message to be displayed to user.
start_response: A function with se... | [
"Write",
"an",
"immediate",
"failure",
"response",
"to",
"outfile",
"no",
"redirect",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L459-L474 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.lookup_rest_method | def lookup_rest_method(self, orig_request):
"""Looks up and returns rest method for the currently-pending request.
Args:
orig_request: An ApiRequest, the original request from the user.
Returns:
A tuple of (method descriptor, parameters), or (None, None) if no method
was found for the cu... | python | def lookup_rest_method(self, orig_request):
"""Looks up and returns rest method for the currently-pending request.
Args:
orig_request: An ApiRequest, the original request from the user.
Returns:
A tuple of (method descriptor, parameters), or (None, None) if no method
was found for the cu... | [
"def",
"lookup_rest_method",
"(",
"self",
",",
"orig_request",
")",
":",
"method_name",
",",
"method",
",",
"params",
"=",
"self",
".",
"config_manager",
".",
"lookup_rest_method",
"(",
"orig_request",
".",
"path",
",",
"orig_request",
".",
"request_uri",
",",
... | Looks up and returns rest method for the currently-pending request.
Args:
orig_request: An ApiRequest, the original request from the user.
Returns:
A tuple of (method descriptor, parameters), or (None, None) if no method
was found for the current request. | [
"Looks",
"up",
"and",
"returns",
"rest",
"method",
"for",
"the",
"currently",
"-",
"pending",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L476-L489 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.transform_request | def transform_request(self, orig_request, params, method_config):
"""Transforms orig_request to apiserving request.
This method uses orig_request to determine the currently-pending request
and returns a new transformed request ready to send to the backend. This
method accepts a rest-style or RPC-style... | python | def transform_request(self, orig_request, params, method_config):
"""Transforms orig_request to apiserving request.
This method uses orig_request to determine the currently-pending request
and returns a new transformed request ready to send to the backend. This
method accepts a rest-style or RPC-style... | [
"def",
"transform_request",
"(",
"self",
",",
"orig_request",
",",
"params",
",",
"method_config",
")",
":",
"method_params",
"=",
"method_config",
".",
"get",
"(",
"'request'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'parameters'",
",",
"{",
"}",
")",
"re... | Transforms orig_request to apiserving request.
This method uses orig_request to determine the currently-pending request
and returns a new transformed request ready to send to the backend. This
method accepts a rest-style or RPC-style request.
Args:
orig_request: An ApiRequest, the original requ... | [
"Transforms",
"orig_request",
"to",
"apiserving",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L491-L512 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware._add_message_field | def _add_message_field(self, field_name, value, params):
"""Converts a . delimitied field name to a message field in parameters.
This adds the field to the params dict, broken out so that message
parameters appear as sub-dicts within the outer param.
For example:
{'a.b.c': ['foo']}
becomes:
... | python | def _add_message_field(self, field_name, value, params):
"""Converts a . delimitied field name to a message field in parameters.
This adds the field to the params dict, broken out so that message
parameters appear as sub-dicts within the outer param.
For example:
{'a.b.c': ['foo']}
becomes:
... | [
"def",
"_add_message_field",
"(",
"self",
",",
"field_name",
",",
"value",
",",
"params",
")",
":",
"if",
"'.'",
"not",
"in",
"field_name",
":",
"params",
"[",
"field_name",
"]",
"=",
"value",
"return",
"root",
",",
"remaining",
"=",
"field_name",
".",
"... | Converts a . delimitied field name to a message field in parameters.
This adds the field to the params dict, broken out so that message
parameters appear as sub-dicts within the outer param.
For example:
{'a.b.c': ['foo']}
becomes:
{'a': {'b': {'c': ['foo']}}}
Args:
field_name: ... | [
"Converts",
"a",
".",
"delimitied",
"field",
"name",
"to",
"a",
"message",
"field",
"in",
"parameters",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L514-L538 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware._update_from_body | def _update_from_body(self, destination, source):
"""Updates the dictionary for an API payload with the request body.
The values from the body should override those already in the payload, but
for nested fields (message objects) the values can be combined
recursively.
Args:
destination: A di... | python | def _update_from_body(self, destination, source):
"""Updates the dictionary for an API payload with the request body.
The values from the body should override those already in the payload, but
for nested fields (message objects) the values can be combined
recursively.
Args:
destination: A di... | [
"def",
"_update_from_body",
"(",
"self",
",",
"destination",
",",
"source",
")",
":",
"for",
"key",
",",
"value",
"in",
"source",
".",
"iteritems",
"(",
")",
":",
"destination_value",
"=",
"destination",
".",
"get",
"(",
"key",
")",
"if",
"isinstance",
"... | Updates the dictionary for an API payload with the request body.
The values from the body should override those already in the payload, but
for nested fields (message objects) the values can be combined
recursively.
Args:
destination: A dictionary containing an API payload parsed from the
... | [
"Updates",
"the",
"dictionary",
"for",
"an",
"API",
"payload",
"with",
"the",
"request",
"body",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L540-L557 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.transform_rest_request | def transform_rest_request(self, orig_request, params, method_parameters):
"""Translates a Rest request into an apiserving request.
This makes a copy of orig_request and transforms it to apiserving
format (moving request parameters to the body).
The request can receive values from the path, query and ... | python | def transform_rest_request(self, orig_request, params, method_parameters):
"""Translates a Rest request into an apiserving request.
This makes a copy of orig_request and transforms it to apiserving
format (moving request parameters to the body).
The request can receive values from the path, query and ... | [
"def",
"transform_rest_request",
"(",
"self",
",",
"orig_request",
",",
"params",
",",
"method_parameters",
")",
":",
"request",
"=",
"orig_request",
".",
"copy",
"(",
")",
"body_json",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"params",
".",
"iteri... | Translates a Rest request into an apiserving request.
This makes a copy of orig_request and transforms it to apiserving
format (moving request parameters to the body).
The request can receive values from the path, query and body and combine
them before sending them along to the backend. In cases of co... | [
"Translates",
"a",
"Rest",
"request",
"into",
"an",
"apiserving",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L559-L645 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.check_error_response | def check_error_response(self, body, status):
"""Raise an exception if the response from the backend was an error.
Args:
body: A string containing the backend response body.
status: A string containing the backend response status.
Raises:
BackendError if the response is an error.
"""... | python | def check_error_response(self, body, status):
"""Raise an exception if the response from the backend was an error.
Args:
body: A string containing the backend response body.
status: A string containing the backend response status.
Raises:
BackendError if the response is an error.
"""... | [
"def",
"check_error_response",
"(",
"self",
",",
"body",
",",
"status",
")",
":",
"status_code",
"=",
"int",
"(",
"status",
".",
"split",
"(",
"' '",
",",
"1",
")",
"[",
"0",
"]",
")",
"if",
"status_code",
">=",
"300",
":",
"raise",
"errors",
".",
... | Raise an exception if the response from the backend was an error.
Args:
body: A string containing the backend response body.
status: A string containing the backend response status.
Raises:
BackendError if the response is an error. | [
"Raise",
"an",
"exception",
"if",
"the",
"response",
"from",
"the",
"backend",
"was",
"an",
"error",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L647-L659 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.check_empty_response | def check_empty_response(self, orig_request, method_config, start_response):
"""If the response from the backend is empty, return a HTTP 204 No Content.
Args:
orig_request: An ApiRequest, the original request from the user.
method_config: A dict, the API config of the method to be called.
sta... | python | def check_empty_response(self, orig_request, method_config, start_response):
"""If the response from the backend is empty, return a HTTP 204 No Content.
Args:
orig_request: An ApiRequest, the original request from the user.
method_config: A dict, the API config of the method to be called.
sta... | [
"def",
"check_empty_response",
"(",
"self",
",",
"orig_request",
",",
"method_config",
",",
"start_response",
")",
":",
"response_config",
"=",
"method_config",
".",
"get",
"(",
"'response'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'body'",
")",
"if",
"respons... | If the response from the backend is empty, return a HTTP 204 No Content.
Args:
orig_request: An ApiRequest, the original request from the user.
method_config: A dict, the API config of the method to be called.
start_response: A function with semantics defined in PEP-333.
Returns:
If th... | [
"If",
"the",
"response",
"from",
"the",
"backend",
"is",
"empty",
"return",
"a",
"HTTP",
"204",
"No",
"Content",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L661-L681 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware.transform_rest_response | def transform_rest_response(self, response_body):
"""Translates an apiserving REST response so it's ready to return.
Currently, the only thing that needs to be fixed here is indentation,
so it's consistent with what the live app will return.
Args:
response_body: A string containing the backend r... | python | def transform_rest_response(self, response_body):
"""Translates an apiserving REST response so it's ready to return.
Currently, the only thing that needs to be fixed here is indentation,
so it's consistent with what the live app will return.
Args:
response_body: A string containing the backend r... | [
"def",
"transform_rest_response",
"(",
"self",
",",
"response_body",
")",
":",
"body_json",
"=",
"json",
".",
"loads",
"(",
"response_body",
")",
"return",
"json",
".",
"dumps",
"(",
"body_json",
",",
"indent",
"=",
"1",
",",
"sort_keys",
"=",
"True",
")"
... | Translates an apiserving REST response so it's ready to return.
Currently, the only thing that needs to be fixed here is indentation,
so it's consistent with what the live app will return.
Args:
response_body: A string containing the backend response.
Returns:
A reformatted version of the... | [
"Translates",
"an",
"apiserving",
"REST",
"response",
"so",
"it",
"s",
"ready",
"to",
"return",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L683-L696 | train |
cloudendpoints/endpoints-python | endpoints/endpoints_dispatcher.py | EndpointsDispatcherMiddleware._handle_request_error | def _handle_request_error(self, orig_request, error, start_response):
"""Handle a request error, converting it to a WSGI response.
Args:
orig_request: An ApiRequest, the original request from the user.
error: A RequestError containing information about the error.
start_response: A function wi... | python | def _handle_request_error(self, orig_request, error, start_response):
"""Handle a request error, converting it to a WSGI response.
Args:
orig_request: An ApiRequest, the original request from the user.
error: A RequestError containing information about the error.
start_response: A function wi... | [
"def",
"_handle_request_error",
"(",
"self",
",",
"orig_request",
",",
"error",
",",
"start_response",
")",
":",
"headers",
"=",
"[",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
"]",
"status_code",
"=",
"error",
".",
"status_code",
"(",
")",
"body",... | Handle a request error, converting it to a WSGI response.
Args:
orig_request: An ApiRequest, the original request from the user.
error: A RequestError containing information about the error.
start_response: A function with semantics defined in PEP-333.
Returns:
A string containing the ... | [
"Handle",
"a",
"request",
"error",
"converting",
"it",
"to",
"a",
"WSGI",
"response",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/endpoints_dispatcher.py#L698-L718 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _WriteFile | def _WriteFile(output_path, name, content):
"""Write given content to a file in a given directory.
Args:
output_path: The directory to store the file in.
name: The name of the file to store the content in.
content: The content to write to the file.close
Returns:
The full path to the written file... | python | def _WriteFile(output_path, name, content):
"""Write given content to a file in a given directory.
Args:
output_path: The directory to store the file in.
name: The name of the file to store the content in.
content: The content to write to the file.close
Returns:
The full path to the written file... | [
"def",
"_WriteFile",
"(",
"output_path",
",",
"name",
",",
"content",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output_path",
",",
"name",
")",
"with",
"open",
"(",
"path",
",",
"'wb'",
")",
"as",
"f",
":",
"f",
".",
"write",
"... | Write given content to a file in a given directory.
Args:
output_path: The directory to store the file in.
name: The name of the file to store the content in.
content: The content to write to the file.close
Returns:
The full path to the written file. | [
"Write",
"given",
"content",
"to",
"a",
"file",
"in",
"a",
"given",
"directory",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L138-L152 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | GenApiConfig | def GenApiConfig(service_class_names, config_string_generator=None,
hostname=None, application_path=None, **additional_kwargs):
"""Write an API configuration for endpoints annotated ProtoRPC services.
Args:
service_class_names: A list of fully qualified ProtoRPC service classes.
config_str... | python | def GenApiConfig(service_class_names, config_string_generator=None,
hostname=None, application_path=None, **additional_kwargs):
"""Write an API configuration for endpoints annotated ProtoRPC services.
Args:
service_class_names: A list of fully qualified ProtoRPC service classes.
config_str... | [
"def",
"GenApiConfig",
"(",
"service_class_names",
",",
"config_string_generator",
"=",
"None",
",",
"hostname",
"=",
"None",
",",
"application_path",
"=",
"None",
",",
"**",
"additional_kwargs",
")",
":",
"api_service_map",
"=",
"collections",
".",
"OrderedDict",
... | Write an API configuration for endpoints annotated ProtoRPC services.
Args:
service_class_names: A list of fully qualified ProtoRPC service classes.
config_string_generator: A generator object that produces API config strings
using its pretty_print_config_to_json method.
hostname: A string hostname... | [
"Write",
"an",
"API",
"configuration",
"for",
"endpoints",
"annotated",
"ProtoRPC",
"services",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L155-L218 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _GetAppYamlHostname | def _GetAppYamlHostname(application_path, open_func=open):
"""Build the hostname for this app based on the name in app.yaml.
Args:
application_path: A string with the path to the AppEngine application. This
should be the directory containing the app.yaml file.
open_func: Function to call to open a f... | python | def _GetAppYamlHostname(application_path, open_func=open):
"""Build the hostname for this app based on the name in app.yaml.
Args:
application_path: A string with the path to the AppEngine application. This
should be the directory containing the app.yaml file.
open_func: Function to call to open a f... | [
"def",
"_GetAppYamlHostname",
"(",
"application_path",
",",
"open_func",
"=",
"open",
")",
":",
"try",
":",
"app_yaml_file",
"=",
"open_func",
"(",
"os",
".",
"path",
".",
"join",
"(",
"application_path",
"or",
"'.'",
",",
"'app.yaml'",
")",
")",
"config",
... | Build the hostname for this app based on the name in app.yaml.
Args:
application_path: A string with the path to the AppEngine application. This
should be the directory containing the app.yaml file.
open_func: Function to call to open a file. Used to override the default
open function in unit t... | [
"Build",
"the",
"hostname",
"for",
"this",
"app",
"based",
"on",
"the",
"name",
"in",
"app",
".",
"yaml",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L221-L257 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _GenDiscoveryDoc | def _GenDiscoveryDoc(service_class_names,
output_path, hostname=None,
application_path=None):
"""Write discovery documents generated from the service classes to file.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
output_path: The dire... | python | def _GenDiscoveryDoc(service_class_names,
output_path, hostname=None,
application_path=None):
"""Write discovery documents generated from the service classes to file.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
output_path: The dire... | [
"def",
"_GenDiscoveryDoc",
"(",
"service_class_names",
",",
"output_path",
",",
"hostname",
"=",
"None",
",",
"application_path",
"=",
"None",
")",
":",
"output_files",
"=",
"[",
"]",
"service_configs",
"=",
"GenApiConfig",
"(",
"service_class_names",
",",
"hostna... | Write discovery documents generated from the service classes to file.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
output_path: The directory to output the discovery docs to.
hostname: A string hostname which will be used as the default version
hostname. If no hostna... | [
"Write",
"discovery",
"documents",
"generated",
"from",
"the",
"service",
"classes",
"to",
"file",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L260-L285 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _GenOpenApiSpec | def _GenOpenApiSpec(service_class_names, output_path, hostname=None,
application_path=None, x_google_api_name=False):
"""Write openapi documents generated from the service classes to file.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
output_path: The dire... | python | def _GenOpenApiSpec(service_class_names, output_path, hostname=None,
application_path=None, x_google_api_name=False):
"""Write openapi documents generated from the service classes to file.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
output_path: The dire... | [
"def",
"_GenOpenApiSpec",
"(",
"service_class_names",
",",
"output_path",
",",
"hostname",
"=",
"None",
",",
"application_path",
"=",
"None",
",",
"x_google_api_name",
"=",
"False",
")",
":",
"output_files",
"=",
"[",
"]",
"service_configs",
"=",
"GenApiConfig",
... | Write openapi documents generated from the service classes to file.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
output_path: The directory to which to output the OpenAPI specs.
hostname: A string hostname which will be used as the default version
hostname. If no hos... | [
"Write",
"openapi",
"documents",
"generated",
"from",
"the",
"service",
"classes",
"to",
"file",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L288-L313 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _GetClientLib | def _GetClientLib(service_class_names, language, output_path, build_system,
hostname=None, application_path=None):
"""Fetch client libraries from a cloud service.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
language: The client library language to generate... | python | def _GetClientLib(service_class_names, language, output_path, build_system,
hostname=None, application_path=None):
"""Fetch client libraries from a cloud service.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
language: The client library language to generate... | [
"def",
"_GetClientLib",
"(",
"service_class_names",
",",
"language",
",",
"output_path",
",",
"build_system",
",",
"hostname",
"=",
"None",
",",
"application_path",
"=",
"None",
")",
":",
"client_libs",
"=",
"[",
"]",
"service_configs",
"=",
"GenApiConfig",
"(",... | Fetch client libraries from a cloud service.
Args:
service_class_names: A list of fully qualified ProtoRPC service names.
language: The client library language to generate. (java)
output_path: The directory to output the discovery docs to.
build_system: The target build system for the client library ... | [
"Fetch",
"client",
"libraries",
"from",
"a",
"cloud",
"service",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L374-L401 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _GenApiConfigCallback | def _GenApiConfigCallback(args, api_func=GenApiConfig):
"""Generate an api file.
Args:
args: An argparse.Namespace object to extract parameters from.
api_func: A function that generates and returns an API configuration
for a list of services.
"""
service_configs = api_func(args.service,
... | python | def _GenApiConfigCallback(args, api_func=GenApiConfig):
"""Generate an api file.
Args:
args: An argparse.Namespace object to extract parameters from.
api_func: A function that generates and returns an API configuration
for a list of services.
"""
service_configs = api_func(args.service,
... | [
"def",
"_GenApiConfigCallback",
"(",
"args",
",",
"api_func",
"=",
"GenApiConfig",
")",
":",
"service_configs",
"=",
"api_func",
"(",
"args",
".",
"service",
",",
"hostname",
"=",
"args",
".",
"hostname",
",",
"application_path",
"=",
"args",
".",
"application... | Generate an api file.
Args:
args: An argparse.Namespace object to extract parameters from.
api_func: A function that generates and returns an API configuration
for a list of services. | [
"Generate",
"an",
"api",
"file",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L404-L417 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _GetClientLibCallback | def _GetClientLibCallback(args, client_func=_GetClientLib):
"""Generate discovery docs and client libraries to files.
Args:
args: An argparse.Namespace object to extract parameters from.
client_func: A function that generates client libraries and stores them to
files, accepting a list of service name... | python | def _GetClientLibCallback(args, client_func=_GetClientLib):
"""Generate discovery docs and client libraries to files.
Args:
args: An argparse.Namespace object to extract parameters from.
client_func: A function that generates client libraries and stores them to
files, accepting a list of service name... | [
"def",
"_GetClientLibCallback",
"(",
"args",
",",
"client_func",
"=",
"_GetClientLib",
")",
":",
"client_paths",
"=",
"client_func",
"(",
"args",
".",
"service",
",",
"args",
".",
"language",
",",
"args",
".",
"output",
",",
"args",
".",
"build_system",
",",... | Generate discovery docs and client libraries to files.
Args:
args: An argparse.Namespace object to extract parameters from.
client_func: A function that generates client libraries and stores them to
files, accepting a list of service names, a client library language,
an output directory, a build ... | [
"Generate",
"discovery",
"docs",
"and",
"client",
"libraries",
"to",
"files",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L420-L435 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _GenDiscoveryDocCallback | def _GenDiscoveryDocCallback(args, discovery_func=_GenDiscoveryDoc):
"""Generate discovery docs to files.
Args:
args: An argparse.Namespace object to extract parameters from
discovery_func: A function that generates discovery docs and stores them to
files, accepting a list of service names, a discove... | python | def _GenDiscoveryDocCallback(args, discovery_func=_GenDiscoveryDoc):
"""Generate discovery docs to files.
Args:
args: An argparse.Namespace object to extract parameters from
discovery_func: A function that generates discovery docs and stores them to
files, accepting a list of service names, a discove... | [
"def",
"_GenDiscoveryDocCallback",
"(",
"args",
",",
"discovery_func",
"=",
"_GenDiscoveryDoc",
")",
":",
"discovery_paths",
"=",
"discovery_func",
"(",
"args",
".",
"service",
",",
"args",
".",
"output",
",",
"hostname",
"=",
"args",
".",
"hostname",
",",
"ap... | Generate discovery docs to files.
Args:
args: An argparse.Namespace object to extract parameters from
discovery_func: A function that generates discovery docs and stores them to
files, accepting a list of service names, a discovery doc format, and an
output directory. | [
"Generate",
"discovery",
"docs",
"to",
"files",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L438-L451 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _GenClientLibCallback | def _GenClientLibCallback(args, client_func=_GenClientLib):
"""Generate a client library to file.
Args:
args: An argparse.Namespace object to extract parameters from
client_func: A function that generates client libraries and stores them to
files, accepting a path to a discovery doc, a client library... | python | def _GenClientLibCallback(args, client_func=_GenClientLib):
"""Generate a client library to file.
Args:
args: An argparse.Namespace object to extract parameters from
client_func: A function that generates client libraries and stores them to
files, accepting a path to a discovery doc, a client library... | [
"def",
"_GenClientLibCallback",
"(",
"args",
",",
"client_func",
"=",
"_GenClientLib",
")",
":",
"client_path",
"=",
"client_func",
"(",
"args",
".",
"discovery_doc",
"[",
"0",
"]",
",",
"args",
".",
"language",
",",
"args",
".",
"output",
",",
"args",
"."... | Generate a client library to file.
Args:
args: An argparse.Namespace object to extract parameters from
client_func: A function that generates client libraries and stores them to
files, accepting a path to a discovery doc, a client library language, an
output directory, and a build system for the ... | [
"Generate",
"a",
"client",
"library",
"to",
"file",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L470-L481 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_impl.py | _EndpointsParser.error | def error(self, message):
"""Override superclass to support customized error message.
Error message needs to be rewritten in order to display visible commands
only, when invalid command is called by user. Otherwise, hidden commands
will be displayed in stderr, which is not expected.
Refer the foll... | python | def error(self, message):
"""Override superclass to support customized error message.
Error message needs to be rewritten in order to display visible commands
only, when invalid command is called by user. Otherwise, hidden commands
will be displayed in stderr, which is not expected.
Refer the foll... | [
"def",
"error",
"(",
"self",
",",
"message",
")",
":",
"subcommands_quoted",
"=",
"', '",
".",
"join",
"(",
"[",
"repr",
"(",
"command",
")",
"for",
"command",
"in",
"_VISIBLE_COMMANDS",
"]",
")",
"subcommands",
"=",
"', '",
".",
"join",
"(",
"_VISIBLE_C... | Override superclass to support customized error message.
Error message needs to be rewritten in order to display visible commands
only, when invalid command is called by user. Otherwise, hidden commands
will be displayed in stderr, which is not expected.
Refer the following argparse python documentati... | [
"Override",
"superclass",
"to",
"support",
"customized",
"error",
"message",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_impl.py#L111-L135 | train |
cloudendpoints/endpoints-python | endpoints/_endpointscfg_setup.py | _SetupPaths | def _SetupPaths():
"""Sets up the sys.path with special directories for endpointscfg.py."""
sdk_path = _FindSdkPath()
if sdk_path:
sys.path.append(sdk_path)
try:
import dev_appserver # pylint: disable=g-import-not-at-top
if hasattr(dev_appserver, 'fix_sys_path'):
dev_appserver.fix_sys... | python | def _SetupPaths():
"""Sets up the sys.path with special directories for endpointscfg.py."""
sdk_path = _FindSdkPath()
if sdk_path:
sys.path.append(sdk_path)
try:
import dev_appserver # pylint: disable=g-import-not-at-top
if hasattr(dev_appserver, 'fix_sys_path'):
dev_appserver.fix_sys... | [
"def",
"_SetupPaths",
"(",
")",
":",
"sdk_path",
"=",
"_FindSdkPath",
"(",
")",
"if",
"sdk_path",
":",
"sys",
".",
"path",
".",
"append",
"(",
"sdk_path",
")",
"try",
":",
"import",
"dev_appserver",
"if",
"hasattr",
"(",
"dev_appserver",
",",
"'fix_sys_pat... | Sets up the sys.path with special directories for endpointscfg.py. | [
"Sets",
"up",
"the",
"sys",
".",
"path",
"with",
"special",
"directories",
"for",
"endpointscfg",
".",
"py",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/_endpointscfg_setup.py#L84-L104 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | _Enum | def _Enum(docstring, *names):
"""Utility to generate enum classes used by annotations.
Args:
docstring: Docstring for the generated enum class.
*names: Enum names.
Returns:
A class that contains enum names as attributes.
"""
enums = dict(zip(names, range(len(names))))
reverse = dict((value, ke... | python | def _Enum(docstring, *names):
"""Utility to generate enum classes used by annotations.
Args:
docstring: Docstring for the generated enum class.
*names: Enum names.
Returns:
A class that contains enum names as attributes.
"""
enums = dict(zip(names, range(len(names))))
reverse = dict((value, ke... | [
"def",
"_Enum",
"(",
"docstring",
",",
"*",
"names",
")",
":",
"enums",
"=",
"dict",
"(",
"zip",
"(",
"names",
",",
"range",
"(",
"len",
"(",
"names",
")",
")",
")",
")",
"reverse",
"=",
"dict",
"(",
"(",
"value",
",",
"key",
")",
"for",
"key",... | Utility to generate enum classes used by annotations.
Args:
docstring: Docstring for the generated enum class.
*names: Enum names.
Returns:
A class that contains enum names as attributes. | [
"Utility",
"to",
"generate",
"enum",
"classes",
"used",
"by",
"annotations",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L102-L116 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | _CheckType | def _CheckType(value, check_type, name, allow_none=True):
"""Check that the type of an object is acceptable.
Args:
value: The object whose type is to be checked.
check_type: The type that the object must be an instance of.
name: Name of the object, to be placed in any error messages.
allow_none: Tr... | python | def _CheckType(value, check_type, name, allow_none=True):
"""Check that the type of an object is acceptable.
Args:
value: The object whose type is to be checked.
check_type: The type that the object must be an instance of.
name: Name of the object, to be placed in any error messages.
allow_none: Tr... | [
"def",
"_CheckType",
"(",
"value",
",",
"check_type",
",",
"name",
",",
"allow_none",
"=",
"True",
")",
":",
"if",
"value",
"is",
"None",
"and",
"allow_none",
":",
"return",
"if",
"not",
"isinstance",
"(",
"value",
",",
"check_type",
")",
":",
"raise",
... | Check that the type of an object is acceptable.
Args:
value: The object whose type is to be checked.
check_type: The type that the object must be an instance of.
name: Name of the object, to be placed in any error messages.
allow_none: True if value can be None, false if not.
Raises:
TypeError... | [
"Check",
"that",
"the",
"type",
"of",
"an",
"object",
"is",
"acceptable",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L190-L205 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | api | def api(name, version, description=None, hostname=None, audiences=None,
scopes=None, allowed_client_ids=None, canonical_name=None,
auth=None, owner_domain=None, owner_name=None, package_path=None,
frontend_limits=None, title=None, documentation=None, auth_level=None,
issuers=None, namesp... | python | def api(name, version, description=None, hostname=None, audiences=None,
scopes=None, allowed_client_ids=None, canonical_name=None,
auth=None, owner_domain=None, owner_name=None, package_path=None,
frontend_limits=None, title=None, documentation=None, auth_level=None,
issuers=None, namesp... | [
"def",
"api",
"(",
"name",
",",
"version",
",",
"description",
"=",
"None",
",",
"hostname",
"=",
"None",
",",
"audiences",
"=",
"None",
",",
"scopes",
"=",
"None",
",",
"allowed_client_ids",
"=",
"None",
",",
"canonical_name",
"=",
"None",
",",
"auth",
... | Decorate a ProtoRPC Service class for use by the framework above.
This decorator can be used to specify an API name, version, description, and
hostname for your API.
Sample usage (python 2.7):
@endpoints.api(name='guestbook', version='v0.2',
description='Guestbook API')
class PostServ... | [
"Decorate",
"a",
"ProtoRPC",
"Service",
"class",
"for",
"use",
"by",
"the",
"framework",
"above",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L988-L1077 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | method | def method(request_message=message_types.VoidMessage,
response_message=message_types.VoidMessage,
name=None,
path=None,
http_method='POST',
scopes=None,
audiences=None,
allowed_client_ids=None,
auth_level=None,
api_key_re... | python | def method(request_message=message_types.VoidMessage,
response_message=message_types.VoidMessage,
name=None,
path=None,
http_method='POST',
scopes=None,
audiences=None,
allowed_client_ids=None,
auth_level=None,
api_key_re... | [
"def",
"method",
"(",
"request_message",
"=",
"message_types",
".",
"VoidMessage",
",",
"response_message",
"=",
"message_types",
".",
"VoidMessage",
",",
"name",
"=",
"None",
",",
"path",
"=",
"None",
",",
"http_method",
"=",
"'POST'",
",",
"scopes",
"=",
"... | Decorate a ProtoRPC Method for use by the framework above.
This decorator can be used to specify a method name, path, http method,
scopes, audiences, client ids and auth_level.
Sample usage:
@api_config.method(RequestMessage, ResponseMessage,
name='insert', http_method='PUT')
def ... | [
"Decorate",
"a",
"ProtoRPC",
"Method",
"for",
"use",
"by",
"the",
"framework",
"above",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1257-L1379 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | _ApiInfo.is_same_api | def is_same_api(self, other):
"""Check if this implements the same API as another _ApiInfo instance."""
if not isinstance(other, _ApiInfo):
return False
# pylint: disable=protected-access
return self.__common_info is other.__common_info | python | def is_same_api(self, other):
"""Check if this implements the same API as another _ApiInfo instance."""
if not isinstance(other, _ApiInfo):
return False
# pylint: disable=protected-access
return self.__common_info is other.__common_info | [
"def",
"is_same_api",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"_ApiInfo",
")",
":",
"return",
"False",
"return",
"self",
".",
"__common_info",
"is",
"other",
".",
"__common_info"
] | Check if this implements the same API as another _ApiInfo instance. | [
"Check",
"if",
"this",
"implements",
"the",
"same",
"API",
"as",
"another",
"_ApiInfo",
"instance",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L307-L312 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | _ApiDecorator.api_class | def api_class(self, resource_name=None, path=None, audiences=None,
scopes=None, allowed_client_ids=None, auth_level=None,
api_key_required=None):
"""Get a decorator for a class that implements an API.
This can be used for single-class or multi-class implementations. It's
us... | python | def api_class(self, resource_name=None, path=None, audiences=None,
scopes=None, allowed_client_ids=None, auth_level=None,
api_key_required=None):
"""Get a decorator for a class that implements an API.
This can be used for single-class or multi-class implementations. It's
us... | [
"def",
"api_class",
"(",
"self",
",",
"resource_name",
"=",
"None",
",",
"path",
"=",
"None",
",",
"audiences",
"=",
"None",
",",
"scopes",
"=",
"None",
",",
"allowed_client_ids",
"=",
"None",
",",
"auth_level",
"=",
"None",
",",
"api_key_required",
"=",
... | Get a decorator for a class that implements an API.
This can be used for single-class or multi-class implementations. It's
used implicitly in simple single-class APIs that only use @api directly.
Args:
resource_name: string, Resource name for the class this decorates.
(Default: None)
... | [
"Get",
"a",
"decorator",
"for",
"a",
"class",
"that",
"implements",
"an",
"API",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L795-L842 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | _MethodInfo.__safe_name | def __safe_name(self, method_name):
"""Restrict method name to a-zA-Z0-9_, first char lowercase."""
# Endpoints backend restricts what chars are allowed in a method name.
safe_name = re.sub(r'[^\.a-zA-Z0-9_]', '', method_name)
# Strip any number of leading underscores.
safe_name = safe_name.lstrip(... | python | def __safe_name(self, method_name):
"""Restrict method name to a-zA-Z0-9_, first char lowercase."""
# Endpoints backend restricts what chars are allowed in a method name.
safe_name = re.sub(r'[^\.a-zA-Z0-9_]', '', method_name)
# Strip any number of leading underscores.
safe_name = safe_name.lstrip(... | [
"def",
"__safe_name",
"(",
"self",
",",
"method_name",
")",
":",
"safe_name",
"=",
"re",
".",
"sub",
"(",
"r'[^\\.a-zA-Z0-9_]'",
",",
"''",
",",
"method_name",
")",
"safe_name",
"=",
"safe_name",
".",
"lstrip",
"(",
"'_'",
")",
"return",
"safe_name",
"[",
... | Restrict method name to a-zA-Z0-9_, first char lowercase. | [
"Restrict",
"method",
"name",
"to",
"a",
"-",
"zA",
"-",
"Z0",
"-",
"9_",
"first",
"char",
"lowercase",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1126-L1136 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | _MethodInfo.method_id | def method_id(self, api_info):
"""Computed method name."""
# This is done here for now because at __init__ time, the method is known
# but not the api, and thus not the api name. Later, in
# ApiConfigGenerator.__method_descriptor, the api name is known.
if api_info.resource_name:
resource_par... | python | def method_id(self, api_info):
"""Computed method name."""
# This is done here for now because at __init__ time, the method is known
# but not the api, and thus not the api name. Later, in
# ApiConfigGenerator.__method_descriptor, the api name is known.
if api_info.resource_name:
resource_par... | [
"def",
"method_id",
"(",
"self",
",",
"api_info",
")",
":",
"if",
"api_info",
".",
"resource_name",
":",
"resource_part",
"=",
"'.%s'",
"%",
"self",
".",
"__safe_name",
"(",
"api_info",
".",
"resource_name",
")",
"else",
":",
"resource_part",
"=",
"''",
"r... | Computed method name. | [
"Computed",
"method",
"name",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1243-L1253 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__field_to_subfields | def __field_to_subfields(self, field):
"""Fully describes data represented by field, including the nested case.
In the case that the field is not a message field, we have no fields nested
within a message definition, so we can simply return that field. However, in
the nested case, we can't simply descr... | python | def __field_to_subfields(self, field):
"""Fully describes data represented by field, including the nested case.
In the case that the field is not a message field, we have no fields nested
within a message definition, so we can simply return that field. However, in
the nested case, we can't simply descr... | [
"def",
"__field_to_subfields",
"(",
"self",
",",
"field",
")",
":",
"if",
"not",
"isinstance",
"(",
"field",
",",
"messages",
".",
"MessageField",
")",
":",
"return",
"[",
"[",
"field",
"]",
"]",
"result",
"=",
"[",
"]",
"for",
"subfield",
"in",
"sorte... | Fully describes data represented by field, including the nested case.
In the case that the field is not a message field, we have no fields nested
within a message definition, so we can simply return that field. However, in
the nested case, we can't simply describe the data with one field or even
with o... | [
"Fully",
"describes",
"data",
"represented",
"by",
"field",
"including",
"the",
"nested",
"case",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1438-L1503 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__field_to_parameter_type | def __field_to_parameter_type(self, field):
"""Converts the field variant type into a string describing the parameter.
Args:
field: An instance of a subclass of messages.Field.
Returns:
A string corresponding to the variant enum of the field, with a few
exceptions. In the case of signe... | python | def __field_to_parameter_type(self, field):
"""Converts the field variant type into a string describing the parameter.
Args:
field: An instance of a subclass of messages.Field.
Returns:
A string corresponding to the variant enum of the field, with a few
exceptions. In the case of signe... | [
"def",
"__field_to_parameter_type",
"(",
"self",
",",
"field",
")",
":",
"variant",
"=",
"field",
".",
"variant",
"if",
"variant",
"==",
"messages",
".",
"Variant",
".",
"MESSAGE",
":",
"raise",
"TypeError",
"(",
"'A message variant can\\'t be used in a parameter.'"... | Converts the field variant type into a string describing the parameter.
Args:
field: An instance of a subclass of messages.Field.
Returns:
A string corresponding to the variant enum of the field, with a few
exceptions. In the case of signed ints, the 's' is dropped; for the BOOL
va... | [
"Converts",
"the",
"field",
"variant",
"type",
"into",
"a",
"string",
"describing",
"the",
"parameter",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1507-L1532 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__get_path_parameters | def __get_path_parameters(self, path):
"""Parses path paremeters from a URI path and organizes them by parameter.
Some of the parameters may correspond to message fields, and so will be
represented as segments corresponding to each subfield; e.g. first.second if
the field "second" in the message field ... | python | def __get_path_parameters(self, path):
"""Parses path paremeters from a URI path and organizes them by parameter.
Some of the parameters may correspond to message fields, and so will be
represented as segments corresponding to each subfield; e.g. first.second if
the field "second" in the message field ... | [
"def",
"__get_path_parameters",
"(",
"self",
",",
"path",
")",
":",
"path_parameters_by_segment",
"=",
"{",
"}",
"for",
"format_var_name",
"in",
"re",
".",
"findall",
"(",
"_PATH_VARIABLE_PATTERN",
",",
"path",
")",
":",
"first_segment",
"=",
"format_var_name",
... | Parses path paremeters from a URI path and organizes them by parameter.
Some of the parameters may correspond to message fields, and so will be
represented as segments corresponding to each subfield; e.g. first.second if
the field "second" in the message field "first" is pulled from the path.
The resu... | [
"Parses",
"path",
"paremeters",
"from",
"a",
"URI",
"path",
"and",
"organizes",
"them",
"by",
"parameter",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1534-L1559 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__validate_simple_subfield | def __validate_simple_subfield(self, parameter, field, segment_list,
_segment_index=0):
"""Verifies that a proposed subfield actually exists and is a simple field.
Here, simple means it is not a MessageField (nested).
Args:
parameter: String; the '.' delimited name o... | python | def __validate_simple_subfield(self, parameter, field, segment_list,
_segment_index=0):
"""Verifies that a proposed subfield actually exists and is a simple field.
Here, simple means it is not a MessageField (nested).
Args:
parameter: String; the '.' delimited name o... | [
"def",
"__validate_simple_subfield",
"(",
"self",
",",
"parameter",
",",
"field",
",",
"segment_list",
",",
"_segment_index",
"=",
"0",
")",
":",
"if",
"_segment_index",
">=",
"len",
"(",
"segment_list",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"mess... | Verifies that a proposed subfield actually exists and is a simple field.
Here, simple means it is not a MessageField (nested).
Args:
parameter: String; the '.' delimited name of the current field being
considered. This is relative to some root.
field: An instance of a subclass of message... | [
"Verifies",
"that",
"a",
"proposed",
"subfield",
"actually",
"exists",
"and",
"is",
"a",
"simple",
"field",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1561-L1604 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__validate_path_parameters | def __validate_path_parameters(self, field, path_parameters):
"""Verifies that all path parameters correspond to an existing subfield.
Args:
field: An instance of a subclass of messages.Field. Should be the root
level property name in each path parameter in path_parameters. For
exampl... | python | def __validate_path_parameters(self, field, path_parameters):
"""Verifies that all path parameters correspond to an existing subfield.
Args:
field: An instance of a subclass of messages.Field. Should be the root
level property name in each path parameter in path_parameters. For
exampl... | [
"def",
"__validate_path_parameters",
"(",
"self",
",",
"field",
",",
"path_parameters",
")",
":",
"for",
"param",
"in",
"path_parameters",
":",
"segment_list",
"=",
"param",
".",
"split",
"(",
"'.'",
")",
"if",
"segment_list",
"[",
"0",
"]",
"!=",
"field",
... | Verifies that all path parameters correspond to an existing subfield.
Args:
field: An instance of a subclass of messages.Field. Should be the root
level property name in each path parameter in path_parameters. For
example, if the field is called 'foo', then each path parameter should
... | [
"Verifies",
"that",
"all",
"path",
"parameters",
"correspond",
"to",
"an",
"existing",
"subfield",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1606-L1624 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__parameter_default | def __parameter_default(self, final_subfield):
"""Returns default value of final subfield if it has one.
If this subfield comes from a field list returned from __field_to_subfields,
none of the fields in the subfield list can have a default except the final
one since they all must be message fields.
... | python | def __parameter_default(self, final_subfield):
"""Returns default value of final subfield if it has one.
If this subfield comes from a field list returned from __field_to_subfields,
none of the fields in the subfield list can have a default except the final
one since they all must be message fields.
... | [
"def",
"__parameter_default",
"(",
"self",
",",
"final_subfield",
")",
":",
"if",
"final_subfield",
".",
"default",
":",
"if",
"isinstance",
"(",
"final_subfield",
",",
"messages",
".",
"EnumField",
")",
":",
"return",
"final_subfield",
".",
"default",
".",
"n... | Returns default value of final subfield if it has one.
If this subfield comes from a field list returned from __field_to_subfields,
none of the fields in the subfield list can have a default except the final
one since they all must be message fields.
Args:
final_subfield: A simple field from the... | [
"Returns",
"default",
"value",
"of",
"final",
"subfield",
"if",
"it",
"has",
"one",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1626-L1644 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__parameter_enum | def __parameter_enum(self, final_subfield):
"""Returns enum descriptor of final subfield if it is an enum.
An enum descriptor is a dictionary with keys as the names from the enum and
each value is a dictionary with a single key "backendValue" and value equal
to the same enum name used to stored it in t... | python | def __parameter_enum(self, final_subfield):
"""Returns enum descriptor of final subfield if it is an enum.
An enum descriptor is a dictionary with keys as the names from the enum and
each value is a dictionary with a single key "backendValue" and value equal
to the same enum name used to stored it in t... | [
"def",
"__parameter_enum",
"(",
"self",
",",
"final_subfield",
")",
":",
"if",
"isinstance",
"(",
"final_subfield",
",",
"messages",
".",
"EnumField",
")",
":",
"enum_descriptor",
"=",
"{",
"}",
"for",
"enum_value",
"in",
"final_subfield",
".",
"type",
".",
... | Returns enum descriptor of final subfield if it is an enum.
An enum descriptor is a dictionary with keys as the names from the enum and
each value is a dictionary with a single key "backendValue" and value equal
to the same enum name used to stored it in the descriptor.
The key "description" can also ... | [
"Returns",
"enum",
"descriptor",
"of",
"final",
"subfield",
"if",
"it",
"is",
"an",
"enum",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1646-L1667 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__parameter_descriptor | def __parameter_descriptor(self, subfield_list):
"""Creates descriptor for a parameter using the subfields that define it.
Each parameter is defined by a list of fields, with all but the last being
a message field and the final being a simple (non-message) field.
Many of the fields in the descriptor a... | python | def __parameter_descriptor(self, subfield_list):
"""Creates descriptor for a parameter using the subfields that define it.
Each parameter is defined by a list of fields, with all but the last being
a message field and the final being a simple (non-message) field.
Many of the fields in the descriptor a... | [
"def",
"__parameter_descriptor",
"(",
"self",
",",
"subfield_list",
")",
":",
"descriptor",
"=",
"{",
"}",
"final_subfield",
"=",
"subfield_list",
"[",
"-",
"1",
"]",
"if",
"all",
"(",
"subfield",
".",
"required",
"for",
"subfield",
"in",
"subfield_list",
")... | Creates descriptor for a parameter using the subfields that define it.
Each parameter is defined by a list of fields, with all but the last being
a message field and the final being a simple (non-message) field.
Many of the fields in the descriptor are determined solely by the simple
field at the end,... | [
"Creates",
"descriptor",
"for",
"a",
"parameter",
"using",
"the",
"subfields",
"that",
"define",
"it",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1669-L1710 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__schema_descriptor | def __schema_descriptor(self, services):
"""Descriptor for the all the JSON Schema used.
Args:
services: List of protorpc.remote.Service instances implementing an
api/version.
Returns:
Dictionary containing all the JSON Schema used in the service.
"""
methods_desc = {}
for... | python | def __schema_descriptor(self, services):
"""Descriptor for the all the JSON Schema used.
Args:
services: List of protorpc.remote.Service instances implementing an
api/version.
Returns:
Dictionary containing all the JSON Schema used in the service.
"""
methods_desc = {}
for... | [
"def",
"__schema_descriptor",
"(",
"self",
",",
"services",
")",
":",
"methods_desc",
"=",
"{",
"}",
"for",
"service",
"in",
"services",
":",
"protorpc_methods",
"=",
"service",
".",
"all_remote_methods",
"(",
")",
"for",
"protorpc_method_name",
"in",
"protorpc_... | Descriptor for the all the JSON Schema used.
Args:
services: List of protorpc.remote.Service instances implementing an
api/version.
Returns:
Dictionary containing all the JSON Schema used in the service. | [
"Descriptor",
"for",
"the",
"all",
"the",
"JSON",
"Schema",
"used",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L1960-L1999 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__auth_descriptor | def __auth_descriptor(self, api_info):
"""Builds an auth descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A dictionary with 'allowCookieAuth' and/or 'blockedRegions' keys.
"""
if api_info.auth is None:
return None
auth_descriptor = {}
if api_info.au... | python | def __auth_descriptor(self, api_info):
"""Builds an auth descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A dictionary with 'allowCookieAuth' and/or 'blockedRegions' keys.
"""
if api_info.auth is None:
return None
auth_descriptor = {}
if api_info.au... | [
"def",
"__auth_descriptor",
"(",
"self",
",",
"api_info",
")",
":",
"if",
"api_info",
".",
"auth",
"is",
"None",
":",
"return",
"None",
"auth_descriptor",
"=",
"{",
"}",
"if",
"api_info",
".",
"auth",
".",
"allow_cookie_auth",
"is",
"not",
"None",
":",
"... | Builds an auth descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A dictionary with 'allowCookieAuth' and/or 'blockedRegions' keys. | [
"Builds",
"an",
"auth",
"descriptor",
"from",
"API",
"info",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L2028-L2046 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__frontend_limit_descriptor | def __frontend_limit_descriptor(self, api_info):
"""Builds a frontend limit descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A dictionary with frontend limit information.
"""
if api_info.frontend_limits is None:
return None
descriptor = {}
for propn... | python | def __frontend_limit_descriptor(self, api_info):
"""Builds a frontend limit descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A dictionary with frontend limit information.
"""
if api_info.frontend_limits is None:
return None
descriptor = {}
for propn... | [
"def",
"__frontend_limit_descriptor",
"(",
"self",
",",
"api_info",
")",
":",
"if",
"api_info",
".",
"frontend_limits",
"is",
"None",
":",
"return",
"None",
"descriptor",
"=",
"{",
"}",
"for",
"propname",
",",
"descname",
"in",
"(",
"(",
"'unregistered_user_qp... | Builds a frontend limit descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A dictionary with frontend limit information. | [
"Builds",
"a",
"frontend",
"limit",
"descriptor",
"from",
"API",
"info",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L2048-L2071 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.__frontend_limit_rules_descriptor | def __frontend_limit_rules_descriptor(self, api_info):
"""Builds a frontend limit rules descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A list of dictionaries with frontend limit rules information.
"""
if not api_info.frontend_limits.rules:
return None
... | python | def __frontend_limit_rules_descriptor(self, api_info):
"""Builds a frontend limit rules descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A list of dictionaries with frontend limit rules information.
"""
if not api_info.frontend_limits.rules:
return None
... | [
"def",
"__frontend_limit_rules_descriptor",
"(",
"self",
",",
"api_info",
")",
":",
"if",
"not",
"api_info",
".",
"frontend_limits",
".",
"rules",
":",
"return",
"None",
"rules",
"=",
"[",
"]",
"for",
"rule",
"in",
"api_info",
".",
"frontend_limits",
".",
"r... | Builds a frontend limit rules descriptor from API info.
Args:
api_info: An _ApiInfo object.
Returns:
A list of dictionaries with frontend limit rules information. | [
"Builds",
"a",
"frontend",
"limit",
"rules",
"descriptor",
"from",
"API",
"info",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L2073-L2098 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.get_config_dict | def get_config_dict(self, services, hostname=None):
"""JSON dict description of a protorpc.remote.Service in API format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override the value set... | python | def get_config_dict(self, services, hostname=None):
"""JSON dict description of a protorpc.remote.Service in API format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override the value set... | [
"def",
"get_config_dict",
"(",
"self",
",",
"services",
",",
"hostname",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"services",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"services",
"=",
"[",
"services",
"]",
"endpoints_util",
".",
"ch... | JSON dict description of a protorpc.remote.Service in API format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override the value set on the
current service. Defaults to None.
Ret... | [
"JSON",
"dict",
"description",
"of",
"a",
"protorpc",
".",
"remote",
".",
"Service",
"in",
"API",
"format",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L2226-L2246 | train |
cloudendpoints/endpoints-python | endpoints/api_config.py | ApiConfigGenerator.pretty_print_config_to_json | def pretty_print_config_to_json(self, services, hostname=None):
"""JSON string description of a protorpc.remote.Service in API format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override... | python | def pretty_print_config_to_json(self, services, hostname=None):
"""JSON string description of a protorpc.remote.Service in API format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override... | [
"def",
"pretty_print_config_to_json",
"(",
"self",
",",
"services",
",",
"hostname",
"=",
"None",
")",
":",
"descriptor",
"=",
"self",
".",
"get_config_dict",
"(",
"services",
",",
"hostname",
")",
"return",
"json",
".",
"dumps",
"(",
"descriptor",
",",
"sor... | JSON string description of a protorpc.remote.Service in API format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override the value set on the
current service. Defaults to None.
R... | [
"JSON",
"string",
"description",
"of",
"a",
"protorpc",
".",
"remote",
".",
"Service",
"in",
"API",
"format",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_config.py#L2248-L2262 | train |
cloudendpoints/endpoints-python | endpoints/discovery_generator.py | DiscoveryGenerator.__parameter_enum | def __parameter_enum(self, param):
"""Returns enum descriptor of a parameter if it is an enum.
An enum descriptor is a list of keys.
Args:
param: A simple field.
Returns:
The enum descriptor for the field, if it's an enum descriptor, else
returns None.
"""
if isinstance(... | python | def __parameter_enum(self, param):
"""Returns enum descriptor of a parameter if it is an enum.
An enum descriptor is a list of keys.
Args:
param: A simple field.
Returns:
The enum descriptor for the field, if it's an enum descriptor, else
returns None.
"""
if isinstance(... | [
"def",
"__parameter_enum",
"(",
"self",
",",
"param",
")",
":",
"if",
"isinstance",
"(",
"param",
",",
"messages",
".",
"EnumField",
")",
":",
"return",
"[",
"enum_entry",
"[",
"0",
"]",
"for",
"enum_entry",
"in",
"sorted",
"(",
"param",
".",
"type",
"... | Returns enum descriptor of a parameter if it is an enum.
An enum descriptor is a list of keys.
Args:
param: A simple field.
Returns:
The enum descriptor for the field, if it's an enum descriptor, else
returns None. | [
"Returns",
"enum",
"descriptor",
"of",
"a",
"parameter",
"if",
"it",
"is",
"an",
"enum",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_generator.py#L332-L346 | train |
cloudendpoints/endpoints-python | endpoints/discovery_generator.py | DiscoveryGenerator.__params_order_descriptor | def __params_order_descriptor(self, message_type, path, is_params_class=False):
"""Describe the order of path parameters.
Args:
message_type: messages.Message class, Message with parameters to describe.
path: string, HTTP path to method.
is_params_class: boolean, Whether the message represent... | python | def __params_order_descriptor(self, message_type, path, is_params_class=False):
"""Describe the order of path parameters.
Args:
message_type: messages.Message class, Message with parameters to describe.
path: string, HTTP path to method.
is_params_class: boolean, Whether the message represent... | [
"def",
"__params_order_descriptor",
"(",
"self",
",",
"message_type",
",",
"path",
",",
"is_params_class",
"=",
"False",
")",
":",
"path_params",
"=",
"[",
"]",
"query_params",
"=",
"[",
"]",
"path_parameter_dict",
"=",
"self",
".",
"__get_path_parameters",
"(",... | Describe the order of path parameters.
Args:
message_type: messages.Message class, Message with parameters to describe.
path: string, HTTP path to method.
is_params_class: boolean, Whether the message represents URL parameters.
Returns:
Descriptor list for the parameter order. | [
"Describe",
"the",
"order",
"of",
"path",
"parameters",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_generator.py#L514-L545 | train |
cloudendpoints/endpoints-python | endpoints/discovery_generator.py | DiscoveryGenerator.__schemas_descriptor | def __schemas_descriptor(self):
"""Describes the schemas section of the discovery document.
Returns:
Dictionary describing the schemas of the document.
"""
# Filter out any keys that aren't 'properties', 'type', or 'id'
result = {}
for schema_key, schema_value in self.__parser.schemas().i... | python | def __schemas_descriptor(self):
"""Describes the schemas section of the discovery document.
Returns:
Dictionary describing the schemas of the document.
"""
# Filter out any keys that aren't 'properties', 'type', or 'id'
result = {}
for schema_key, schema_value in self.__parser.schemas().i... | [
"def",
"__schemas_descriptor",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"for",
"schema_key",
",",
"schema_value",
"in",
"self",
".",
"__parser",
".",
"schemas",
"(",
")",
".",
"iteritems",
"(",
")",
":",
"field_keys",
"=",
"schema_value",
".",
"ke... | Describes the schemas section of the discovery document.
Returns:
Dictionary describing the schemas of the document. | [
"Describes",
"the",
"schemas",
"section",
"of",
"the",
"discovery",
"document",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_generator.py#L547-L591 | train |
cloudendpoints/endpoints-python | endpoints/discovery_generator.py | DiscoveryGenerator.__resource_descriptor | def __resource_descriptor(self, resource_path, methods):
"""Describes a resource.
Args:
resource_path: string, the path of the resource (e.g., 'entries.items')
methods: list of tuples of type
(endpoints.Service, protorpc.remote._RemoteMethodInfo), the methods
that serve this resourc... | python | def __resource_descriptor(self, resource_path, methods):
"""Describes a resource.
Args:
resource_path: string, the path of the resource (e.g., 'entries.items')
methods: list of tuples of type
(endpoints.Service, protorpc.remote._RemoteMethodInfo), the methods
that serve this resourc... | [
"def",
"__resource_descriptor",
"(",
"self",
",",
"resource_path",
",",
"methods",
")",
":",
"descriptor",
"=",
"{",
"}",
"method_map",
"=",
"{",
"}",
"sub_resource_index",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"sub_resource_map",
"=",
"{",... | Describes a resource.
Args:
resource_path: string, the path of the resource (e.g., 'entries.items')
methods: list of tuples of type
(endpoints.Service, protorpc.remote._RemoteMethodInfo), the methods
that serve this resource.
Returns:
Dictionary describing the resource. | [
"Describes",
"a",
"resource",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_generator.py#L706-L766 | train |
cloudendpoints/endpoints-python | endpoints/discovery_generator.py | DiscoveryGenerator.__discovery_doc_descriptor | def __discovery_doc_descriptor(self, services, hostname=None):
"""Builds a discovery doc for an API.
Args:
services: List of protorpc.remote.Service instances implementing an
api/version.
hostname: string, Hostname of the API, to override the value set on the
current service. Defaul... | python | def __discovery_doc_descriptor(self, services, hostname=None):
"""Builds a discovery doc for an API.
Args:
services: List of protorpc.remote.Service instances implementing an
api/version.
hostname: string, Hostname of the API, to override the value set on the
current service. Defaul... | [
"def",
"__discovery_doc_descriptor",
"(",
"self",
",",
"services",
",",
"hostname",
"=",
"None",
")",
":",
"merged_api_info",
"=",
"self",
".",
"__get_merged_api_info",
"(",
"services",
")",
"descriptor",
"=",
"self",
".",
"get_descriptor_defaults",
"(",
"merged_a... | Builds a discovery doc for an API.
Args:
services: List of protorpc.remote.Service instances implementing an
api/version.
hostname: string, Hostname of the API, to override the value set on the
current service. Defaults to None.
Returns:
A dictionary that can be deserialized ... | [
"Builds",
"a",
"discovery",
"doc",
"for",
"an",
"API",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_generator.py#L855-L964 | train |
cloudendpoints/endpoints-python | endpoints/discovery_generator.py | DiscoveryGenerator.get_discovery_doc | def get_discovery_doc(self, services, hostname=None):
"""JSON dict description of a protorpc.remote.Service in discovery format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override the v... | python | def get_discovery_doc(self, services, hostname=None):
"""JSON dict description of a protorpc.remote.Service in discovery format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override the v... | [
"def",
"get_discovery_doc",
"(",
"self",
",",
"services",
",",
"hostname",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"services",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"services",
"=",
"[",
"services",
"]",
"util",
".",
"check_list... | JSON dict description of a protorpc.remote.Service in discovery format.
Args:
services: Either a single protorpc.remote.Service or a list of them
that implements an api/version.
hostname: string, Hostname of the API, to override the value set on the
current service. Defaults to None.
... | [
"JSON",
"dict",
"description",
"of",
"a",
"protorpc",
".",
"remote",
".",
"Service",
"in",
"discovery",
"format",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_generator.py#L1019-L1041 | train |
cloudendpoints/endpoints-python | endpoints/util.py | send_wsgi_response | def send_wsgi_response(status, headers, content, start_response,
cors_handler=None):
"""Dump reformatted response to CGI start_response.
This calls start_response and returns the response body.
Args:
status: A string containing the HTTP status code to send.
headers: A list of (hea... | python | def send_wsgi_response(status, headers, content, start_response,
cors_handler=None):
"""Dump reformatted response to CGI start_response.
This calls start_response and returns the response body.
Args:
status: A string containing the HTTP status code to send.
headers: A list of (hea... | [
"def",
"send_wsgi_response",
"(",
"status",
",",
"headers",
",",
"content",
",",
"start_response",
",",
"cors_handler",
"=",
"None",
")",
":",
"if",
"cors_handler",
":",
"cors_handler",
".",
"update_headers",
"(",
"headers",
")",
"content_len",
"=",
"len",
"("... | Dump reformatted response to CGI start_response.
This calls start_response and returns the response body.
Args:
status: A string containing the HTTP status code to send.
headers: A list of (header, value) tuples, the headers to send in the
response.
content: A string containing the body content ... | [
"Dump",
"reformatted",
"response",
"to",
"CGI",
"start_response",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L115-L143 | train |
cloudendpoints/endpoints-python | endpoints/util.py | get_headers_from_environ | def get_headers_from_environ(environ):
"""Get a wsgiref.headers.Headers object with headers from the environment.
Headers in environ are prefixed with 'HTTP_', are all uppercase, and have
had dashes replaced with underscores. This strips the HTTP_ prefix and
changes underscores back to dashes before adding th... | python | def get_headers_from_environ(environ):
"""Get a wsgiref.headers.Headers object with headers from the environment.
Headers in environ are prefixed with 'HTTP_', are all uppercase, and have
had dashes replaced with underscores. This strips the HTTP_ prefix and
changes underscores back to dashes before adding th... | [
"def",
"get_headers_from_environ",
"(",
"environ",
")",
":",
"headers",
"=",
"wsgiref",
".",
"headers",
".",
"Headers",
"(",
"[",
"]",
")",
"for",
"header",
",",
"value",
"in",
"environ",
".",
"iteritems",
"(",
")",
":",
"if",
"header",
".",
"startswith"... | Get a wsgiref.headers.Headers object with headers from the environment.
Headers in environ are prefixed with 'HTTP_', are all uppercase, and have
had dashes replaced with underscores. This strips the HTTP_ prefix and
changes underscores back to dashes before adding them to the returned set
of headers.
Args... | [
"Get",
"a",
"wsgiref",
".",
"headers",
".",
"Headers",
"object",
"with",
"headers",
"from",
"the",
"environment",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L146-L168 | train |
cloudendpoints/endpoints-python | endpoints/util.py | put_headers_in_environ | def put_headers_in_environ(headers, environ):
"""Given a list of headers, put them into environ based on PEP-333.
This converts headers to uppercase, prefixes them with 'HTTP_', and
converts dashes to underscores before adding them to the environ dict.
Args:
headers: A list of (header, value) tuples. The... | python | def put_headers_in_environ(headers, environ):
"""Given a list of headers, put them into environ based on PEP-333.
This converts headers to uppercase, prefixes them with 'HTTP_', and
converts dashes to underscores before adding them to the environ dict.
Args:
headers: A list of (header, value) tuples. The... | [
"def",
"put_headers_in_environ",
"(",
"headers",
",",
"environ",
")",
":",
"for",
"key",
",",
"value",
"in",
"headers",
":",
"environ",
"[",
"'HTTP_%s'",
"%",
"key",
".",
"upper",
"(",
")",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
"]",
"=",
"valu... | Given a list of headers, put them into environ based on PEP-333.
This converts headers to uppercase, prefixes them with 'HTTP_', and
converts dashes to underscores before adding them to the environ dict.
Args:
headers: A list of (header, value) tuples. The HTTP headers to add to the
environment.
... | [
"Given",
"a",
"list",
"of",
"headers",
"put",
"them",
"into",
"environ",
"based",
"on",
"PEP",
"-",
"333",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L171-L183 | train |
cloudendpoints/endpoints-python | endpoints/util.py | get_hostname_prefix | def get_hostname_prefix():
"""Returns the hostname prefix of a running Endpoints service.
The prefix is the portion of the hostname that comes before the API name.
For example, if a non-default version and a non-default service are in use,
the returned result would be '{VERSION}-dot-{SERVICE}-'.
Returns:
... | python | def get_hostname_prefix():
"""Returns the hostname prefix of a running Endpoints service.
The prefix is the portion of the hostname that comes before the API name.
For example, if a non-default version and a non-default service are in use,
the returned result would be '{VERSION}-dot-{SERVICE}-'.
Returns:
... | [
"def",
"get_hostname_prefix",
"(",
")",
":",
"parts",
"=",
"[",
"]",
"version",
"=",
"modules",
".",
"get_current_version_name",
"(",
")",
"default_version",
"=",
"modules",
".",
"get_default_version",
"(",
")",
"if",
"version",
"!=",
"default_version",
":",
"... | Returns the hostname prefix of a running Endpoints service.
The prefix is the portion of the hostname that comes before the API name.
For example, if a non-default version and a non-default service are in use,
the returned result would be '{VERSION}-dot-{SERVICE}-'.
Returns:
str, the hostname prefix. | [
"Returns",
"the",
"hostname",
"prefix",
"of",
"a",
"running",
"Endpoints",
"service",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L200-L228 | train |
cloudendpoints/endpoints-python | endpoints/util.py | get_app_hostname | def get_app_hostname():
"""Return hostname of a running Endpoints service.
Returns hostname of an running Endpoints API. It can be 1) "localhost:PORT"
if running on development server, or 2) "app_id.appspot.com" if running on
external app engine prod, or "app_id.googleplex.com" if running as Google
first-par... | python | def get_app_hostname():
"""Return hostname of a running Endpoints service.
Returns hostname of an running Endpoints API. It can be 1) "localhost:PORT"
if running on development server, or 2) "app_id.appspot.com" if running on
external app engine prod, or "app_id.googleplex.com" if running as Google
first-par... | [
"def",
"get_app_hostname",
"(",
")",
":",
"if",
"not",
"is_running_on_app_engine",
"(",
")",
"or",
"is_running_on_localhost",
"(",
")",
":",
"return",
"None",
"app_id",
"=",
"app_identity",
".",
"get_application_id",
"(",
")",
"prefix",
"=",
"get_hostname_prefix",... | Return hostname of a running Endpoints service.
Returns hostname of an running Endpoints API. It can be 1) "localhost:PORT"
if running on development server, or 2) "app_id.appspot.com" if running on
external app engine prod, or "app_id.googleplex.com" if running as Google
first-party Endpoints API, or 4) None ... | [
"Return",
"hostname",
"of",
"a",
"running",
"Endpoints",
"service",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L231-L259 | train |
cloudendpoints/endpoints-python | endpoints/util.py | check_list_type | def check_list_type(objects, allowed_type, name, allow_none=True):
"""Verify that objects in list are of the allowed type or raise TypeError.
Args:
objects: The list of objects to check.
allowed_type: The allowed type of items in 'settings'.
name: Name of the list of objects, added to the exception.
... | python | def check_list_type(objects, allowed_type, name, allow_none=True):
"""Verify that objects in list are of the allowed type or raise TypeError.
Args:
objects: The list of objects to check.
allowed_type: The allowed type of items in 'settings'.
name: Name of the list of objects, added to the exception.
... | [
"def",
"check_list_type",
"(",
"objects",
",",
"allowed_type",
",",
"name",
",",
"allow_none",
"=",
"True",
")",
":",
"if",
"objects",
"is",
"None",
":",
"if",
"not",
"allow_none",
":",
"raise",
"TypeError",
"(",
"'%s is None, which is not allowed.'",
"%",
"na... | Verify that objects in list are of the allowed type or raise TypeError.
Args:
objects: The list of objects to check.
allowed_type: The allowed type of items in 'settings'.
name: Name of the list of objects, added to the exception.
allow_none: If set, None is also allowed.
Raises:
TypeError: if... | [
"Verify",
"that",
"objects",
"in",
"list",
"are",
"of",
"the",
"allowed",
"type",
"or",
"raise",
"TypeError",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L262-L287 | train |
cloudendpoints/endpoints-python | endpoints/util.py | snake_case_to_headless_camel_case | def snake_case_to_headless_camel_case(snake_string):
"""Convert snake_case to headlessCamelCase.
Args:
snake_string: The string to be converted.
Returns:
The input string converted to headlessCamelCase.
"""
return ''.join([snake_string.split('_')[0]] +
list(sub_string.capitalize()
... | python | def snake_case_to_headless_camel_case(snake_string):
"""Convert snake_case to headlessCamelCase.
Args:
snake_string: The string to be converted.
Returns:
The input string converted to headlessCamelCase.
"""
return ''.join([snake_string.split('_')[0]] +
list(sub_string.capitalize()
... | [
"def",
"snake_case_to_headless_camel_case",
"(",
"snake_string",
")",
":",
"return",
"''",
".",
"join",
"(",
"[",
"snake_string",
".",
"split",
"(",
"'_'",
")",
"[",
"0",
"]",
"]",
"+",
"list",
"(",
"sub_string",
".",
"capitalize",
"(",
")",
"for",
"sub_... | Convert snake_case to headlessCamelCase.
Args:
snake_string: The string to be converted.
Returns:
The input string converted to headlessCamelCase. | [
"Convert",
"snake_case",
"to",
"headlessCamelCase",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L290-L300 | train |
cloudendpoints/endpoints-python | endpoints/util.py | StartResponseProxy.Proxy | def Proxy(self, status, headers, exc_info=None):
"""Save args, defer start_response until response body is parsed.
Create output buffer for body to be written into.
Note: this is not quite WSGI compliant: The body should come back as an
iterator returned from calling service_app() but instead, StartR... | python | def Proxy(self, status, headers, exc_info=None):
"""Save args, defer start_response until response body is parsed.
Create output buffer for body to be written into.
Note: this is not quite WSGI compliant: The body should come back as an
iterator returned from calling service_app() but instead, StartR... | [
"def",
"Proxy",
"(",
"self",
",",
"status",
",",
"headers",
",",
"exc_info",
"=",
"None",
")",
":",
"self",
".",
"call_context",
"[",
"'status'",
"]",
"=",
"status",
"self",
".",
"call_context",
"[",
"'headers'",
"]",
"=",
"headers",
"self",
".",
"call... | Save args, defer start_response until response body is parsed.
Create output buffer for body to be written into.
Note: this is not quite WSGI compliant: The body should come back as an
iterator returned from calling service_app() but instead, StartResponse
returns a writer that will be later called... | [
"Save",
"args",
"defer",
"start_response",
"until",
"response",
"body",
"is",
"parsed",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/util.py#L44-L66 | train |
cloudendpoints/endpoints-python | endpoints/discovery_service.py | DiscoveryService._send_success_response | def _send_success_response(self, response, start_response):
"""Sends an HTTP 200 json success response.
This calls start_response and returns the response body.
Args:
response: A string containing the response body to return.
start_response: A function with semantics defined in PEP-333.
R... | python | def _send_success_response(self, response, start_response):
"""Sends an HTTP 200 json success response.
This calls start_response and returns the response body.
Args:
response: A string containing the response body to return.
start_response: A function with semantics defined in PEP-333.
R... | [
"def",
"_send_success_response",
"(",
"self",
",",
"response",
",",
"start_response",
")",
":",
"headers",
"=",
"[",
"(",
"'Content-Type'",
",",
"'application/json; charset=UTF-8'",
")",
"]",
"return",
"util",
".",
"send_wsgi_response",
"(",
"'200 OK'",
",",
"head... | Sends an HTTP 200 json success response.
This calls start_response and returns the response body.
Args:
response: A string containing the response body to return.
start_response: A function with semantics defined in PEP-333.
Returns:
A string, the response body. | [
"Sends",
"an",
"HTTP",
"200",
"json",
"success",
"response",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_service.py#L82-L95 | train |
cloudendpoints/endpoints-python | endpoints/discovery_service.py | DiscoveryService._get_rest_doc | def _get_rest_doc(self, request, start_response):
"""Sends back HTTP response with API directory.
This calls start_response and returns the response body. It will return
the discovery doc for the requested api/version.
Args:
request: An ApiRequest, the transformed request sent to the Discovery ... | python | def _get_rest_doc(self, request, start_response):
"""Sends back HTTP response with API directory.
This calls start_response and returns the response body. It will return
the discovery doc for the requested api/version.
Args:
request: An ApiRequest, the transformed request sent to the Discovery ... | [
"def",
"_get_rest_doc",
"(",
"self",
",",
"request",
",",
"start_response",
")",
":",
"api",
"=",
"request",
".",
"body_json",
"[",
"'api'",
"]",
"version",
"=",
"request",
".",
"body_json",
"[",
"'version'",
"]",
"generator",
"=",
"discovery_generator",
"."... | Sends back HTTP response with API directory.
This calls start_response and returns the response body. It will return
the discovery doc for the requested api/version.
Args:
request: An ApiRequest, the transformed request sent to the Discovery API.
start_response: A function with semantics defi... | [
"Sends",
"back",
"HTTP",
"response",
"with",
"API",
"directory",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_service.py#L97-L122 | train |
cloudendpoints/endpoints-python | endpoints/discovery_service.py | DiscoveryService._generate_api_config_with_root | def _generate_api_config_with_root(self, request):
"""Generate an API config with a specific root hostname.
This uses the backend object and the ApiConfigGenerator to create an API
config specific to the hostname of the incoming request. This allows for
flexible API configs for non-standard environment... | python | def _generate_api_config_with_root(self, request):
"""Generate an API config with a specific root hostname.
This uses the backend object and the ApiConfigGenerator to create an API
config specific to the hostname of the incoming request. This allows for
flexible API configs for non-standard environment... | [
"def",
"_generate_api_config_with_root",
"(",
"self",
",",
"request",
")",
":",
"actual_root",
"=",
"self",
".",
"_get_actual_root",
"(",
"request",
")",
"generator",
"=",
"api_config",
".",
"ApiConfigGenerator",
"(",
")",
"api",
"=",
"request",
".",
"body_json"... | Generate an API config with a specific root hostname.
This uses the backend object and the ApiConfigGenerator to create an API
config specific to the hostname of the incoming request. This allows for
flexible API configs for non-standard environments, such as localhost.
Args:
request: An ApiRequ... | [
"Generate",
"an",
"API",
"config",
"with",
"a",
"specific",
"root",
"hostname",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_service.py#L124-L158 | train |
cloudendpoints/endpoints-python | endpoints/discovery_service.py | DiscoveryService._list | def _list(self, request, start_response):
"""Sends HTTP response containing the API directory.
This calls start_response and returns the response body.
Args:
request: An ApiRequest, the transformed request sent to the Discovery API.
start_response: A function with semantics defined in PEP-333.... | python | def _list(self, request, start_response):
"""Sends HTTP response containing the API directory.
This calls start_response and returns the response body.
Args:
request: An ApiRequest, the transformed request sent to the Discovery API.
start_response: A function with semantics defined in PEP-333.... | [
"def",
"_list",
"(",
"self",
",",
"request",
",",
"start_response",
")",
":",
"configs",
"=",
"[",
"]",
"generator",
"=",
"directory_list_generator",
".",
"DirectoryListGenerator",
"(",
"request",
")",
"for",
"config",
"in",
"self",
".",
"_config_manager",
"."... | Sends HTTP response containing the API directory.
This calls start_response and returns the response body.
Args:
request: An ApiRequest, the transformed request sent to the Discovery API.
start_response: A function with semantics defined in PEP-333.
Returns:
A string containing the resp... | [
"Sends",
"HTTP",
"response",
"containing",
"the",
"API",
"directory",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_service.py#L170-L193 | train |
cloudendpoints/endpoints-python | endpoints/discovery_service.py | DiscoveryService.handle_discovery_request | def handle_discovery_request(self, path, request, start_response):
"""Returns the result of a discovery service request.
This calls start_response and returns the response body.
Args:
path: A string containing the API path (the portion of the path
after /_ah/api/).
request: An ApiReque... | python | def handle_discovery_request(self, path, request, start_response):
"""Returns the result of a discovery service request.
This calls start_response and returns the response body.
Args:
path: A string containing the API path (the portion of the path
after /_ah/api/).
request: An ApiReque... | [
"def",
"handle_discovery_request",
"(",
"self",
",",
"path",
",",
"request",
",",
"start_response",
")",
":",
"if",
"path",
"==",
"self",
".",
"_GET_REST_API",
":",
"return",
"self",
".",
"_get_rest_doc",
"(",
"request",
",",
"start_response",
")",
"elif",
"... | Returns the result of a discovery service request.
This calls start_response and returns the response body.
Args:
path: A string containing the API path (the portion of the path
after /_ah/api/).
request: An ApiRequest, the transformed request sent to the Discovery API.
start_respons... | [
"Returns",
"the",
"result",
"of",
"a",
"discovery",
"service",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/discovery_service.py#L195-L220 | train |
cloudendpoints/endpoints-python | endpoints/api_request.py | ApiRequest._process_req_body | def _process_req_body(self, body):
"""Process the body of the HTTP request.
If the body is valid JSON, return the JSON as a dict.
Else, convert the key=value format to a dict and return that.
Args:
body: The body of the HTTP request.
"""
try:
return json.loads(body)
except Valu... | python | def _process_req_body(self, body):
"""Process the body of the HTTP request.
If the body is valid JSON, return the JSON as a dict.
Else, convert the key=value format to a dict and return that.
Args:
body: The body of the HTTP request.
"""
try:
return json.loads(body)
except Valu... | [
"def",
"_process_req_body",
"(",
"self",
",",
"body",
")",
":",
"try",
":",
"return",
"json",
".",
"loads",
"(",
"body",
")",
"except",
"ValueError",
":",
"return",
"urlparse",
".",
"parse_qs",
"(",
"body",
",",
"keep_blank_values",
"=",
"True",
")"
] | Process the body of the HTTP request.
If the body is valid JSON, return the JSON as a dict.
Else, convert the key=value format to a dict and return that.
Args:
body: The body of the HTTP request. | [
"Process",
"the",
"body",
"of",
"the",
"HTTP",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_request.py#L118-L130 | train |
cloudendpoints/endpoints-python | endpoints/api_request.py | ApiRequest._reconstruct_relative_url | def _reconstruct_relative_url(self, environ):
"""Reconstruct the relative URL of this request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
URL from the pieces available in the environment.
Args:
env... | python | def _reconstruct_relative_url(self, environ):
"""Reconstruct the relative URL of this request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
URL from the pieces available in the environment.
Args:
env... | [
"def",
"_reconstruct_relative_url",
"(",
"self",
",",
"environ",
")",
":",
"url",
"=",
"urllib",
".",
"quote",
"(",
"environ",
".",
"get",
"(",
"'SCRIPT_NAME'",
",",
"''",
")",
")",
"url",
"+=",
"urllib",
".",
"quote",
"(",
"environ",
".",
"get",
"(",
... | Reconstruct the relative URL of this request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
URL from the pieces available in the environment.
Args:
environ: An environ dict for the request as defined in P... | [
"Reconstruct",
"the",
"relative",
"URL",
"of",
"this",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_request.py#L132-L149 | train |
cloudendpoints/endpoints-python | endpoints/api_request.py | ApiRequest.reconstruct_hostname | def reconstruct_hostname(self, port_override=None):
"""Reconstruct the hostname of a request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
hostname from the pieces available in the environment.
Args:
... | python | def reconstruct_hostname(self, port_override=None):
"""Reconstruct the hostname of a request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
hostname from the pieces available in the environment.
Args:
... | [
"def",
"reconstruct_hostname",
"(",
"self",
",",
"port_override",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"server",
"port",
"=",
"port_override",
"or",
"self",
".",
"port",
"if",
"port",
"and",
"(",
"(",
"self",
".",
"url_scheme",
"==",
"'https'"... | Reconstruct the hostname of a request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
hostname from the pieces available in the environment.
Args:
port_override: str, An override for the port on the return... | [
"Reconstruct",
"the",
"hostname",
"of",
"a",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_request.py#L151-L171 | train |
cloudendpoints/endpoints-python | endpoints/api_request.py | ApiRequest.reconstruct_full_url | def reconstruct_full_url(self, port_override=None):
"""Reconstruct the full URL of a request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
hostname from the pieces available in the environment.
Args:
... | python | def reconstruct_full_url(self, port_override=None):
"""Reconstruct the full URL of a request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
hostname from the pieces available in the environment.
Args:
... | [
"def",
"reconstruct_full_url",
"(",
"self",
",",
"port_override",
"=",
"None",
")",
":",
"return",
"'{0}://{1}{2}'",
".",
"format",
"(",
"self",
".",
"url_scheme",
",",
"self",
".",
"reconstruct_hostname",
"(",
"port_override",
")",
",",
"self",
".",
"relative... | Reconstruct the full URL of a request.
This is based on the URL reconstruction code in Python PEP 333:
http://www.python.org/dev/peps/pep-0333/#url-reconstruction. Rebuild the
hostname from the pieces available in the environment.
Args:
port_override: str, An override for the port on the return... | [
"Reconstruct",
"the",
"full",
"URL",
"of",
"a",
"request",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/api_request.py#L173-L188 | train |
cloudendpoints/endpoints-python | endpoints/openapi_generator.py | OpenApiGenerator._construct_operation_id | def _construct_operation_id(self, service_name, protorpc_method_name):
"""Return an operation id for a service method.
Args:
service_name: The name of the service.
protorpc_method_name: The ProtoRPC method name.
Returns:
A string representing the operation id.
"""
# camelCase th... | python | def _construct_operation_id(self, service_name, protorpc_method_name):
"""Return an operation id for a service method.
Args:
service_name: The name of the service.
protorpc_method_name: The ProtoRPC method name.
Returns:
A string representing the operation id.
"""
# camelCase th... | [
"def",
"_construct_operation_id",
"(",
"self",
",",
"service_name",
",",
"protorpc_method_name",
")",
":",
"method_name_camel",
"=",
"util",
".",
"snake_case_to_headless_camel_case",
"(",
"protorpc_method_name",
")",
"return",
"'{0}_{1}'",
".",
"format",
"(",
"service_n... | Return an operation id for a service method.
Args:
service_name: The name of the service.
protorpc_method_name: The ProtoRPC method name.
Returns:
A string representing the operation id. | [
"Return",
"an",
"operation",
"id",
"for",
"a",
"service",
"method",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L113-L128 | train |
cloudendpoints/endpoints-python | endpoints/openapi_generator.py | OpenApiGenerator.__definitions_descriptor | def __definitions_descriptor(self):
"""Describes the definitions section of the OpenAPI spec.
Returns:
Dictionary describing the definitions of the spec.
"""
# Filter out any keys that aren't 'properties' or 'type'
result = {}
for def_key, def_value in self.__parser.schemas().iteritems():... | python | def __definitions_descriptor(self):
"""Describes the definitions section of the OpenAPI spec.
Returns:
Dictionary describing the definitions of the spec.
"""
# Filter out any keys that aren't 'properties' or 'type'
result = {}
for def_key, def_value in self.__parser.schemas().iteritems():... | [
"def",
"__definitions_descriptor",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"for",
"def_key",
",",
"def_value",
"in",
"self",
".",
"__parser",
".",
"schemas",
"(",
")",
".",
"iteritems",
"(",
")",
":",
"if",
"'properties'",
"in",
"def_value",
"or"... | Describes the definitions section of the OpenAPI spec.
Returns:
Dictionary describing the definitions of the spec. | [
"Describes",
"the",
"definitions",
"section",
"of",
"the",
"OpenAPI",
"spec",
"."
] | 00dd7c7a52a9ee39d5923191c2604b8eafdb3f24 | https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L613-L647 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.