How to use the yandexcloud.SDK function in yandexcloud

To help you get started, we’ve selected a few yandexcloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yandex-cloud / python-sdk / examples / compute / main.py View on Github external
def main():
    logging.basicConfig(level=logging.INFO)
    arguments = parse_args()
    interceptor = yandexcloud.RetryInterceptor(max_retry_count=5, retriable_codes=[grpc.StatusCode.UNAVAILABLE])
    if arguments.token:
        sdk = yandexcloud.SDK(interceptor=interceptor, token=arguments.token)
    else:
        with open(arguments.sa_json_path) as infile:
            sdk = yandexcloud.SDK(interceptor=interceptor, service_account_key=json.load(infile))

    fill_missing_arguments(sdk, arguments)

    instance_id = None
    try:
        operation = create_instance(sdk, arguments.folder_id, arguments.zone, arguments.name, arguments.subnet_id)
        operation_result = sdk.wait_operation_and_get_result(
            operation,
            response_type=Instance,
            meta_type=CreateInstanceMetadata,
        )

        instance_id = operation_result.response.id
github yandex-cloud / python-sdk / examples / compute / main.py View on Github external
def main():
    logging.basicConfig(level=logging.INFO)
    arguments = parse_args()
    interceptor = yandexcloud.RetryInterceptor(max_retry_count=5, retriable_codes=[grpc.StatusCode.UNAVAILABLE])
    if arguments.token:
        sdk = yandexcloud.SDK(interceptor=interceptor, token=arguments.token)
    else:
        with open(arguments.sa_json_path) as infile:
            sdk = yandexcloud.SDK(interceptor=interceptor, service_account_key=json.load(infile))

    fill_missing_arguments(sdk, arguments)

    instance_id = None
    try:
        operation = create_instance(sdk, arguments.folder_id, arguments.zone, arguments.name, arguments.subnet_id)
        operation_result = sdk.wait_operation_and_get_result(
            operation,
            response_type=Instance,
            meta_type=CreateInstanceMetadata,
        )

        instance_id = operation_result.response.id

    finally:
        if instance_id:
github yandex-cloud / python-sdk / examples / mdb / postgresql / main.py View on Github external
def main():
    flags = parse_cmd()
    sdk = yandexcloud.SDK(token=flags.token)

    fill_missing_flags(sdk, flags)

    req = create_cluster_request(flags)
    cluster = None
    try:
        cluster = create_cluster(sdk, req)
        change_cluster_description(sdk, cluster)
        add_cluster_host(sdk, cluster, flags)
    finally:
        if cluster is not None:
            delete_cluster(sdk, cluster)
github yandex-cloud / python-sdk / examples / dataproc / main.py View on Github external
def main():
    arguments = parse_cmd()
    sdk = yandexcloud.SDK(token=arguments.token)

    fill_missing_flags(sdk, arguments)

    resources = common_pb.Resources(
        resource_preset_id='s2.micro',
        disk_size=15 * (1024 ** 3),
        disk_type_id='network-ssd',
    )
    req = create_cluster_request(arguments, resources=resources)
    cluster_id = None
    try:
        cluster = create_cluster(sdk, req)
        cluster_id = cluster.id
        change_cluster_description(sdk, cluster_id)
        add_subcluster(sdk, cluster_id, arguments, resources=resources)
github yandex-cloud / python-sdk / examples / mdb / mysql / main.py View on Github external
def main():
    flags = parse_cmd()
    sdk = yandexcloud.SDK(token=flags.token)

    fill_missing_flags(sdk, flags)

    req = create_cluster_request(flags)
    cluster = None
    try:
        cluster = create_cluster(sdk, req)
        change_cluster_description(sdk, cluster)
        add_cluster_host(sdk, cluster, flags)
    finally:
        if cluster is not None:
            delete_cluster(sdk, cluster)
github yandex-cloud / python-sdk / examples / mdb / mongodb / main.py View on Github external
def main():
    flags = parse_cmd()
    sdk = yandexcloud.SDK(token=flags.token)

    fill_missing_flags(sdk, flags)

    req = create_cluster_request(flags)
    cluster = None
    try:
        cluster = create_cluster(sdk, req)
        change_cluster_description(sdk, cluster)
        add_cluster_host(sdk, cluster, flags)
    finally:
        if cluster is not None:
            delete_cluster(sdk, cluster)