[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Functions](../../index.md) > [Developing in Kotlin](index.md) > Using the SDK

# Using the SDK for a function in Kotlin

The [runtime](../../concepts/runtime/index.md) does not have a pre-installed library for accessing the [Yandex Cloud API](../../../api-design-guide/index.md). To use it, add a [dependency](dependencies.md) to your Kotlin application. The library source code is available on [GitHub](https://github.com/yandex-cloud/java-sdk).

{% note warning %}

From the `java-sdk-serverless` and `java-sdk-functions` modules, only `java-sdk-serverless` is available for Kotlin. There are no restrictions on other modules.

{% endnote %}

The [SDK (Software Development Kit)](https://en.wikipedia.org/wiki/Software_development_kit) helps you manage Yandex Cloud resources using the [service account](../../operations/function-sa.md) specified in the function parameters.

## Example {#example}

The following function gets the folder ID (`folderId`), gets authorized in the SDK, retrieves a list of all Compute Cloud VMs in the specified folder, and restarts those that are stopped. As a result, it returns a message with the number of running VMs.

{% note warning %}

Invoke the function using the [Yandex Cloud CLI](../../concepts/function-invoke.md) or an HTTP request with the `?integration=raw` parameter.

{% endnote %}

```kotlin
import yandex.cloud.api.compute.v1.InstanceOuterClass
import yandex.cloud.api.compute.v1.InstanceServiceGrpc
import yandex.cloud.api.compute.v1.InstanceServiceOuterClass
import yandex.cloud.sdk.ServiceFactory
import yandex.cloud.sdk.auth.Auth

fun handle(folderId: String): String {
    // Getting authorized in the SDK via the service account
    val defaultComputeEngine = Auth.computeEngineBuilder().build()
    val factory = ServiceFactory.builder()
        .credentialProvider(defaultComputeEngine)
        .build()
    val instanceService = factory.create(
        InstanceServiceGrpc.InstanceServiceBlockingStub::class.java,
        InstanceServiceGrpc::newBlockingStub
    )
    val listInstancesRequest =
        InstanceServiceOuterClass.ListInstancesRequest.newBuilder().setFolderId(folderId).build()
    // Getting the list of VMs by `folderId` specified in the request
    val instances = instanceService.list(listInstancesRequest).instancesList
    var count = 0
    for (instance in instances) {
        if (instance.status != InstanceOuterClass.Instance.Status.RUNNING) {
            val startInstanceRequest =
                InstanceServiceOuterClass.StartInstanceRequest.newBuilder().setInstanceId(instance.id).build()
            // Starting VMs with IDs specified in the request
            val startInstanceResponse = instanceService.start(startInstanceRequest)
            if (!startInstanceResponse.hasError()) {
                count++
            }
        }
    }
    return "Started $count instances"
}
```