google.appengine.api.modules.modules module

Exposes methods to control modules and versions of an app.

exception google.appengine.api.modules.modules.Error[source]

Bases: exceptions.Exception

Base-class for errors in this module.

exception google.appengine.api.modules.modules.InvalidModuleError[source]

Bases: google.appengine.api.modules.modules.Error

The given module is not known to the system.

exception google.appengine.api.modules.modules.InvalidVersionError[source]

Bases: google.appengine.api.modules.modules.Error

The given module version is not known to the system.

exception google.appengine.api.modules.modules.InvalidInstancesError[source]

Bases: google.appengine.api.modules.modules.Error

The given instances value is not valid.

exception google.appengine.api.modules.modules.UnexpectedStateError[source]

Bases: google.appengine.api.modules.modules.Error

An unexpected current state was found when starting/stopping a module.

exception google.appengine.api.modules.modules.TransientError[source]

Bases: google.appengine.api.modules.modules.Error

A transient error was encountered, please retry the operation.

google.appengine.api.modules.modules.get_current_module_name()[source]

Returns the module name of the current instance.

If this is version “v1” of module “module5” for app “my-app”, this function will return “module5”.

google.appengine.api.modules.modules.get_current_version_name()[source]

Returns the version of the current instance.

If this is version “v1” of module “module5” for app “my-app”, this function will return “v1”.

google.appengine.api.modules.modules.get_current_instance_id()[source]

Returns the id of the current instance.

If this is instance 2 of version “v1” of module “module5” for app “my-app”, this function will return “2”.

This is only valid for manually-scheduled modules, None will be returned for automatically-scaled modules.

Returns:
String containing the id of the instance, or None if this is not a manually-scaled module.
google.appengine.api.modules.modules.get_modules()[source]

Returns a list of all modules for the application.

Returns:
List of strings containing the names of modules associated with this
application. The ‘default’ module will be included if it exists, as will the name of the module that is associated with the instance that calls this function.
google.appengine.api.modules.modules.get_versions(module=None)[source]

Returns a list of versions for a given module.

Args:
module: Module to retrieve version for, if None then the current module will
be used.
Returns:
List of strings containing the names of versions associated with the module. The current version will also be included in this list.
Raises:
InvalidModuleError if the given module isn’t valid, TransientError if there is an issue fetching the information.
google.appengine.api.modules.modules.get_default_version(module=None)[source]

Returns the name of the default version for the module.

Args:
module: Module to retrieve the default version for, if None then the current
module will be used.
Returns:
String containing the name of the default version of the module.
Raises:
InvalidModuleError if the given module is not valid, InvalidVersionError if no default version could be found.
google.appengine.api.modules.modules.get_num_instances(module=None, version=None)[source]

Return the number of instances that are set for the given module version.

This is only valid for fixed modules, an error will be raised for automatically-scaled modules. Support for automatically-scaled modules may be supported in the future.

Args:
module: String containing the name of the module to fetch this info for, if
None the module of the current instance will be used.
version: String containing the name of the version to fetch this info for,
if None the version of the current instance will be used. If that version does not exist in the other module, then an InvalidVersionError is raised.
Returns:
The number of instances that are set for the given module version.
Raises:
InvalidVersionError on invalid input.
google.appengine.api.modules.modules.set_num_instances(instances, module=None, version=None)[source]

Sets the number of instances on the module and version.

Args:

instances: The number of instances to set. module: The module to set the number of instances for, if None the current

module will be used.
version: The version set the number of instances for, if None the current
version will be used.
Raises:
InvalidVersionError if the given module version isn’t valid, TransientError if there is an issue persisting the change. TypeError if the given instances type is invalid.
google.appengine.api.modules.modules.set_num_instances_async(instances, module=None, version=None)[source]

Returns a UserRPC to set the number of instances on the module version.

Args:

instances: The number of instances to set. module: The module to set the number of instances for, if None the current

module will be used.
version: The version set the number of instances for, if None the current
version will be used.
Returns:
A UserRPC to set the number of instances on the module version.
google.appengine.api.modules.modules.start_version(module, version)[source]

Start all instances for the given version of the module.

Args:
module: String containing the name of the module to affect. version: String containing the name of the version of the module to start.
Raises:
InvalidVersionError if the given module version is invalid. TransientError if there is a problem persisting the change.
google.appengine.api.modules.modules.start_version_async(module, version)[source]

Returns a UserRPC to start all instances for the given module version.

Args:
module: String containing the name of the module to affect. version: String containing the name of the version of the module to start.
Returns:
A UserRPC to start all instances for the given module version.
google.appengine.api.modules.modules.stop_version(module=None, version=None)[source]

Stops all instances for the given version of the module.

Args:

module: The module to affect, if None the current module is used. version: The version of the given module to affect, if None the current

version is used.
Raises:
InvalidVersionError if the given module version is invalid. TransientError if there is a problem persisting the change.
google.appengine.api.modules.modules.stop_version_async(module=None, version=None)[source]

Returns a UserRPC to stop all instances for the given module version.

Args:

module: The module to affect, if None the current module is used. version: The version of the given module to affect, if None the current

version is used.
Returns:
A UserRPC to stop all instances for the given module version.
google.appengine.api.modules.modules.get_hostname(module=None, version=None, instance=None)[source]

Returns a hostname to use to contact the module.

Args:

module: Name of module, if None, take module of the current instance. version: Name of version, if version is None then either use the version of

the current instance if that version exists for the target module, otherwise use the default version of the target module.
instance: Instance to construct a hostname for, if instance is None, a
loadbalanced hostname for the module will be returned. If the target module is not a fixed module, then instance is not considered valid.
Returns:
A valid canonical hostname that can be used to communicate with the given module/version/instance. E.g. 0.v1.module5.myapp.appspot.com
Raises:
InvalidModuleError if the given moduleversion is invalid. InvalidInstancesError if the given instance value is invalid. TypeError if the given instance type is invalid.