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
AdminConsoleobjects.
- class google.appengine.api.appinfo.AdminConsolePage(**attributes)source
-
Bases: google.appengine.api.validation.Validated
Class representing the admin console page in an
AdminConsoleobject.- ATTRIBUTES = {'url': '(?!\\^)/.*|\\..*|(\\(.).*(?!\\$).', 'name': '^.+$'}
- class google.appengine.api.appinfo.ApiConfigHandler(**attributes)source
-
Bases: google.appengine.api.appinfo.HandlerBase
Class representing
api_confighandler 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.yamlfile.This class is used for both
builtinsandincludesdirectives.- 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,
builtinsandincludesdirectives are not preserved, but any static objects are copied into an aggregateAppIncludeobject that preserves the directives of both providedAppIncludeobjects.
Parametersappinclude_oneis updated to be the merged result in this process.-
appinclude_one – First
AppIncludeto merge. -
appinclude_two – Second
AppIncludeto merge.
AppIncludeobject that is the result of merging the static directives ofappinclude_oneandappinclude_two. An updated version ofappinclude_oneis returned.-
- classmethod MergeAppYamlAppInclude(appyaml, appinclude)source
Merges an
Parametersapp.yamlfile with referenced builtins/includes.-
appyaml – The
app.yamlfile that you want to update withappinclude. -
appinclude – The includes that you want to merge into
appyaml.
An updated
app.yamlfile that includes the directives you specified inappinclude.-
- classmethod MergeManualScaling(appinclude_one, appinclude_two)source
Takes the greater of
<manual_scaling.instances>from the arguments.appinclude_oneis mutated to be the merged result in this process.Also, this function must be updated if
ParametersManualScalinggets additional fields.-
appinclude_one – The first object to merge. The object must have a
manual_scalingfield that contains aManualScaling(). -
appinclude_two – The second object to merge. The object must have a
manual_scalingfield that contains aManualScaling().
An object that is the result of merging
appinclude_one.manual_scaling.instancesandappinclude_two.manual_scaling.instances; this is returned as a revisedappinclude_oneobject after the mutations are complete.-
- static MergeSkipFiles(skip_files_one, skip_files_two)source
Merges two
Parametersskip_filesdirectives.-
skip_files_one – The first
skip_fileselement that you want to merge. -
skip_files_two – The second
skip_fileselement that you want to merge.
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_objectbuilder 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-quercusif 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
expirationset. See the documentation for theURLMap.expirationfield 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
Parametersapp.yamlfile, such as thestartdirective, which adds a handler for the start request. This method performs those modifications.backend_name – The name of a backend that is defined in the
Raisesbackendsdirective.-
BackendNotFound – If the indicated backend was not listed in the
backendsdirective. -
DuplicateBackend – If the backend is found more than once in the
backendsdirective.
-
- 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_endpointsare defined, anapi_configstanza must be defined. -
If the
runtimeispython27andthreadsafeis set, then no CGI handlers can be used. -
The version name doesn’t start with
BUILTIN_NAME_PREFIX. -
If
redirect_http_response_codeexists, it is in the list of valid 300s. -
Module and service aren’t both set. Services were formerly known as modules.
-
-
DuplicateLibrary – If
library_nameis specified more than once. -
MissingURLMapping – If no
URLMapobject is present in the object. -
TooManyURLMappings – If there are too many
URLMapentries. -
MissingApiConfig – If
api_endpointsexists without anapi_config. -
MissingThreadsafe – If
threadsafeis not set but the runtime requires it. -
ThreadsafeWithCgiHandler – If the
runtimeispython27,threadsafeis 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
ReturnsLibraryinstances active for this configuration.The list of active
Libraryinstances 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
Returnsvm_runtime.The value of
Return typebeta/vm_settings.vm_runtimeifruntimeisvm, orruntimeotherwise.The effective runtime
- GetNormalizedLibraries()source
Returns a list of normalized
ReturnsLibraryinstances for this configuration.The list of active
Libraryinstances for this configuration. This includes directly-specified libraries, their required dependencies, and any libraries enabled by default. Any libraries withlatestas 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.
Parametersruntime – 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
VmSettingseventually.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
ParametersBetaSettingsinstances.-
beta_settings_one – The first
BetaSettingsinstance, orNone. -
beta_settings_two – The second
BetaSettingsinstance, orNone.
The merged
BetaSettingsinstance, orNoneif both input instances areNoneor 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.Optionsobject that is returned byATTRIBUTES.- 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
getoperation. The fixed value that you pass in as a constructor parameter should be avalidation.Validatedobject.
- 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
BuiltinHandlerobjects, typicallyyaml.builtins. -
builtin_name – The name of the built-in that you want to determine whether it is defined.
Trueifbuiltin_nameis defined by a member ofbuiltins_list; all other results returnFalse.-
- classmethod ListToTuples(builtins_list)source
Converts a list of
ParametersBuiltinHandlerobjects.builtins_list – A list of
ReturnsBuildinHandlerobjects to convert to tuples.A list of
(name, status)that is derived from theBuiltinHandlerobjects.
- ToDict()source
Converts a
ReturnsBuiltinHanderobject to a dictionary.on/off}` form
Return typeA dictionary in `{builtin_handler_name
- classmethod Validate(builtins_list, runtime=None)source
Verifies that all
ParametersBuiltinHandlerobjects are valid and not repeated.-
builtins_list – A list of
BuiltinHandlerobjects to validate. -
runtime – If you specify this argument, warnings are generated for built-ins that have been deprecated in the given runtime.
-
InvalidBuiltinFormat – If the name of a
BuiltinHandlerobject cannot be determined. -
DuplicateBuiltinsSpecified – If a
BuiltinHandlername 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.
err if it’s not ASCII-safe.
Returnss 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
EnvironmentVariablesinstances.If a variable is specified by both instances, the value from
Parametersenv_variables_twois used.-
env_variables_one – The first
EnvironmentVariablesinstance orNone. -
env_variables_two – The second
EnvironmentVariablesinstance orNone.
The merged
EnvironmentVariablesinstance, orNoneif both input instances areNoneor 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.
ReturnsTuple 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_headersallows.http_headersis an static handler key; it applies to handlers withstatic_dirorstatic_fileskeys. The following code is an example of howhttp_headersis 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.
Parametersheader_name – HTTP header name to look for.
ReturnsA header value that corresponds to
header_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>
- class KeyValidator(default=None)source
-
Bases: google.appengine.api.validation.Validator
Ensures that keys in
HttpHeadersDictare valid.HttpHeadersDictcontains 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 by RFC 2616, section 4.2.
Parameters-
name – HTTP header field value.
-
unused_key – Unused.
name argument, unchanged.
Raisesappinfo_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
HttpHeadersDictare valid.An instance is used as
HttpHeadersDict’sVALUE_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”:
ParametersTEXT = <any OCTET except CTLs, but including LWS>-
value – HTTP header field value.
-
key – HTTP header field name.
A value argument.
Raisesappinfo_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
ParametersAppIncludeobject where one and only one is expected.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.
ReturnsAn instance of
RaisesAppIncludeas loaded from a YAML file.-
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
AppInfoobject where one and only one is expected.This method validates that the values in the
ParametersAppInfomatch the validators that are defined in this file, in particular,AppInfoExternal.ATTRIBUTES.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.
ReturnsAn instance of
RaisesAppInfoExternalas loaded from a YAML file.-
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
backendsdirective. -
yaml_errors.EventError – If the
app.yamlfile fails validation. -
appinfo_errors.MultipleProjectNames – If the
app.yamlfile has both anapplicationdirective and aprojectdirective.
-
- 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.
Parametersexpiration – String that matches
Returns_DELTA_REGEX.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-idattribute is used.Every mapping can have one and only one handler type. Attempting to use more than one
handler-idattribute will cause anUnknownHandlerTypeto be raised during validation. Failure to provide anyhandler-idattributes will causeMissingHandlerTypeto be raised during validation.The regular expression used by the
urlfield 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 matchingurlwith^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 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,HTTPSoreither.
- 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
urlto 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 the
urlandstatic_filesarguments, this attribute must be included. This attribute is required when you define astatic_filesmapping. A matching file name must fully match against theuploadregular expression, similar to howurlis matched against the request path. Do not begin theuploadargument with the^character or end it with the$character.
- static_dir
-
Specifies the handler ID that maps the provided
urlto a sub-directory within the application directory. See “Special cases.”
- mime_type
-
When used with
static_filesandstatic_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
AppIncludeobjects to specify whether a handler should be inserted at the beginning of the primary handler list or at the end. Iftailis specified, the handler is inserted at the end; otherwise, the handler is inserted at the beginning. This behavior implies thatheadis 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. Thesfor “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_dirhandler, do not use a regular expression in theurlattribute. Both theurlandstatic_dirattributes are automatically mapped to these equivalents:<url>/(.*) <static_dir>/\1For example, this declaration…:
url: /images static_dir: images_folder…is equivalent to this
static_filesdeclaration: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_headersis consistent withself.mime_type.This method assumes that
Raisesselfis a static handler, eitherself.static_dirorself.static_files. You cannot specifyNone.- appinfo_errors.ContentTypeSpecifiedMultipleTimes – If
self.http_headers -
contains a
Content-Typeheader, andself.mime_typeis 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_headersandmime_typespecify a content type, even when they specify the same content type.- appinfo_errors.ContentTypeSpecifiedMultipleTimes – If
- 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
RaisesValidatedCheck, this method callsGetHandlerType, which validates whether all of the handler fields are configured properly.-
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_typeis inconsistent withhttp_headers.
-
- ErrorOnPositionForAppInfo()source
Raises an error if position is specified outside of AppInclude objects.
RaisesPositionUsedInAppYamlHandler – If the
positionattribute is specified for anapp.yamlfile instead of aninclude.yamlfile.
- FixSecureDefaults()source
-
Forces omitted
securehandler fields to be set to ‘secure: optional’.The effect is that
handler.secureis never equal to the nominal default.
- GetHandler()source
Gets the handler for a mapping.
ReturnsThe value of the handler, as determined by the handler ID attribute.
- GetHandlerType()source
Gets the handler type of a mapping.
ReturnsThe 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.
Parametersfilename –
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.
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
Parameterssource_refscontains a valid list of source references.source_refs – A multi-line string containing one source reference per line.
RaisesValidationError – If the reference is malformed.
- google.appengine.api.appinfo.ValidateHandlers(handlers, is_include_file=False)source
Validates a list of handler (
ParametersURLMap) objects.-
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 theincludesdirective are validated.
-
- google.appengine.api.appinfo.ValidateSourceReference(ref)source
Determines if a source reference is valid.
Parametersref – A source reference in the following format:
Raises[repository_uri#]revision.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
VmSettingsinstances.If a variable is specified by both instances, the value from
Parametersvm_settings_oneis used.-
vm_settings_one – The first
VmSettingsinstance, orNone. -
vm_settings_two – The second
VmSettingsinstance, orNone.
The merged
VmSettingsinstance, orNoneif both input instances areNoneor 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>}