Using the SDK for a Python function
Written by
Updated at July 8, 2022
The python37
and python38
runtime environments contain a built-in library for working with the Yandex Cloud API. To use it, you don't need to add a dependency to a Python application unless you need a version of the library other than the one built in. The library source code is available on GitHubrequirements.txt
.
The SDK (Software Development Kit)
import yandexcloud
from yandex.cloud.resourcemanager.v1.cloud_service_pb2 import ListCloudsRequest
from yandex.cloud.resourcemanager.v1.cloud_service_pb2_grpc import CloudServiceStub
def handler(event, context):
cloud_service = yandexcloud.SDK().client(CloudServiceStub)
clouds = {}
for c in cloud_service.List(ListCloudsRequest()).clouds:
clouds[c.id] = c.name
return clouds