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

class google.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>}
classmethod Merge(adminconsole_one, adminconsole_two)source

Returns the result of merging two AdminConsole objects.

class google.appengine.api.appinfo.AdminConsolePage(**attributes)source

Bases: google.appengine.api.validation.Validated

Class representing the admin console page in an AdminConsole object.

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

Bases: google.appengine.api.appinfo.HandlerBase

Class representing api_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>}
class google.appengine.api.appinfo.AppInclude(**attributes)source

Bases: google.appengine.api.validation.Validated

Class representing the contents of an included app.yaml file.

This class is used for both builtins and includes 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>}
classmethod MergeAppIncludes(appinclude_one, appinclude_two)source

Merges the non-referential state of the provided AppInclude.

That is, builtins and includes directives are not preserved, but any static objects are copied into an aggregate AppInclude object that preserves the directives of both provided AppInclude objects.

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

Parameters
  • appinclude_one – First AppInclude to merge.

  • appinclude_two – Second AppInclude to merge.

Returns

AppInclude object that is the result of merging the static directives of appinclude_one and appinclude_two. An updated version of appinclude_one is returned.

classmethod MergeAppYamlAppInclude(appyaml, appinclude)source

Merges an app.yaml file with referenced builtins/includes.

Parameters
  • appyaml – The app.yaml file that you want to update with appinclude.

  • appinclude – The includes that you want to merge into appyaml.

Returns

An updated app.yaml file that includes the directives you specified in appinclude.

classmethod MergeManualScaling(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 if ManualScaling gets additional fields.

Parameters
  • appinclude_one – The first object to merge. The object must have a manual_scaling field that contains a ManualScaling().

  • appinclude_two – The second object to merge. The object must have a manual_scaling field that contains a ManualScaling().

Returns

An object that is the result of merging appinclude_one.manual_scaling.instances and appinclude_two.manual_scaling.instances; this is returned as a revised appinclude_one object after the mutations are complete.

static MergeSkipFiles(skip_files_one, skip_files_two)source

Merges two skip_files directives.

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

  • skip_files_two – The second skip_files element that you want to merge.

Returns

A list of regular expressions that are merged.

class google.appengine.api.appinfo.AppInfoExternal(**attributes)source

Bases: google.appengine.api.validation.Validated

Class representing users application info.

This class is passed to a yaml_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 specify php-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 specific expiration set. See the documentation for the URLMap.expiration field for more information.

skip_files

A regular expression object. Files that match this regular expression will not be uploaded by appcfg.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 the AppInfoExternal.

Backend entries can contain directives that modify other parts of the app.yaml file, such as the start 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 the backends directive.

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

  • DuplicateBackend – If the backend is found more than once in the backends 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 exceed MAX_URL_MAPS.

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

  • If api_endpoints are defined, an api_config stanza must be defined.

  • If the runtime is python27 and threadsafe is set, then no CGI handlers can be used.

  • The version name doesn’t start with BUILTIN_NAME_PREFIX.

  • If redirect_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 – If library_name is specified more than once.

  • MissingURLMapping – If no URLMap object is present in the object.

  • TooManyURLMappings – If there are too many URLMap entries.

  • MissingApiConfig – If api_endpoints exists without an api_config.

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

  • ThreadsafeWithCgiHandler – If the runtime is python27, 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 as python25.

GetAllLibraries()source

Returns a list of all Library instances active for this configuration.

Returns

The list of active Library 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 underlying vm_runtime.

Returns

The value of beta/vm_settings.vm_runtime if runtime is vm, or runtime otherwise.

Return type

The effective runtime

GetNormalizedLibraries()source

Returns a list of normalized Library instances for this configuration.

Returns

The list of active Library instances for this configuration. This includes directly-specified libraries, their required dependencies, and any libraries enabled by default. Any libraries with latest 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.

class google.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>}
class google.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>}
class google.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>}
class google.appengine.api.appinfo.BetaSettings(**kwds)source

Bases: google.appengine.api.appinfo.VmSettings

Class for Beta (internal or unreleased) settings.

This class is meant to replace VmSettings eventually.

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

classmethod Merge(beta_settings_one, beta_settings_two)source

Merges two BetaSettings instances.

Parameters
  • beta_settings_one – The first BetaSettings instance, or None.

  • beta_settings_two – The second BetaSettings instance, or None.

Returns

The merged BetaSettings instance, or None if both input instances are None or empty.

class google.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 the validation.Options object that is returned by ATTRIBUTES.

ATTRIBUTES = {}
class DynamicAttributes(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 any get operation. The fixed value that you pass in as a constructor parameter should be a validation.Validated object.

GetUnnormalized(key)source
classmethod IsDefined(builtins_list, builtin_name)source

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

Parameters
  • builtins_list – A list of BuiltinHandler objects, typically yaml.builtins.

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

Returns

True if builtin_name is defined by a member of builtins_list; all other results return False.

classmethod ListToTuples(builtins_list)source

Converts a list of BuiltinHandler objects.

Parameters

builtins_list – A list of BuildinHandler objects to convert to tuples.

Returns

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

ToDict()source

Converts a BuiltinHander object to a dictionary.

Returns

on/off}` form

Return type

A dictionary in `{builtin_handler_name

classmethod Validate(builtins_list, runtime=None)source

Verifies that all BuiltinHandler objects are valid and not repeated.

Parameters
  • builtins_list – A list of BuiltinHandler 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 a BuiltinHandler object cannot be determined.

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

class google.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>}
class google.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.

class google.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

class google.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>
classmethod Merge(env_variables_one, env_variables_two)source

Merges two EnvironmentVariables instances.

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

Parameters
  • env_variables_one – The first EnvironmentVariables instance or None.

  • env_variables_two – The second EnvironmentVariables instance or None.

Returns

The merged EnvironmentVariables instance, or None if both input instances are None or empty.

VALUE_VALIDATOR

alias of str

class google.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.

class google.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>}
class google.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>}
class google.appengine.api.appinfo.HttpHeadersDict(**kwds)source

Bases: google.appengine.api.validation.ValidatedDict

A dict that limits keys and values to what http_headers allows.

http_headers is an static handler key; it applies to handlers with static_dir or static_files keys. The following code is an example of how http_headers is used:

handlers:
- url: /static
  static_dir: static
  http_headers:
    X-Foo-Header: foo value
    X-Bar-Header: bar value
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 to header_name. If more than one such value is in self, one of the values is selected arbitrarily and returned. The selection is not deterministic.

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

Bases: google.appengine.api.validation.Validator

Ensures that keys in HttpHeadersDict are valid.

HttpHeadersDict contains a list of headers. An instance is used as HttpHeadersDict’s KEY_VALIDATOR.

Validate(name, unused_key=None)source

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

HTTP header names are defined by RFC 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>
class ValueValidator(default=None)source

Bases: google.appengine.api.validation.Validator

Ensures that values in HttpHeadersDict are valid.

An instance is used as HttpHeadersDict’s VALUE_VALIDATOR.

static AssertHeaderNotTooLong(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 = <any OCTET except CTLs, but including LWS>
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.

class google.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.

class google.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 single AppInclude 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 of AppInclude 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 single AppInfo object where one and only one is expected.

This method validates that the values in the AppInfo 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 of AppInfoExternal 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 the backends directive.

  • yaml_errors.EventError – If the app.yaml file fails validation.

  • appinfo_errors.MultipleProjectNames – If the app.yaml file has both an application directive and a project directive.

class google.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>}
class google.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.

class google.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>}
class google.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>}
class google.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

class google.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 which handler-id attribute is used.

Every mapping can have one and only one handler type. Attempting to use more than one handler-id attribute will cause an UnknownHandlerType to be raised during validation. Failure to provide any handler-id attributes will cause MissingHandlerType to be raised during validation.

The regular expression used by the url 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 a url, such as /admin, is the same as matching against the regular expression ^/admin$. Don’t start your matching url with ^ or end them with $. These regular expressions won’t be accepted and will raise ValueError.

login

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

secure

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

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 maps url to the appropriate file. You can specify regular expression backreferences to the string matched to url.

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 the url and static_files arguments, this attribute must be included. This attribute is required when you define a static_files mapping. A matching file name must fully match against the upload regular expression, similar to how url is matched against the request path. Do not begin the upload argument with the ^ character or end it with the $ character.

static_dir

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

mime_type

When used with static_files and static_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 in AppInclude objects to specify whether a handler should be inserted at the beginning of the primary handler list or at the end. If tail is specified, the handler is inserted at the end; otherwise, the handler is inserted at the beginning. This behavior implies that head 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. The s 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 a static_dir handler, do not use a regular expression in the url attribute. Both the url and static_dir attributes are automatically mapped to these equivalents:

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

For example, this declaration…:

url: /images
static_dir: images_folder

…is equivalent to this static_files declaration:

url: /images/(.*)
static_files: images_folder/\1
upload: 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 that self.http_headers is consistent with self.mime_type.

This method assumes that self is a static handler, either self.static_dir or self.static_files. You cannot specify None.

Raises
appinfo_errors.ContentTypeSpecifiedMultipleTimes – If self.http_headers

contains a Content-Type header, and self.mime_type is set. For example, the following configuration would be rejected:

handlers:
- url: /static
  static_dir: static
  mime_type: text/html
  http_headers:
    content-type: text/html

As this example shows, a configuration will be rejected when http_headers and mime_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 normal ValidatedCheck, this method calls GetHandlerType, 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 – If mime_type is inconsistent with http_headers.

ErrorOnPositionForAppInfo()source

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

Raises

PositionUsedInAppYamlHandler – If the position attribute is specified for an app.yaml file instead of an include.yaml file.

FixSecureDefaults()source

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

The effect is that handler.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 the version 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 if source_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 to True, the handlers that are added as part of the includes 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.

class google.appengine.api.appinfo.VmHealthCheck(**attributes)source

Bases: google.appengine.api.appinfo.HealthCheck

Class representing the configuration of the VM health check.

class google.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>
classmethod Merge(vm_settings_one, vm_settings_two)source

Merges two VmSettings instances.

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

Parameters
  • vm_settings_one – The first VmSettings instance, or None.

  • vm_settings_two – The second VmSettings instance, or None.

Returns

The merged VmSettings instance, or None if both input instances are None or empty.

VALUE_VALIDATOR

alias of str

class google.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>}
class google.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>}