yandex-cloud / go-sdk

Yandex.Cloud Go SDK
MIT License
81 stars 15 forks source link

Cant update instance label #15

Closed kvmukhin closed 1 year ago

kvmukhin commented 1 year ago

I trying update label exist compute instance through UpdateInstanceRequest, but get error rpc error: code = InvalidArgument desc = Request validation error: Unable to update selected parameters at once. Can you take simple example? My function

func setLabels(ctx context.Context, sdk *ycsdk.SDK, instance Instance, label map[string]string) {
    req := &compute.UpdateInstanceRequest{InstanceId: instance.Id}
    req.SetLabels(label)
    op, err := sdk.WrapOperation(sdk.Compute().Instance().Update(ctx, req))
    if err != nil {
        log.Fatal(err)
    }
    err = op.Wait(ctx)
    if err != nil {
        log.Fatal(err)
    }
}
kvmukhin commented 1 year ago

Finded answer https://github.com/yandex-cloud/terraform-provider-yandex/blob/bfe7aeb6a4351eb202391e1959b4b9bfe5c9f742/yandex/resource_yandex_compute_instance.go#L815-L835