\google\appengine\api\modules\ModulesService

FINAL

Methods

getCurrentModuleName

STATIC   

getCurrentModuleName() : string

Gets the name of the currently running module.

Returns

string

The name of the current module. For example, if this is version "v1" of module "module5" for app "my-app", this function will return "module5".

getCurrentVersionName

STATIC   

getCurrentVersionName() : string

Gets the version of the currently running module.

Returns

string

The name of the current module. For example, if this is version "v1" of module "module5" for app "my-app", this function will return "v1".

getCurrentInstanceId

STATIC   

getCurrentInstanceId() : string

Gets the id of the currently running instance.

Returns

string

The name of the current module. For example, if this is instance 2 of version "v1" of module "module5" for app "my-app", this function will return "2". For automatically-scaled modules, this function will return a unique hex string for the instance (e.g. "00c61b117c7f7fd0ce9e1325a04b8f0df30deaaf").

getModules

STATIC   

getModules() : array<mixed,string>

Gets an array of all the modules for the application.

Returns

array<mixed,string>

An array of string containing the names of the modules associated with the 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.

getVersions

STATIC   

getVersions(string $module = null) : array<mixed,string>

Get an array of all versions associated with a module.

Parameters

Name Description

$module

string

The name of the module to retrieve the versions for. If null then the versions for the current module will be retrieved.

Throws

\InvalidArgumentException

If $module is not a string.

\google\appengine\api\modules\ModulesException

If the given $module isn't valid.

\google\appengine\api\modules\TransientModulesException

if there is an issue fetching the information.

Returns

array<mixed,string>

An array of strings containing the names of versions associated with the module. The current version will also be included in this list.

getDefaultVersion

STATIC   

getDefaultVersion(string $module = null) : string

Get the default version of a module.

Parameters

Name Description

$module

string

The name of the module to retrieve the default versions for. If null then the default versions for the current module will be retrieved.

Throws

\InvalidArgumentException

If $module is not a string.

\google\appengine\api\modules\ModulesException

If the given $module is invalid or if no default version could be found.

Returns

string

The default version of the module.

getNumInstances

STATIC   

getNumInstances(string $module = null, string $version = null) : integer

Get the number of instances set for a version of a module.

This function does not work on automatically-scaled modules.

Parameters

Name Description

$module

string

The name of the module to retrieve the count for. If null then the count for the current module will be retrieved.

$version

string

The version of the module to retrieve the count for. If null then the count for the version of the current instance will be retrieved.

Throws

\InvalidArgumentException

If $module or $version is not a string.

\google\appengine\api\modules\ModulesException

if the given combination of $module and $version is invalid.

Returns

integer

The number of instances set for the current module version.

setNumInstances

STATIC   

setNumInstances( $instances, string $module = null, string $version = null)

Set the number of instances for a version of a module.

This function does not work on automatically-scaled modules.

Parameters

Name Description

$instances

$module

string

The name of the module to set the instance count for. If null then the instance count for the current module will be set.

$version

string

The version of the module to set the instance count for. If null then the count for the version of the current instance will be set.

Throws

\InvalidArgumentException

If $instances is not an integer or if $module or $version is not a string.

\google\appengine\api\modules\ModulesException

if the given combination of $module and $version is invalid.

\google\appengine\api\modules\TransientModulesException

if there is an issue setting the instance count.

startVersion

STATIC   

startVersion(string $module, string $version)

Starts all instances of the given version of a module.

*

Parameters

Name Description

$module

string

The name of the module to start.

$version

string

The version of the module to start.

Throws

\InvalidArgumentException

If $module or $version is not a string.

\google\appengine\api\modules\ModulesException

if the given combination of $module and $version is invalid.

\google\appengine\api\modules\InvalidModuleStateException

if the given $version is already started or cannot be started.

\google\appengine\api\modules\TransientModulesException

if there is an issue starting the module version.

stopVersion

STATIC   

stopVersion(string $module = null, string $version = null)

Stops all instances of the given version of a module.

*

Parameters

Name Description

$module

string

The name of the module to stop. If null then the current module will be stopped.

$version

string

The version of the module to stop. If null then the current version will be stopped.

Throws

\InvalidArgumentException

If $module or $version is not a string.

\google\appengine\api\modules\ModulesException

if the given combination of $module and $version instance is invalid.

\google\appengine\api\modules\InvalidModuleStateException

if the given $version is already stopped or cannot be stopped.

\google\appengine\api\modules\TransientModulesException

if there is an issue stopping the module version.

getHostname

STATIC   

getHostname(string $module = null, string $version = null, string $instance = null) : string

Returns the hostname to use when contacting a module.

*

Parameters

Name Description

$module

string

The name of the module whose hostname should be returned. If null then the hostname of the current module will be returned.

$version

string

The version of the module whose hostname should be returned. If null then the hostname for the version of the current instance will be returned.

$instance

string

The instance whose hostname should be returned. If null then the load balanced hostname for the module will be returned. If the module is not a fixed module then the instance parameter is ignored.

Throws

\InvalidArgumentException

If $module or $version is not a string or if $instance is not a string or integer.

\google\appengine\api\modules\ModulesException

if the given combination of $module and $instance is invalid.

Returns

string

The valid canonical hostname that can be used to communicate with the given module/version/instance e.g. "0.version1.module5.myapp.appspot.com".