Python 2.7 has reached end of supportand will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy Python 2.7applications, even if your organization previously used an organization policy tore-enable deployments of legacy runtimes. Your existing Python2.7 applications will continue to run and receive traffic after theirdeprecation date. We recommend thatyoumigrate to the latest supported version of Python.

google.appengine.api.appinfo module

Summary

AppInfo tools.

This library allows you to work with AppInfo records in memory, as well as store and load from configuration files.

Contents

classgoogle.appengine.api.appinfo.AdminConsole(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing an admin console directives in application info.

ATTRIBUTES = {'pages': <google.appengine.api.validation.Optional object>}
classmethodMerge(adminconsole_one, adminconsole_two)source

Returns the result of merging twoAdminConsole objects.

classgoogle.appengine.api.appinfo.AdminConsolePage(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the admin console page in anAdminConsole object.

ATTRIBUTES = {'url': '(?!\\^)/.*|\\..*|(\\(.).*(?!\\$).', 'name': '^.+$'}
classgoogle.appengine.api.appinfo.ApiConfigHandler(**attributes)source

Bases:google.appengine.api.appinfo.HandlerBase

Class representingapi_config handler directives in application info.

ATTRIBUTES = {'secure': <google.appengine.api.validation.Options object>, 'script': <google.appengine.api.validation.Regex object>, 'url': <google.appengine.api.validation.Regex object>, 'login': <google.appengine.api.validation.Options object>, 'auth_fail_action': <google.appengine.api.validation.Options object>}
classgoogle.appengine.api.appinfo.AppInclude(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the contents of an includedapp.yaml file.

This class is used for bothbuiltins andincludes directives.

ATTRIBUTES = {'beta_settings': <google.appengine.api.validation.Optional object>, 'builtins': <google.appengine.api.validation.Optional object>, 'vm_settings': <google.appengine.api.validation.Optional object>, 'admin_console': <google.appengine.api.validation.Optional object>, 'handlers': <google.appengine.api.validation.Optional object>, 'manual_scaling': <google.appengine.api.validation.Optional object>, 'skip_files': <google.appengine.api.validation.RegexStr object>, 'vm': <google.appengine.api.validation.Optional object>, 'env_variables': <google.appengine.api.validation.Optional object>, 'includes': <google.appengine.api.validation.Optional object>}
classmethodMergeAppIncludes(appinclude_one, appinclude_two)source

Merges the non-referential state of the providedAppInclude.

That is,builtins andincludes directives are not preserved, but any static objects are copied into an aggregateAppInclude object that preserves the directives of both providedAppInclude objects.

appinclude_one is updated to be the merged result in this process.

Parameters
  • appinclude_one – FirstAppInclude to merge.

  • appinclude_two – SecondAppInclude to merge.

Returns

AppInclude object that is the result of merging the static directives ofappinclude_one andappinclude_two. An updated version ofappinclude_one is returned.

classmethodMergeAppYamlAppInclude(appyaml, appinclude)source

Merges anapp.yaml file with referenced builtins/includes.

Parameters
  • appyaml – Theapp.yaml file that you want to update withappinclude.

  • appinclude – The includes that you want to merge intoappyaml.

Returns

An updatedapp.yaml file that includes the directives you specified inappinclude.

classmethodMergeManualScaling(appinclude_one, appinclude_two)source

Takes the greater of<manual_scaling.instances> from the arguments.

appinclude_one is mutated to be the merged result in this process.

Also, this function must be updated ifManualScaling gets additional fields.

Parameters
  • appinclude_one – The first object to merge. The object must have amanual_scaling field that contains aManualScaling().

  • appinclude_two – The second object to merge. The object must have amanual_scaling field that contains aManualScaling().

Returns

An object that is the result of mergingappinclude_one.manual_scaling.instances andappinclude_two.manual_scaling.instances; this is returned as a revisedappinclude_one object after the mutations are complete.

staticMergeSkipFiles(skip_files_one, skip_files_two)source

Merges twoskip_files directives.

Parameters
  • skip_files_one – The firstskip_files element that you want to merge.

  • skip_files_two – The secondskip_files element that you want to merge.

Returns

A list of regular expressions that are merged.

classgoogle.appengine.api.appinfo.AppInfoExternal(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing users application info.

This class is passed to ayaml_object builder to provide the validation for the application information file format parser.

application

Unique identifier for application.

version

Application’s major version.

runtime

Runtime used by application.

api_version

Which version of APIs to use.

source_language

Optional specification of the source language. For example, you could specifyphp-quercus if this is a Java app that was generated from PHP source using Quercus.

handlers

List of URL handlers.

default_expiration

Default time delta to use for cache expiration for all static files, unless they have their own specificexpiration set. See the documentation for theURLMap.expiration field for more information.

skip_files

A regular expression object. Files that match this regular expression will not be uploaded byappcfg.py. For example:

skip_files:|.svn.*|#.*#
nobuild_files

A regular expression object. Files that match this regular expression will not be built into the app. This directive is valid for Go only.

api_config

URL root and script or servlet path for enhanced API serving.

ATTRIBUTES = {'manual_scaling': <google.appengine.api.validation.Optional object>, 'env_variables': <google.appengine.api.validation.Optional object>, 'inbound_services': <google.appengine.api.validation.Optional object>, 'builtins': <google.appengine.api.validation.Optional object>, 'service': <google.appengine.api.validation.Preferred object>, 'runtime_channel': <google.appengine.api.validation.Optional object>, 'vpc_access_connector': <google.appengine.api.validation.Optional object>, 'instance_class': <google.appengine.api.validation.Optional object>, 'vm_health_check': <google.appengine.api.validation.Optional object>, 'backends': <google.appengine.api.validation.Optional object>, 'resources': <google.appengine.api.validation.Optional object>, 'basic_scaling': <google.appengine.api.validation.Optional object>, 'admin_console': <google.appengine.api.validation.Optional object>, 'liveness_check': <google.appengine.api.validation.Optional object>, 'auto_id_policy': <google.appengine.api.validation.Optional object>, 'standard_websocket': <google.appengine.api.validation.Optional object>, 'vm_settings': <google.appengine.api.validation.Optional object>, 'default_expiration': <google.appengine.api.validation.Optional object>, 'project': <google.appengine.api.validation.Optional object>, 'derived_file_type': <google.appengine.api.validation.Optional object>, 'automatic_scaling': <google.appengine.api.validation.Optional object>, 'source_language': <google.appengine.api.validation.Optional object>, 'vm': <google.appengine.api.validation.Optional object>, 'module': <google.appengine.api.validation.Deprecated object>, 'zones': <google.appengine.api.validation.Optional object>, 'endpoints_api_service': <google.appengine.api.validation.Optional object>, 'beta_settings': <google.appengine.api.validation.Optional object>, 'threadsafe': <google.appengine.api.validation.Optional object>, 'skip_files': <google.appengine.api.validation.RegexStr object>, 'libraries': <google.appengine.api.validation.Optional object>, 'application': <google.appengine.api.validation.Optional object>, 'readiness_check': <google.appengine.api.validation.Optional object>, 'version': <google.appengine.api.validation.Optional object>, 'entrypoint': <google.appengine.api.validation.Optional object>, 'env': <google.appengine.api.validation.Optional object>, 'api_version': <google.appengine.api.validation.Optional object>, 'health_check': <google.appengine.api.validation.Optional object>, 'includes': <google.appengine.api.validation.Optional object>, 'code_lock': <google.appengine.api.validation.Optional object>, 'network': <google.appengine.api.validation.Optional object>, 'error_handlers': <google.appengine.api.validation.Optional object>, 'handlers': <google.appengine.api.validation.Optional object>, 'runtime_config': <google.appengine.api.validation.Optional object>, 'nobuild_files': <google.appengine.api.validation.RegexStr object>, 'runtime': <google.appengine.api.validation.Optional object>, 'api_config': <google.appengine.api.validation.Optional object>}
ApplyBackendSettings(backend_name)source

Applies settings from the indicated backend to theAppInfoExternal.

Backend entries can contain directives that modify other parts of theapp.yaml file, such as thestart directive, which adds a handler for the start request. This method performs those modifications.

Parameters

backend_name – The name of a backend that is defined in thebackends directive.

Raises
  • BackendNotFound – If the indicated backend was not listed in thebackends directive.

  • DuplicateBackend – If the backend is found more than once in thebackends directive.

CheckInitialized()source

Performs non-regular expression-based validation.

The following are verified:
  • At least one URL mapping is provided in the URL mappers.

  • The number of URL mappers doesn’t exceedMAX_URL_MAPS.

  • The major version does not contain the string-dot-.

  • Ifapi_endpoints are defined, anapi_config stanza must be defined.

  • If theruntime ispython27 andthreadsafe is set, then no CGI handlers can be used.

  • The version name doesn’t start withBUILTIN_NAME_PREFIX.

  • Ifredirect_http_response_code exists, it is in the list of valid 300s.

  • Module and service aren’t both set. Services were formerly known as modules.

Raises
  • DuplicateLibrary – Iflibrary_name is specified more than once.

  • MissingURLMapping – If noURLMap object is present in the object.

  • TooManyURLMappings – If there are too manyURLMap entries.

  • MissingApiConfig – Ifapi_endpoints exists without anapi_config.

  • MissingThreadsafe – Ifthreadsafe is not set but the runtime requires it.

  • ThreadsafeWithCgiHandler – If theruntime ispython27,threadsafe is set and CGI handlers are specified.

  • TooManyScalingSettingsError – If more than one scaling settings block is present.

  • RuntimeDoesNotSupportLibraries – If the libraries clause is used for a runtime that does not support it, such aspython25.

GetAllLibraries()source

Returns a list of allLibrary instances active for this configuration.

Returns

The list of activeLibrary instances for this configuration. This includes directly-specified libraries as well as any required dependencies.

GetEffectiveRuntime()source

Returns the app’s runtime, resolving VMs to the underlyingvm_runtime.

Returns

The value ofbeta/vm_settings.vm_runtime ifruntime isvm, orruntime otherwise.

Return type

The effective runtime

GetNormalizedLibraries()source

Returns a list of normalizedLibrary instances for this configuration.

Returns

The list of activeLibrary instances for this configuration. This includes directly-specified libraries, their required dependencies, and any libraries enabled by default. Any libraries withlatest as their version will be replaced with the latest available version.

IsVm()source
NormalizeVmSettings()source

Normalizes VM settings.

SetEffectiveRuntime(runtime)source

Sets the runtime while respecting vm runtimes rules for runtime settings.

Parameters

runtime – The runtime to use.

classgoogle.appengine.api.appinfo.AppInfoSummary(**attributes)source

Bases:google.appengine.api.validation.Validated

This class contains only basic summary information about an app.

This class is used to pass back information about the newly created app to users after a new version has been created.

ATTRIBUTES = {'application': '(?:[a-z\\d\\-]{1,100}\\~)?(?:(?!\\-)[a-z\\d\\-\\.]{1,100}:)?(?!-)[a-z\\d\\-]{0,99}[a-z\\d]', 'major_version': '^(?!-)[a-z\\d\\-]{0,62}[a-z\\d]$', 'minor_version': <google.appengine.api.validation.Type object>}
classgoogle.appengine.api.appinfo.AutomaticScaling(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing automatic scaling settings in AppInfoExternal.

ATTRIBUTES = {'target_concurrent_requests': <google.appengine.api.validation.Optional object>, 'target_disk_write_ops_per_sec': <google.appengine.api.validation.Optional object>, 'target_disk_read_bytes_per_sec': <google.appengine.api.validation.Optional object>, 'max_pending_latency': <google.appengine.api.validation.Optional object>, 'min_num_instances': <google.appengine.api.validation.Optional object>, 'target_disk_read_ops_per_sec': <google.appengine.api.validation.Optional object>, 'target_network_sent_bytes_per_sec': <google.appengine.api.validation.Optional object>, 'cool_down_period_sec': <google.appengine.api.validation.Optional object>, 'target_cpu_utilization': <google.appengine.api.validation.Optional object>, 'target_network_received_bytes_per_sec': <google.appengine.api.validation.Optional object>, 'target_network_received_packets_per_sec': <google.appengine.api.validation.Optional object>, 'target_request_count_per_sec': <google.appengine.api.validation.Optional object>, 'cpu_utilization': <google.appengine.api.validation.Optional object>, 'max_num_instances': <google.appengine.api.validation.Optional object>, 'min_pending_latency': <google.appengine.api.validation.Optional object>, 'min_idle_instances': <google.appengine.api.validation.Optional object>, 'max_idle_instances': <google.appengine.api.validation.Optional object>, 'target_disk_write_bytes_per_sec': <google.appengine.api.validation.Optional object>, 'max_instances': <google.appengine.api.validation.Optional object>, 'target_throughput_utilization': <google.appengine.api.validation.Optional object>, 'max_concurrent_requests': <google.appengine.api.validation.Optional object>, 'min_instances': <google.appengine.api.validation.Optional object>, 'target_network_sent_packets_per_sec': <google.appengine.api.validation.Optional object>, 'custom_metrics': <google.appengine.api.validation.Optional object>}
classgoogle.appengine.api.appinfo.BasicScaling(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing basic scaling settings in AppInfoExternal.

ATTRIBUTES = {'idle_timeout': <google.appengine.api.validation.Optional object>, 'max_instances': <google.appengine.api.validation.Regex object>}
classgoogle.appengine.api.appinfo.BetaSettings(**kwds)source

Bases:google.appengine.api.appinfo.VmSettings

Class for Beta (internal or unreleased) settings.

This class is meant to replaceVmSettings eventually.

Note:

All new beta settings must be registered inshared_constants.py.

These settings are not validated further here. The settings are validated on the server side.

classmethodMerge(beta_settings_one, beta_settings_two)source

Merges twoBetaSettings instances.

Parameters
  • beta_settings_one – The firstBetaSettings instance, orNone.

  • beta_settings_two – The secondBetaSettings instance, orNone.

Returns

The mergedBetaSettings instance, orNone if both input instances areNone or empty.

classgoogle.appengine.api.appinfo.BuiltinHandler(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing built-in handler directives in application info.

This class permits arbitrary keys, but their values must be described by thevalidation.Options object that is returned byATTRIBUTES.

ATTRIBUTES = {}
classDynamicAttributes(return_value, **parameters)source

Bases: dict

Provides a dictionary object that will always claim to have a key.

This dictionary returns a fixed value for anyget operation. The fixed value that you pass in as a constructor parameter should be avalidation.Validated object.

GetUnnormalized(key)source
classmethodIsDefined(builtins_list, builtin_name)source

Finds if a builtin is defined in a given list of builtin handler objects.

Parameters
  • builtins_list – A list ofBuiltinHandler objects, typicallyyaml.builtins.

  • builtin_name – The name of the built-in that you want to determine whether it is defined.

Returns

True ifbuiltin_name is defined by a member ofbuiltins_list; all other results returnFalse.

classmethodListToTuples(builtins_list)source

Converts a list ofBuiltinHandler objects.

Parameters

builtins_list – A list ofBuildinHandler objects to convert to tuples.

Returns

A list of(name, status) that is derived from theBuiltinHandler objects.

ToDict()source

Converts aBuiltinHander object to a dictionary.

Returns

on/off}` form

Return type

A dictionary in `{builtin_handler_name

classmethodValidate(builtins_list, runtime=None)source

Verifies that allBuiltinHandler objects are valid and not repeated.

Parameters
  • builtins_list – A list ofBuiltinHandler objects to validate.

  • runtime – If you specify this argument, warnings are generated for built-ins that have been deprecated in the given runtime.

Raises
  • InvalidBuiltinFormat – If the name of aBuiltinHandler object cannot be determined.

  • DuplicateBuiltinsSpecified – If aBuiltinHandler name is used more than once in the list.

classgoogle.appengine.api.appinfo.CpuUtilization(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the configuration of VM CPU utilization.

ATTRIBUTES = {'target_utilization': <google.appengine.api.validation.Optional object>, 'aggregation_window_length_sec': <google.appengine.api.validation.Optional object>}
classgoogle.appengine.api.appinfo.CustomMetric(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing CustomMetrics in AppInfoExternal.

ATTRIBUTES = {'target_utilization': <google.appengine.api.validation.Optional object>, 'filter': <google.appengine.api.validation.Optional object>, 'single_instance_assignment': <google.appengine.api.validation.Optional object>, 'metric_name': <google.appengine.api.validation.Regex object>, 'target_type': <google.appengine.api.validation.Regex object>}
CheckInitialized()source

Determines if the CustomMetric is not valid.

Raises
  • appinfo_errors.TooManyAutoscalingUtilizationTargetsError – If too many

  • scaling targets are set.

  • appinfo_errors.NotEnoughAutoscalingUtilizationTargetsError – If no scaling

  • targets are set.

classgoogle.appengine.api.appinfo.EndpointsApiService(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing EndpointsApiService in AppInfoExternal.

ATTRIBUTES = {'config_id': <google.appengine.api.validation.Optional object>, 'trace_sampling': <google.appengine.api.validation.Optional object>, 'name': <google.appengine.api.validation.Regex object>, 'rollout_strategy': <google.appengine.api.validation.Optional object>}
CheckInitialized()source

Determines if the Endpoints API Service is not valid.

Raises
  • appinfo_errors.MissingEndpointsConfigId – If the config id is missing when the rollout strategy is unspecified or set to “fixed”.

  • appinfo_errors.UnexpectedEndpointsConfigId – If the config id is set when the rollout strategy is “managed”.

google.appengine.api.appinfo.EnsureAsciiBytes(s, err)source

Ensure s contains only ASCII-safe characters; return it as bytes-type.

Parameters
  • s – the string or bytes to check

  • err – the error to raise if not good.

Raises

err if it’s not ASCII-safe.

Returns

s as a byte string

classgoogle.appengine.api.appinfo.EnvironmentVariables(**kwds)source

Bases:google.appengine.api.validation.ValidatedDict

Class representing a mapping of environment variable key/value pairs.

KEY_VALIDATOR = <google.appengine.api.validation.Regex object>
classmethodMerge(env_variables_one, env_variables_two)source

Merges twoEnvironmentVariables instances.

If a variable is specified by both instances, the value fromenv_variables_two is used.

Parameters
  • env_variables_one – The firstEnvironmentVariables instance orNone.

  • env_variables_two – The secondEnvironmentVariables instance orNone.

Returns

The mergedEnvironmentVariables instance, orNone if both input instances areNone or empty.

VALUE_VALIDATOR

alias of str

classgoogle.appengine.api.appinfo.ErrorHandlers(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing error handler directives in application info.

ATTRIBUTES = {'error_code': <google.appengine.api.validation.Optional object>, 'mime_type': <google.appengine.api.validation.Optional object>, 'file': '.+'}
google.appengine.api.appinfo.GetAllRuntimes()source

Returns the list of all valid runtimes.

This list can include third-party runtimes as well as canned runtimes.

Returns

Tuple of strings.

classgoogle.appengine.api.appinfo.HandlerBase(**attributes)source

Bases:google.appengine.api.validation.Validated

Base class for URLMap and ApiConfigHandler.

ATTRIBUTES = {'secure': <google.appengine.api.validation.Options object>, 'script': <google.appengine.api.validation.Regex object>, 'url': <google.appengine.api.validation.Regex object>, 'login': <google.appengine.api.validation.Options object>, 'auth_fail_action': <google.appengine.api.validation.Options object>}
classgoogle.appengine.api.appinfo.HealthCheck(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the health check configuration.

ATTRIBUTES = {'check_interval_sec': <google.appengine.api.validation.Optional object>, 'timeout_sec': <google.appengine.api.validation.Optional object>, 'healthy_threshold': <google.appengine.api.validation.Optional object>, 'enable_health_check': <google.appengine.api.validation.Optional object>, 'unhealthy_threshold': <google.appengine.api.validation.Optional object>, 'host': <google.appengine.api.validation.Optional object>, 'restart_threshold': <google.appengine.api.validation.Optional object>}
classgoogle.appengine.api.appinfo.HttpHeadersDict(**kwds)source

Bases:google.appengine.api.validation.ValidatedDict

A dict that limits keys and values to whathttp_headers allows.

http_headers is an static handler key; it applies to handlers withstatic_dir orstatic_files keys. The following code is an example of howhttp_headers is used:

handlers:-url:/staticstatic_dir:statichttp_headers:X-Foo-Header:foovalueX-Bar-Header:barvalue
DISALLOWED_HEADERS = frozenset(['date', 'content-length', 'server', 'content-encoding'])
Get(header_name)source

Gets a header value.

Parameters

header_name – HTTP header name to look for.

Returns

A header value that corresponds toheader_name. If more than one such value is inself, one of the values is selected arbitrarily and returned. The selection is not deterministic.

KEY_VALIDATOR = <google.appengine.api.appinfo.KeyValidator object>
classKeyValidator(default=None)source

Bases:google.appengine.api.validation.Validator

Ensures that keys inHttpHeadersDict are valid.

HttpHeadersDict contains a list of headers. An instance is used asHttpHeadersDict’sKEY_VALIDATOR.

Validate(name, unused_key=None)source

Returns an argument, or raises an exception if the argument is invalid.

HTTP header names are defined byRFC 2616, section 4.2.

Parameters
  • name – HTTP header field value.

  • unused_key – Unused.

Returns

name argument, unchanged.

Raises

appinfo_errors.InvalidHttpHeaderName – An argument cannot be used as an HTTP header name.

MAX_HEADER_LENGTH = 500
MAX_HEADER_VALUE_LENGTHS = {'set-cookie2': 4096, 'content-security-policy': 10240, 'set-cookie': 4096, 'content-security-policy-report-only': 10240, 'location': 2047, 'x-content-security-policy': 10240, 'x-webkit-csp': 10240}
MAX_LEN = 500
VALUE_VALIDATOR = <google.appengine.api.appinfo.ValueValidator object>
classValueValidator(default=None)source

Bases:google.appengine.api.validation.Validator

Ensures that values inHttpHeadersDict are valid.

An instance is used asHttpHeadersDict’sVALUE_VALIDATOR.

staticAssertHeaderNotTooLong(name, value)source
Validate(value, key=None)source

Returns a value, or raises an exception if the value is invalid.

According to `RFC 2616 section 4.2`_ header field values must consist “of either *TEXT or combinations of token, separators, and quoted-string”:

TEXT= <anyOCTETexceptCTLs,butincludingLWS>
Parameters
  • value – HTTP header field value.

  • key – HTTP header field name.

Returns

A value argument.

Raises

appinfo_errors.InvalidHttpHeaderValue – An argument cannot be used as an HTTP header value.

classgoogle.appengine.api.appinfo.Library(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the configuration of a single library.

ATTRIBUTES = {'version': <google.appengine.api.validation.Type object>, 'name': <google.appengine.api.validation.Type object>}
CheckInitialized()source

Determines if the library configuration is not valid.

Raises
  • appinfo_errors.InvalidLibraryName – If the specified library is not supported.

  • appinfo_errors.InvalidLibraryVersion – If the specified library version is not supported.

classgoogle.appengine.api.appinfo.LivenessCheck(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the liveness check configuration.

ATTRIBUTES = {'check_interval_sec': <google.appengine.api.validation.Optional object>, 'timeout_sec': <google.appengine.api.validation.Optional object>, 'host': <google.appengine.api.validation.Optional object>, 'failure_threshold': <google.appengine.api.validation.Optional object>, 'path': <google.appengine.api.validation.Optional object>, 'initial_delay_sec': <google.appengine.api.validation.Optional object>, 'success_threshold': <google.appengine.api.validation.Optional object>}
google.appengine.api.appinfo.LoadAppInclude(app_include)source

Loads a singleAppInclude object where one and only one is expected.

Parameters

app_include – A file-like object or string. The argument is set to a string, the argument is parsed as a configuration file. If the argument is set to a file-like object, the data is read and parsed.

Returns

An instance ofAppInclude as loaded from a YAML file.

Raises
  • EmptyConfigurationFile – If there are no documents in the YAML file.

  • MultipleConfigurationFile – If there is more than one document in the YAML file.

google.appengine.api.appinfo.LoadSingleAppInfo(app_info)source

Loads a singleAppInfo object where one and only one is expected.

This method validates that the values in theAppInfo match the validators that are defined in this file, in particular,AppInfoExternal.ATTRIBUTES.

Parameters

app_info – A file-like object or string. If the argument is a string, the argument is parsed as a configuration file. If the argument is a file-like object, the data is read, then parsed.

Returns

An instance ofAppInfoExternal as loaded from a YAML file.

Raises
  • ValueError – If a specified service is not valid.

  • EmptyConfigurationFile – If there are no documents in YAML file.

  • MultipleConfigurationFile – If more than one document exists in the YAML file.

  • DuplicateBackend – If a backend is found more than once in thebackends directive.

  • yaml_errors.EventError – If theapp.yaml file fails validation.

  • appinfo_errors.MultipleProjectNames – If theapp.yaml file has both anapplication directive and aproject directive.

classgoogle.appengine.api.appinfo.ManualScaling(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing manual scaling settings in AppInfoExternal.

ATTRIBUTES = {'instances': <google.appengine.api.validation.Regex object>}
classgoogle.appengine.api.appinfo.Network(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the VM network configuration.

ATTRIBUTES = {'instance_tag': <google.appengine.api.validation.Optional object>, 'session_affinity': <google.appengine.api.validation.Optional object>, 'name': <google.appengine.api.validation.Optional object>, 'forwarded_ports': <google.appengine.api.validation.Optional object>, 'subnetwork_name': <google.appengine.api.validation.Optional object>}
google.appengine.api.appinfo.ParseExpiration(expiration)source

Parses an expiration delta string.

Parameters

expiration – String that matches_DELTA_REGEX.

Returns

Time delta in seconds.

classgoogle.appengine.api.appinfo.ReadinessCheck(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the readiness check configuration.

ATTRIBUTES = {'check_interval_sec': <google.appengine.api.validation.Optional object>, 'timeout_sec': <google.appengine.api.validation.Optional object>, 'app_start_timeout_sec': <google.appengine.api.validation.Optional object>, 'host': <google.appengine.api.validation.Optional object>, 'failure_threshold': <google.appengine.api.validation.Optional object>, 'path': <google.appengine.api.validation.Optional object>, 'success_threshold': <google.appengine.api.validation.Optional object>}
classgoogle.appengine.api.appinfo.Resources(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the configuration of VM resources.

ATTRIBUTES = {'memory_gb': <google.appengine.api.validation.Optional object>, 'disk_size_gb': <google.appengine.api.validation.Optional object>, 'cpu': <google.appengine.api.validation.Optional object>, 'volumes': <google.appengine.api.validation.Optional object>}
classgoogle.appengine.api.appinfo.RuntimeConfig(**kwds)source

Bases:google.appengine.api.validation.ValidatedDict

Class for “vanilla” runtime configuration.

Fields used vary by runtime, so validation is delegated to the per-runtime build processes.

These are intended to be used during Dockerfile generation, not after VM boot.

KEY_VALIDATOR = <google.appengine.api.validation.Regex object>
VALUE_VALIDATOR

alias of str

classgoogle.appengine.api.appinfo.URLMap(**attributes)source

Bases:google.appengine.api.appinfo.HandlerBase

Maps from URLs to handlers.

This class acts similar to a union type. Its purpose is to describe a mapping between a set of URLs and their handlers. The handler type of a given instance is determined by whichhandler-id attribute is used.

Every mapping can have one and only one handler type. Attempting to use more than onehandler-id attribute will cause anUnknownHandlerType to be raised during validation. Failure to provide anyhandler-id attributes will causeMissingHandlerType to be raised during validation.

The regular expression used by theurl field will be used to match against the entire URL path and query string of the request; therefore, partial maps will not be matched. Specifying aurl, such as/admin, is the same as matching against the regular expression^/admin$. Don’t start your matchingurl with^ or end them with$. These regular expressions won’t be accepted and will raiseValueError.

login

Specifies whether a user should be logged in to access a URL. The default value of this argument isoptional.

secure

Sets the restriction on the protocol that can be used to serve this URL or handler. This value can be set toHTTP,HTTPS oreither.

url

Specifies a regular expression that is used to fully match against the request URLs path. See the “Special cases” section of this document to learn more.

static_files

Specifies the handler ID attribute that mapsurl to the appropriate file. You can specify regular expression backreferences to the string matched tourl.

upload

Specifies the regular expression that is used by the application configuration program to determine which files are uploaded as blobs. Because it is difficult to determine this information using just theurl andstatic_files arguments, this attribute must be included. This attribute is required when you define astatic_files mapping. A matching file name must fully match against theupload regular expression, similar to howurl is matched against the request path. Do not begin theupload argument with the^ character or end it with the$ character.

static_dir

Specifies the handler ID that maps the providedurl to a sub-directory within the application directory. See “Special cases.”

mime_type

When used withstatic_files andstatic_dir, this argument specifies that the MIME type of the files that are served from those directories must be overridden with this value.

script

Specifies the handler ID that maps URLs to a script handler within the application directory that will run using CGI.

position

Used inAppInclude objects to specify whether a handler should be inserted at the beginning of the primary handler list or at the end. Iftail is specified, the handler is inserted at the end; otherwise, the handler is inserted at the beginning. This behavior implies thathead is the effective default.

expiration

When used with static files and directories, this argument specifies the time delta to use for cache expiration. This argument should use the following format:4d 5h 30m 15s, where each letter signifies days, hours, minutes, and seconds, respectively. Thes for “seconds” can be omitted. Only one amount must be specified, though combining multiple amounts is optional. The following list contains examples of values that are acceptable:10,1d 6h,1h 30m,7d 7d 7d,5m 30.

api_endpoint

Specifies the handler ID that identifies an endpoint as an API endpoint. Calls that terminate here will be handled by the API serving framework.

Special cases:

When defining astatic_dir handler, do not use a regular expression in theurl attribute. Both theurl andstatic_dir attributes are automatically mapped to these equivalents:

<url>/(.*)<static_dir>/\1

For example, this declaration…:

url:/imagesstatic_dir:images_folder

…is equivalent to thisstatic_files declaration:

url:/images/(.*)static_files:images_folder/\1upload:images_folder/(.*)
ALLOWED_FIELDS = {'api_endpoint': ('position', 'script'), 'static_files': ('mime_type', 'upload', 'expiration', 'require_matching_file', 'http_headers', 'application_readable'), 'static_dir': ('mime_type', 'expiration', 'require_matching_file', 'http_headers', 'application_readable'), 'script': 'position'}
ATTRIBUTES = {'secure': <google.appengine.api.validation.Options object>, 'static_files': <google.appengine.api.validation.Optional object>, 'application_readable': <google.appengine.api.validation.Optional object>, 'auth_fail_action': <google.appengine.api.validation.Options object>, 'require_matching_file': <google.appengine.api.validation.Optional object>, 'static_dir': <google.appengine.api.validation.Optional object>, 'redirect_http_response_code': <google.appengine.api.validation.Optional object>, 'http_headers': <google.appengine.api.validation.Optional object>, 'url': <google.appengine.api.validation.Optional object>, 'script': <google.appengine.api.validation.Optional object>, 'upload': <google.appengine.api.validation.Optional object>, 'api_endpoint': <google.appengine.api.validation.Optional object>, 'expiration': <google.appengine.api.validation.Optional object>, 'position': <google.appengine.api.validation.Optional object>, 'login': <google.appengine.api.validation.Options object>, 'mime_type': <google.appengine.api.validation.Optional object>}
AssertUniqueContentType()source

Makes sure thatself.http_headers is consistent withself.mime_type.

This method assumes thatself is a static handler, eitherself.static_dir orself.static_files. You cannot specifyNone.

Raises
appinfo_errors.ContentTypeSpecifiedMultipleTimes – Ifself.http_headers

contains aContent-Type header, andself.mime_type is set. For example, the following configuration would be rejected:

handlers:-url:/staticstatic_dir:staticmime_type:text/htmlhttp_headers:content-type:text/html

As this example shows, a configuration will be rejected whenhttp_headers andmime_type specify a content type, even when they specify the same content type.

COMMON_FIELDS = set(['url', 'redirect_http_response_code', 'login', 'secure', 'auth_fail_action'])
CheckInitialized()source

Adds additional checking to make sure a handler has correct fields.

In addition to normalValidatedCheck, this method callsGetHandlerType, which validates whether all of the handler fields are configured properly.

Raises
  • UnknownHandlerType – If none of the handler ID attributes are set.

  • UnexpectedHandlerAttribute – If an unexpected attribute is set for the discovered handler type.

  • HandlerTypeMissingAttribute – If the handler is missing a required attribute for its handler type.

  • ContentTypeSpecifiedMultipleTimes – Ifmime_type is inconsistent withhttp_headers.

ErrorOnPositionForAppInfo()source

Raises an error if position is specified outside of AppInclude objects.

Raises

PositionUsedInAppYamlHandler – If theposition attribute is specified for anapp.yaml file instead of aninclude.yaml file.

FixSecureDefaults()source

Forces omittedsecure handler fields to be set to ‘secure: optional’.

The effect is thathandler.secure is never equal to the nominal default.

GetHandler()source

Gets the handler for a mapping.

Returns

The value of the handler, as determined by the handler ID attribute.

GetHandlerType()source

Gets the handler type of a mapping.

Returns

The handler type as determined by which handler ID attribute is set.

Raises
  • UnknownHandlerType – If none of the handler ID attributes are set.

  • UnexpectedHandlerAttribute – If an unexpected attribute is set for the discovered handler type.

  • HandlerTypeMissingAttribute – If the handler is missing a required attribute for its handler type.

  • MissingHandlerAttribute – If a URL handler is missing an attribute.

WarnReservedURLs()source

Generates a warning for reserved URLs.

See theversion element documentation to learn which URLs are reserved.

google.appengine.api.appinfo.ValidFilename(filename)source

Determines if a file name is valid.

Parameters

filename –

The file name to validate. The file name must be a valid file name:

  • It must only contain letters, numbers, and the following special characters:@,_,+,/$,.,-, or ‘~’.

  • It must be less than 256 characters.

  • It must not contain/./,/../, or//.

  • It must not end in/.

  • All spaces must be in the middle of a directory or file name.

Returns

An error string if the file name is invalid.‘’ is returned if the file name is valid.

google.appengine.api.appinfo.ValidateCombinedSourceReferencesString(source_refs)source

Determines ifsource_refs contains a valid list of source references.

Parameters

source_refs – A multi-line string containing one source reference per line.

Raises

ValidationError – If the reference is malformed.

google.appengine.api.appinfo.ValidateHandlers(handlers, is_include_file=False)source

Validates a list of handler (URLMap) objects.

Parameters
  • handlers – A list of a handler (URLMap) objects.

  • is_include_file – If this argument is set toTrue, the handlers that are added as part of theincludes directive are validated.

google.appengine.api.appinfo.ValidateSourceReference(ref)source

Determines if a source reference is valid.

Parameters

ref – A source reference in the following format:[repository_uri#]revision.

Raises

ValidationError – If the reference is malformed.

classgoogle.appengine.api.appinfo.VmHealthCheck(**attributes)source

Bases:google.appengine.api.appinfo.HealthCheck

Class representing the configuration of the VM health check.

Note:

This class is deprecated and will be removed in a future release. UseHealthCheck instead.

classgoogle.appengine.api.appinfo.VmSettings(**kwds)source

Bases:google.appengine.api.validation.ValidatedDict

Class for VM settings.

The settings are not further validated here. The settings are validated on the server side.

KEY_VALIDATOR = <google.appengine.api.validation.Regex object>
classmethodMerge(vm_settings_one, vm_settings_two)source

Merges twoVmSettings instances.

If a variable is specified by both instances, the value fromvm_settings_one is used.

Parameters
  • vm_settings_one – The firstVmSettings instance, orNone.

  • vm_settings_two – The secondVmSettings instance, orNone.

Returns

The mergedVmSettings instance, orNone if both input instances areNone or empty.

VALUE_VALIDATOR

alias of str

classgoogle.appengine.api.appinfo.Volume(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the configuration of a volume.

ATTRIBUTES = {'size_gb': <google.appengine.api.validation.Type object>, 'name': <google.appengine.api.validation.Type object>, 'volume_type': <google.appengine.api.validation.Type object>}
classgoogle.appengine.api.appinfo.VpcAccessConnector(**attributes)source

Bases:google.appengine.api.validation.Validated

Class representing the VPC Access connector configuration.

ATTRIBUTES = {'name': <google.appengine.api.validation.Regex object>}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-06-16 UTC.