google.appengine.api.modules.modules module
Summary
Exposes methods to control services (modules) and versions of an app.
Services were formerly known as modules and the API methods still reflect that naming. For more information and code samples, see Using the Modules API.
Contents
- exception google.appengine.api.modules.modules.Errorsource
-
Bases: exceptions.Exception
Base-class for errors in this module.
- exception google.appengine.api.modules.modules.InvalidModuleErrorsource
-
Bases: google.appengine.api.modules.modules.Error
The given module is not known to the system.
- exception google.appengine.api.modules.modules.InvalidVersionErrorsource
-
Bases: google.appengine.api.modules.modules.Error
The given module version is not known to the system.
- exception google.appengine.api.modules.modules.InvalidInstancesErrorsource
-
Bases: google.appengine.api.modules.modules.Error
The given instances value is not valid.
- exception google.appengine.api.modules.modules.UnexpectedStateErrorsource
-
Bases: google.appengine.api.modules.modules.Error
An unexpected current state was found when starting/stopping a module.
- exception google.appengine.api.modules.modules.TransientErrorsource
-
Bases: google.appengine.api.modules.modules.Error
A transient error was encountered, 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 automatically-scaled modules; otherwise, None is returned.
ReturnsString containing the ID of the instance, or None if this is not an automatically-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.
Parametersmodule – Module to retrieve version for, if None then the current module will be used.
ReturnsList 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.
Parametersmodule – Module to retrieve the default version for, if None then the current module will be used.
ReturnsString 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.
Parameters-
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.
The number of instances that are set for the given module version.
RaisesInvalidVersionError 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.
Parameters-
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.
-
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.
Parameters-
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.
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.
Parameters-
module – String containing the name of the module to affect.
-
version – String containing the name of the version of the module to start.
-
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.
Parameters-
module – String containing the name of the module to affect.
-
version – String containing the name of the version of the module to start.
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.
Parameters-
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.
-
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.
Parameters-
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.
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.
Parameters-
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.
A valid canonical hostname that can be used to communicate with the given module/version/instance. For example:
Raises0.v1.module5.myapp.appspot.com
-
InvalidModuleError – if the given module version is invalid.
-
InvalidInstancesError – if the given instance value is invalid.
-
TypeError – if the given instance type is invalid.
-