class IndexDefinitions(validation.Validated): """Top level for index definition file. Attributes: indexes: List of Index definitions. """ ATTRIBUTES = { 'indexes': validation.Optional(validation.Repeated(Index)), }
class Index(validation.Validated): """Individual index definition. Order of the properties properties determins a given indixes sort priority. Attributes: kind: Datastore kind that index belongs to. ancestors: Include ancestors in index. properties: Properties to sort on. """ ATTRIBUTES = { 'kind': validation.TYPE_STR, 'ancestor': validation.Type(bool, default=False), 'properties': validation.Optional(validation.Repeated(Property)), }
class AdminConsole(validation.Validated): """Class representing admin console directives in application info. """ ATTRIBUTES = { PAGES: validation.Optional(validation.Repeated(AdminConsolePage)), } @classmethod def Merge(cls, adminconsole_one, adminconsole_two): """Return the result of merging two AdminConsole objects.""" if not adminconsole_one or not adminconsole_two: return adminconsole_one or adminconsole_two if adminconsole_one.pages: if adminconsole_two.pages: adminconsole_one.pages.extend(adminconsole_two.pages) else: adminconsole_one.pages = adminconsole_two.pages return adminconsole_one
class AppInfoExternal(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. Attributes: application: Unique identifier for application. version: Application's major version number. runtime: Runtime used by application. api_version: Which version of APIs to use. 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 URLMap.expiration field's documentation for more information. skip_files: An re object. Files that match this regular expression will not be uploaded by appcfg.py. For example: skip_files: | .svn.*| #.*# """ ATTRIBUTES = { APPLICATION: APPLICATION_RE_STRING, VERSION: VERSION_RE_STRING, RUNTIME: RUNTIME_RE_STRING, ADMIN_NAME: validation.Optional(str), MCYCLES_LIM: validation.Optional(int), REQTIME_LIM: validation.Optional(int), PROCMEM_LIM: validation.Optional(int), API_VERSION: API_VERSION_RE_STRING, BUILTINS: validation.Optional(validation.Repeated(BuiltinHandler)), INCLUDES: validation.Optional(validation.Type(list)), HANDLERS: validation.Optional(validation.Repeated(URLMap)), SERVICES: validation.Optional( validation.Repeated(validation.Regex(_SERVICE_RE_STRING))), DEFAULT_EXPIRATION: validation.Optional(_EXPIRATION_REGEX), SKIP_FILES: validation.RegexStr(default=DEFAULT_SKIP_FILES), DERIVED_FILE_TYPE: validation.Optional( validation.Repeated( validation.Options(JAVA_PRECOMPILED, PYTHON_PRECOMPILED))), ADMIN_CONSOLE: validation.Optional(AdminConsole), ERROR_HANDLERS: validation.Optional(validation.Repeated(ErrorHandlers)), } def CheckInitialized(self): """Performs non-regex-based validation. Ensures that at least one url mapping is provided in the URL mappers Also ensures that the major version doesn't contain the string -dot-. Raises: MissingURLMapping when no URLMap objects are present in object. TooManyURLMappings when there are too many URLMap entries. """ super(AppInfoExternal, self).CheckInitialized() if not self.handlers and not self.builtins and not self.includes: raise appinfo_errors.MissingURLMapping( 'No URLMap entries found in application configuration') if self.handlers and len(self.handlers) > MAX_URL_MAPS: raise appinfo_errors.TooManyURLMappings( 'Found more than %d URLMap entries in application configuration' % MAX_URL_MAPS) if self.version.find(ALTERNATE_HOSTNAME_SEPARATOR) != -1: raise validation.ValidationError( 'App version "%s" cannot contain the string "%s"' % (self.version, ALTERNATE_HOSTNAME_SEPARATOR))
class AppInclude(validation.Validated): """Class representing the contents of an included app.yaml file. Used for both builtins and includes directives. """ ATTRIBUTES = { BUILTINS: validation.Optional(validation.Repeated(BuiltinHandler)), INCLUDES: validation.Optional(validation.Type(list)), HANDLERS: validation.Optional(validation.Repeated(URLMap)), ADMIN_CONSOLE: validation.Optional(AdminConsole), } @classmethod def MergeAppYamlAppInclude(cls, appyaml, appinclude): """This function merges an app.yaml file with referenced builtins/includes. """ if not appinclude: return appyaml if appinclude.handlers: tail = appyaml.handlers or [] appyaml.handlers = [] for h in appinclude.handlers: if not h.position or h.position == 'head': appyaml.handlers.append(h) else: tail.append(h) appyaml.handlers.extend(tail) appyaml.admin_console = AdminConsole.Merge(appyaml.admin_console, appinclude.admin_console) return appyaml @classmethod def MergeAppIncludes(cls, appinclude_one, appinclude_two): """This function merges the non-referential state of the provided AppInclude objects. 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. Args: appinclude_one: object one to merge appinclude_two: object two to merge Returns: AppInclude object that is the result of merging the static directives of appinclude_one and appinclude_two. """ if not appinclude_one or not appinclude_two: return appinclude_one or appinclude_two if appinclude_one.handlers: if appinclude_two.handlers: appinclude_one.handlers.extend(appinclude_two.handlers) else: appinclude_one.handlers = appinclude_two.handlers appinclude_one.admin_console = (AdminConsole.Merge( appinclude_one.admin_console, appinclude_two.admin_console)) return appinclude_one
class QueueInfoExternal(validation.Validated): """QueueInfoExternal describes all queue entries for an application.""" ATTRIBUTES = { TOTAL_STORAGE_LIMIT: validation.Optional(_TOTAL_STORAGE_LIMIT_REGEX), QUEUE: validation.Optional(validation.Repeated(QueueEntry)), }