Class: VersSdk::VersSdkClient

Inherits:
Object
  • Object
show all
Defined in:
lib/vers_sdk/client.rb

Overview

HTTP client for Orchestrator Control Plane API.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url: nil, api_key: nil, max_retries: 2, timeout: 30) ⇒ VersSdkClient

Returns a new instance of VersSdkClient.

Parameters:

  • base_url (String, nil) (defaults to: nil)

    API base URL (default: VERS_BASE_URL env or api.vers.sh)

  • api_key (String, nil) (defaults to: nil)

    Bearer token (default: VERS_API_KEY env)

  • max_retries (Integer) (defaults to: 2)

    Maximum number of retries (default: 2)

  • timeout (Numeric) (defaults to: 30)

    Request timeout in seconds (default: 30)



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/vers_sdk/client.rb', line 45

def initialize(base_url: nil, api_key: nil, max_retries: 2, timeout: 30)
  @base_url = base_url || ENV.fetch("VERS_BASE_URL", "https://api.vers.sh")
  @api_key = api_key || ENV["VERS_API_KEY"]
  @max_retries = max_retries
  @timeout = timeout
  @logger = self.class.build_logger
  @default_headers = {
    "Content-Type" => "application/json",
    "Accept" => "application/json",
    "User-Agent" => "vers-sdk/0.1.9 ruby/#{RUBY_VERSION} #{RUBY_PLATFORM}"
  }
  @default_headers["Authorization"] = "Bearer #{@api_key}" if @api_key
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



39
40
41
# File 'lib/vers_sdk/client.rb', line 39

def base_url
  @base_url
end

#max_retriesObject (readonly)

Returns the value of attribute max_retries.



39
40
41
# File 'lib/vers_sdk/client.rb', line 39

def max_retries
  @max_retries
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



39
40
41
# File 'lib/vers_sdk/client.rb', line 39

def timeout
  @timeout
end

Class Method Details

.build_loggerObject



59
60
61
62
63
64
65
66
67
# File 'lib/vers_sdk/client.rb', line 59

def self.build_logger
  logger = Logger.new($stdout)
  env_level = ENV.fetch("VERS_LOG", "warn").downcase
  logger.level = LOG_LEVEL_MAP.fetch(env_level, Logger::WARN)
  logger.formatter = proc { |severity, datetime, _progname, msg|
    "#{datetime} [vers_sdk #{severity}] #{msg}\n"
  }
  logger
end

Instance Method Details

#branch_by_commit(commit_id, body: nil, params: nil, options: nil) ⇒ Object



514
515
516
517
518
519
520
521
522
# File 'lib/vers_sdk/client.rb', line 514

def branch_by_commit(commit_id, body: nil, params: nil, options: nil)
  path = sprintf("/api/v1/vm/branch/by_commit/%s", commit_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("POST", path, options: options, body: body, query: query)
end

#branch_by_ref(repo_name, tag_name, body: nil, params: nil, options: nil) ⇒ Object



239
240
241
242
243
244
245
246
247
# File 'lib/vers_sdk/client.rb', line 239

def branch_by_ref(repo_name, tag_name, body: nil, params: nil, options: nil)
  path = sprintf("/api/v1/vm/branch/by_ref/%s/%s", repo_name, tag_name)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("POST", path, options: options, body: body, query: query)
end

#branch_by_tag(tag_name, body: nil, params: nil, options: nil) ⇒ Object



274
275
276
277
278
279
280
281
282
# File 'lib/vers_sdk/client.rb', line 274

def branch_by_tag(tag_name, body: nil, params: nil, options: nil)
  path = sprintf("/api/v1/vm/branch/by_tag/%s", tag_name)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("POST", path, options: options, body: body, query: query)
end

#branch_by_vm(vm_id, body: nil, params: nil, options: nil) ⇒ Object



415
416
417
418
419
420
421
422
423
# File 'lib/vers_sdk/client.rb', line 415

def branch_by_vm(vm_id, body: nil, params: nil, options: nil)
  path = sprintf("/api/v1/vm/branch/by_vm/%s", vm_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("POST", path, options: options, body: body, query: query)
end

#branch_vm(vm_or_commit_id, body: nil, params: nil, options: nil) ⇒ Object



303
304
305
306
307
308
309
310
311
# File 'lib/vers_sdk/client.rb', line 303

def branch_vm(vm_or_commit_id, body: nil, params: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/branch", vm_or_commit_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("POST", path, options: options, body: body, query: query)
end

#commit_vm(vm_id, body: nil, params: nil, options: nil) ⇒ Object



438
439
440
441
442
443
444
445
446
# File 'lib/vers_sdk/client.rb', line 438

def commit_vm(vm_id, body: nil, params: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/commit", vm_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("POST", path, options: options, body: body, query: query)
end

#create_domain(body: nil, options: nil) ⇒ Object



496
497
498
499
# File 'lib/vers_sdk/client.rb', line 496

def create_domain(body: nil, options: nil)
  path = "/api/v1/domains"
  request("POST", path, options: options, body: body)
end

#create_image(body: nil, options: nil) ⇒ Object



344
345
346
347
# File 'lib/vers_sdk/client.rb', line 344

def create_image(body: nil, options: nil)
  path = "/api/v1/images/create"
  request("POST", path, options: options, body: body)
end

#create_new_root_vm(body: nil, params: nil, options: nil) ⇒ Object



228
229
230
231
232
233
234
235
236
# File 'lib/vers_sdk/client.rb', line 228

def create_new_root_vm(body: nil, params: nil, options: nil)
  path = "/api/v1/vm/new_root"
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("POST", path, options: options, body: body, query: query)
end

#create_repo_tag(repo_name, body: nil, options: nil) ⇒ Object



164
165
166
167
# File 'lib/vers_sdk/client.rb', line 164

def create_repo_tag(repo_name, body: nil, options: nil)
  path = sprintf("/api/v1/repositories/%s/tags", repo_name)
  request("POST", path, options: options, body: body)
end

#create_repository(body: nil, options: nil) ⇒ Object



116
117
118
119
# File 'lib/vers_sdk/client.rb', line 116

def create_repository(body: nil, options: nil)
  path = "/api/v1/repositories"
  request("POST", path, options: options, body: body)
end

#create_tag(body: nil, options: nil) ⇒ Object



134
135
136
137
# File 'lib/vers_sdk/client.rb', line 134

def create_tag(body: nil, options: nil)
  path = "/api/v1/commit_tags"
  request("POST", path, options: options, body: body)
end

#delete_commit(commit_id, options: nil) ⇒ Object



449
450
451
452
# File 'lib/vers_sdk/client.rb', line 449

def delete_commit(commit_id, options: nil)
  path = sprintf("/api/v1/commits/%s", commit_id)
  request("DELETE", path, options: options)
end

#delete_domain(domain_id, options: nil) ⇒ Object



362
363
364
365
# File 'lib/vers_sdk/client.rb', line 362

def delete_domain(domain_id, options: nil)
  path = sprintf("/api/v1/domains/%s", domain_id)
  request("DELETE", path, options: options)
end

#delete_env_var(key, options: nil) ⇒ Object



426
427
428
429
# File 'lib/vers_sdk/client.rb', line 426

def delete_env_var(key, options: nil)
  path = sprintf("/api/v1/env_vars/%s", key)
  request("DELETE", path, options: options)
end

#delete_image(base_image_id, options: nil) ⇒ Object



432
433
434
435
# File 'lib/vers_sdk/client.rb', line 432

def delete_image(base_image_id, options: nil)
  path = sprintf("/api/v1/images/images/%s", base_image_id)
  request("DELETE", path, options: options)
end

#delete_repo_tag(repo_name, tag_name, options: nil) ⇒ Object



291
292
293
294
# File 'lib/vers_sdk/client.rb', line 291

def delete_repo_tag(repo_name, tag_name, options: nil)
  path = sprintf("/api/v1/repositories/%s/tags/%s", repo_name, tag_name)
  request("DELETE", path, options: options)
end

#delete_repository(repo_name, options: nil) ⇒ Object



320
321
322
323
# File 'lib/vers_sdk/client.rb', line 320

def delete_repository(repo_name, options: nil)
  path = sprintf("/api/v1/repositories/%s", repo_name)
  request("DELETE", path, options: options)
end

#delete_tag(tag_name, options: nil) ⇒ Object



403
404
405
406
# File 'lib/vers_sdk/client.rb', line 403

def delete_tag(tag_name, options: nil)
  path = sprintf("/api/v1/commit_tags/%s", tag_name)
  request("DELETE", path, options: options)
end

#delete_vm(vm_id, params: nil, options: nil) ⇒ Object



386
387
388
389
390
391
392
393
394
# File 'lib/vers_sdk/client.rb', line 386

def delete_vm(vm_id, params: nil, options: nil)
  path = sprintf("/api/v1/vm/%s", vm_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("DELETE", path, options: options, query: query)
end

#delete_vm_label(vm_id, label_name, options: nil) ⇒ Object

Delete a single label from a VM by name.



338
339
340
341
# File 'lib/vers_sdk/client.rb', line 338

def delete_vm_label(vm_id, label_name, options: nil)
  path = sprintf("/api/v1/vm/%s/label/%s", vm_id, label_name)
  request("DELETE", path, options: options)
end

#deploy_handler(body: nil, options: nil) ⇒ Object

Deploy a GitHub repository to a new Vers project.



467
468
469
470
# File 'lib/vers_sdk/client.rb', line 467

def deploy_handler(body: nil, options: nil)
  path = "/api/v1/deploy"
  request("POST", path, options: options, body: body)
end

#exec_vm(vm_id, body: nil, options: nil) ⇒ Object



170
171
172
173
# File 'lib/vers_sdk/client.rb', line 170

def exec_vm(vm_id, body: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/exec", vm_id)
  request("POST", path, options: options, body: body)
end

#exec_vm_stream(vm_id, body: nil, options: nil) ⇒ Object



461
462
463
464
# File 'lib/vers_sdk/client.rb', line 461

def exec_vm_stream(vm_id, body: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/exec/stream", vm_id)
  request("POST", path, options: options, body: body)
end

#exec_vm_stream_attach(vm_id, body: nil, options: nil) ⇒ Object



222
223
224
225
# File 'lib/vers_sdk/client.rb', line 222

def exec_vm_stream_attach(vm_id, body: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/exec/stream/attach", vm_id)
  request("POST", path, options: options, body: body)
end

#fork_repository(body: nil, options: nil) ⇒ Object



332
333
334
335
# File 'lib/vers_sdk/client.rb', line 332

def fork_repository(body: nil, options: nil)
  path = "/api/v1/repositories/fork"
  request("POST", path, options: options, body: body)
end

#get_domain(domain_id, options: nil) ⇒ Object



356
357
358
359
# File 'lib/vers_sdk/client.rb', line 356

def get_domain(domain_id, options: nil)
  path = sprintf("/api/v1/domains/%s", domain_id)
  request("GET", path, options: options)
end

#get_image_status(image_name, options: nil) ⇒ Object



262
263
264
265
# File 'lib/vers_sdk/client.rb', line 262

def get_image_status(image_name, options: nil)
  path = sprintf("/api/v1/images/%s/status", image_name)
  request("GET", path, options: options)
end

#get_public_repo_tag(org_name, repo_name, tag_name, options: nil) ⇒ Object



122
123
124
125
# File 'lib/vers_sdk/client.rb', line 122

def get_public_repo_tag(org_name, repo_name, tag_name, options: nil)
  path = sprintf("/api/v1/public/repositories/%s/%s/tags/%s", org_name, repo_name, tag_name)
  request("GET", path, options: options)
end

#get_public_repository(org_name, repo_name, options: nil) ⇒ Object



205
206
207
208
# File 'lib/vers_sdk/client.rb', line 205

def get_public_repository(org_name, repo_name, options: nil)
  path = sprintf("/api/v1/public/repositories/%s/%s", org_name, repo_name)
  request("GET", path, options: options)
end

#get_repo_tag(repo_name, tag_name, options: nil) ⇒ Object



285
286
287
288
# File 'lib/vers_sdk/client.rb', line 285

def get_repo_tag(repo_name, tag_name, options: nil)
  path = sprintf("/api/v1/repositories/%s/tags/%s", repo_name, tag_name)
  request("GET", path, options: options)
end

#get_repository(repo_name, options: nil) ⇒ Object



314
315
316
317
# File 'lib/vers_sdk/client.rb', line 314

def get_repository(repo_name, options: nil)
  path = sprintf("/api/v1/repositories/%s", repo_name)
  request("GET", path, options: options)
end

#get_tag(tag_name, options: nil) ⇒ Object



397
398
399
400
# File 'lib/vers_sdk/client.rb', line 397

def get_tag(tag_name, options: nil)
  path = sprintf("/api/v1/commit_tags/%s", tag_name)
  request("GET", path, options: options)
end

#get_vm_metadata(vm_id, options: nil) ⇒ Object



146
147
148
149
# File 'lib/vers_sdk/client.rb', line 146

def (vm_id, options: nil)
  path = sprintf("/api/v1/vm/%s/metadata", vm_id)
  request("GET", path, options: options)
end

#list_commits(options: nil) ⇒ Object



152
153
154
155
# File 'lib/vers_sdk/client.rb', line 152

def list_commits(options: nil)
  path = "/api/v1/commits"
  request("GET", path, options: options)
end

#list_domains(params: nil, options: nil) ⇒ Object



485
486
487
488
489
490
491
492
493
# File 'lib/vers_sdk/client.rb', line 485

def list_domains(params: nil, options: nil)
  path = "/api/v1/domains"
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("GET", path, options: options, query: query)
end

#list_env_vars(options: nil) ⇒ Object



374
375
376
377
# File 'lib/vers_sdk/client.rb', line 374

def list_env_vars(options: nil)
  path = "/api/v1/env_vars"
  request("GET", path, options: options)
end

#list_images(options: nil) ⇒ Object



182
183
184
185
# File 'lib/vers_sdk/client.rb', line 182

def list_images(options: nil)
  path = "/api/v1/images"
  request("GET", path, options: options)
end

#list_parent_commits(commit_id, options: nil) ⇒ Object



93
94
95
96
# File 'lib/vers_sdk/client.rb', line 93

def list_parent_commits(commit_id, options: nil)
  path = sprintf("/api/v1/vm/commits/%s/parents", commit_id)
  request("GET", path, options: options)
end

#list_public_commits(options: nil) ⇒ Object



256
257
258
259
# File 'lib/vers_sdk/client.rb', line 256

def list_public_commits(options: nil)
  path = "/api/v1/commits/public"
  request("GET", path, options: options)
end

#list_public_repo_tags(org_name, repo_name, options: nil) ⇒ Object



87
88
89
90
# File 'lib/vers_sdk/client.rb', line 87

def list_public_repo_tags(org_name, repo_name, options: nil)
  path = sprintf("/api/v1/public/repositories/%s/%s/tags", org_name, repo_name)
  request("GET", path, options: options)
end

#list_public_repositories(options: nil) ⇒ Object



368
369
370
371
# File 'lib/vers_sdk/client.rb', line 368

def list_public_repositories(options: nil)
  path = "/api/v1/public/repositories"
  request("GET", path, options: options)
end

#list_repo_tags(repo_name, options: nil) ⇒ Object



158
159
160
161
# File 'lib/vers_sdk/client.rb', line 158

def list_repo_tags(repo_name, options: nil)
  path = sprintf("/api/v1/repositories/%s/tags", repo_name)
  request("GET", path, options: options)
end

#list_repositories(options: nil) ⇒ Object



110
111
112
113
# File 'lib/vers_sdk/client.rb', line 110

def list_repositories(options: nil)
  path = "/api/v1/repositories"
  request("GET", path, options: options)
end

#list_tags(options: nil) ⇒ Object



128
129
130
131
# File 'lib/vers_sdk/client.rb', line 128

def list_tags(options: nil)
  path = "/api/v1/commit_tags"
  request("GET", path, options: options)
end

#list_vms(options: nil) ⇒ Object



140
141
142
143
# File 'lib/vers_sdk/client.rb', line 140

def list_vms(options: nil)
  path = "/api/v1/vm"
  request("GET", path, options: options)
end

#read_file_vm(vm_id, params: nil, options: nil) ⇒ Object



188
189
190
191
192
193
194
195
196
# File 'lib/vers_sdk/client.rb', line 188

def read_file_vm(vm_id, params: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/files", vm_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("GET", path, options: options, query: query)
end

#replace_vm_labels(vm_id, body: nil, options: nil) ⇒ Object

Replace all labels on a VM with the provided map.



250
251
252
253
# File 'lib/vers_sdk/client.rb', line 250

def replace_vm_labels(vm_id, body: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/labels", vm_id)
  request("PUT", path, options: options, body: body)
end

#resize_vm_disk(vm_id, body: nil, params: nil, options: nil) ⇒ Object



211
212
213
214
215
216
217
218
219
# File 'lib/vers_sdk/client.rb', line 211

def resize_vm_disk(vm_id, body: nil, params: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/disk", vm_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("PATCH", path, options: options, body: body, query: query)
end

#restore_from_commit(body: nil, options: nil) ⇒ Object



350
351
352
353
# File 'lib/vers_sdk/client.rb', line 350

def restore_from_commit(body: nil, options: nil)
  path = "/api/v1/vm/from_commit"
  request("POST", path, options: options, body: body)
end

#set_env_vars(body: nil, options: nil) ⇒ Object



380
381
382
383
# File 'lib/vers_sdk/client.rb', line 380

def set_env_vars(body: nil, options: nil)
  path = "/api/v1/env_vars"
  request("PUT", path, options: options, body: body)
end

#set_repository_visibility(repo_name, body: nil, options: nil) ⇒ Object



176
177
178
179
# File 'lib/vers_sdk/client.rb', line 176

def set_repository_visibility(repo_name, body: nil, options: nil)
  path = sprintf("/api/v1/repositories/%s/visibility", repo_name)
  request("PATCH", path, options: options, body: body)
end

#ssh_key(vm_id, options: nil) ⇒ Object



473
474
475
476
# File 'lib/vers_sdk/client.rb', line 473

def ssh_key(vm_id, options: nil)
  path = sprintf("/api/v1/vm/%s/ssh_key", vm_id)
  request("GET", path, options: options)
end

#update_commit(commit_id, body: nil, options: nil) ⇒ Object



455
456
457
458
# File 'lib/vers_sdk/client.rb', line 455

def update_commit(commit_id, body: nil, options: nil)
  path = sprintf("/api/v1/commits/%s", commit_id)
  request("PATCH", path, options: options, body: body)
end

#update_repo_tag(repo_name, tag_name, body: nil, options: nil) ⇒ Object



297
298
299
300
# File 'lib/vers_sdk/client.rb', line 297

def update_repo_tag(repo_name, tag_name, body: nil, options: nil)
  path = sprintf("/api/v1/repositories/%s/tags/%s", repo_name, tag_name)
  request("PATCH", path, options: options, body: body)
end

#update_tag(tag_name, body: nil, options: nil) ⇒ Object



409
410
411
412
# File 'lib/vers_sdk/client.rb', line 409

def update_tag(tag_name, body: nil, options: nil)
  path = sprintf("/api/v1/commit_tags/%s", tag_name)
  request("PATCH", path, options: options, body: body)
end

#update_vm_state(vm_id, body: nil, params: nil, options: nil) ⇒ Object



99
100
101
102
103
104
105
106
107
# File 'lib/vers_sdk/client.rb', line 99

def update_vm_state(vm_id, body: nil, params: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/state", vm_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("PATCH", path, options: options, body: body, query: query)
end

#upload_image(body: nil, options: nil) ⇒ Object



508
509
510
511
# File 'lib/vers_sdk/client.rb', line 508

def upload_image(body: nil, options: nil)
  path = "/api/v1/images/upload"
  request("POST", path, options: options, body: body)
end

#upsert_vm_labels(vm_id, body: nil, options: nil) ⇒ Object

Upsert (additive) labels on a VM.



81
82
83
84
# File 'lib/vers_sdk/client.rb', line 81

def upsert_vm_labels(vm_id, body: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/label", vm_id)
  request("PATCH", path, options: options, body: body)
end

#validate_key(body: nil, options: nil) ⇒ Object



326
327
328
329
# File 'lib/vers_sdk/client.rb', line 326

def validate_key(body: nil, options: nil)
  path = "/api/v1/keys/validate"
  request("POST", path, options: options, body: body)
end

#version_handler(options: nil) ⇒ Object



268
269
270
271
# File 'lib/vers_sdk/client.rb', line 268

def version_handler(options: nil)
  path = "/api/v1/system/version"
  request("GET", path, options: options)
end

#vm_logs(vm_id, params: nil, options: nil) ⇒ Object



70
71
72
73
74
75
76
77
78
# File 'lib/vers_sdk/client.rb', line 70

def vm_logs(vm_id, params: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/logs", vm_id)
  query = {}
  if params
    h = params.is_a?(Hash) ? params : params.to_h
    h.each { |k, v| query[k.to_s] = v.to_s unless v.nil? }
  end
  request("GET", path, options: options, query: query)
end

#vm_status(vm_id, options: nil) ⇒ Object



479
480
481
482
# File 'lib/vers_sdk/client.rb', line 479

def vm_status(vm_id, options: nil)
  path = sprintf("/api/v1/vm/%s/status", vm_id)
  request("GET", path, options: options)
end

#whoami_handler(options: nil) ⇒ Object



502
503
504
505
# File 'lib/vers_sdk/client.rb', line 502

def whoami_handler(options: nil)
  path = "/api/v1/whoami"
  request("GET", path, options: options)
end

#write_file_vm(vm_id, body: nil, options: nil) ⇒ Object



199
200
201
202
# File 'lib/vers_sdk/client.rb', line 199

def write_file_vm(vm_id, body: nil, options: nil)
  path = sprintf("/api/v1/vm/%s/files", vm_id)
  request("PUT", path, options: options, body: body)
end