# Interface ModulesService (5.0.3)

    public interface ModulesService

ModulesService allows the application to fetch information about its
own module and version information. Additionally, the service has the
ability to start, stop and change the number of instances associated with a
module version.

## Methods

### getCurrentInstanceId()

    public abstract String getCurrentInstanceId()

Get the id of the current instance.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | current instance id |

### getCurrentModule()

    public abstract String getCurrentModule()

Get the name of the current module. ("default" if modules are not enabled for this app)

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | the name of the module |

### getCurrentVersion()

    public abstract String getCurrentVersion()

Get the name of the current version.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | the name of the version |

### getDefaultVersion(String module)

    public abstract String getDefaultVersion(String module)

Returns the name of the default version for the module.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the module or null for the current module |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getInstanceHostname(String module, String version, String instance)

    public abstract String getInstanceHostname(String module, String version, String instance)

Returns a host name to use for the given module, version and instance.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the module or null to indicate the current module |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the version or null to indicate the current version |
| `instance` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the id of a particular instance to address |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` | the hostname of the given instance |

### getModules()

    public abstract Set<String> getModules()

Get the set of modules that are available to the application.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Set.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` | Set of modules available to the application |

### getNumInstances(String module, String version)

    public abstract int getNumInstances(String module, String version)

Returns the number of instances that are available to the given
manual scaling module version.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the module or null for the current module |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the version or null for the current version |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getVersionHostname(String module, String version)

    public abstract String getVersionHostname(String module, String version)

Returns a host name to use for the given module and version.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the module or null to indicate the current module |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the version or null to indicate the current version |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getVersions(String module)

    public abstract Set<String> getVersions(String module)

Returns the set of versions that are available to the given module.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the module or null for the current module |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Set.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### setNumInstances(String module, String version, long instances)

    public abstract void setNumInstances(String module, String version, long instances)

Set the number of instances that are available to the given manual
scaling module version. Changing the number of instances is an
asynchronous process so this may return before added instances begin
serving or removed instances stop serving.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the module or null for the current module |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the version or null for the current version |
| `instances` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` the number of instances to set |

### setNumInstancesAsync(String module, String version, long instances)

    public abstract Future<Void> setNumInstancesAsync(String module, String version, long instances)

Starts an asynchronous call to [#setNumInstances](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.modules.ModulesService#com_google_appengine_api_modules_ModulesService_setNumInstances_) and returns a [Future](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html) to obtain
its eventual result. When the returned [Future](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html) yields a successful result
[ModulesService](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.modules.ModulesService) will have successfully initiated the process of setting the number of
instances. There may be some delay before added instances start serving or removed instances
stop serving.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `instances` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html<https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html>` |   |

### startVersion(String module, String version)

    public abstract void startVersion(String module, String version)

Starts the given manual scaling or basic scaling module version. Starting a version is an
asynchronous process so this may return before the started version is serving. If the
requested module version is already started this returns without error.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the module |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the version |

### startVersionAsync(String module, String version)

    public abstract Future<Void> startVersionAsync(String module, String version)

Starts an asynchronous call to [#startVersion](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.modules.ModulesService#com_google_appengine_api_modules_ModulesService_startVersion_) and returns a [Future](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html) to obtain its
eventual result. When the returned [Future](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html) yields a successful result
[ModulesService](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.modules.ModulesService) will have successfully initiated the process of starting the requested
version. There may be some delay before the version starts serving.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html<https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html>` |   |

### stopVersion(String module, String version)

    public abstract void stopVersion(String module, String version)

Stops the given manual scaling or basic scaling module version. Stopping a version is an
asynchronous process so this may return before the stopped version stops serving. If the
requested module version is already stopped this returns without error.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the module or null for the current module |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the name of the version or null for the current version |

### stopVersionAsync(String module, String version)

    public abstract Future<Void> stopVersionAsync(String module, String version)

Starts an asynchronous call to [#stopVersion](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.modules.ModulesService#com_google_appengine_api_modules_ModulesService_stopVersion_) and returns a [Future](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html) to obtain its
eventual result. When the returned [Future](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html) yields a successful result
[ModulesService](https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.modules.ModulesService) will have successfully initiated the process of stopping the requested
version. There may be some delay before the version stops serving.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `module` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `version` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html<https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html>` |   |