Class: VersSdk::VersSdkClient
- Inherits:
-
Object
- Object
- VersSdk::VersSdkClient
- Defined in:
- lib/vers_sdk/client.rb
Overview
HTTP client for Orchestrator Control Plane API.
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#max_retries ⇒ Object
readonly
Returns the value of attribute max_retries.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
- #branch_by_commit(commit_id, body: nil, params: nil, options: nil) ⇒ Object
- #branch_by_ref(repo_name, tag_name, body: nil, params: nil, options: nil) ⇒ Object
- #branch_by_tag(tag_name, body: nil, params: nil, options: nil) ⇒ Object
- #branch_by_vm(vm_id, body: nil, params: nil, options: nil) ⇒ Object
- #branch_vm(vm_or_commit_id, body: nil, params: nil, options: nil) ⇒ Object
- #commit_vm(vm_id, body: nil, params: nil, options: nil) ⇒ Object
- #create_domain(body: nil, options: nil) ⇒ Object
- #create_new_root_vm(body: nil, params: nil, options: nil) ⇒ Object
- #create_repo_tag(repo_name, body: nil, options: nil) ⇒ Object
- #create_repository(body: nil, options: nil) ⇒ Object
- #create_tag(body: nil, options: nil) ⇒ Object
- #delete_commit(commit_id, options: nil) ⇒ Object
- #delete_domain(domain_id, options: nil) ⇒ Object
- #delete_env_var(key, options: nil) ⇒ Object
- #delete_repo_tag(repo_name, tag_name, options: nil) ⇒ Object
- #delete_repository(repo_name, options: nil) ⇒ Object
- #delete_tag(tag_name, options: nil) ⇒ Object
- #delete_vm(vm_id, params: nil, options: nil) ⇒ Object
- #exec_vm(vm_id, body: nil, options: nil) ⇒ Object
- #exec_vm_stream(vm_id, body: nil, options: nil) ⇒ Object
- #exec_vm_stream_attach(vm_id, body: nil, options: nil) ⇒ Object
- #fork_repository(body: nil, options: nil) ⇒ Object
- #get_domain(domain_id, options: nil) ⇒ Object
- #get_public_repo_tag(org_name, repo_name, tag_name, options: nil) ⇒ Object
- #get_public_repository(org_name, repo_name, options: nil) ⇒ Object
- #get_repo_tag(repo_name, tag_name, options: nil) ⇒ Object
- #get_repository(repo_name, options: nil) ⇒ Object
- #get_tag(tag_name, options: nil) ⇒ Object
- #get_vm_metadata(vm_id, options: nil) ⇒ Object
-
#initialize(base_url: nil, api_key: nil, max_retries: 2, timeout: 30) ⇒ VersSdkClient
constructor
A new instance of VersSdkClient.
- #list_commits(options: nil) ⇒ Object
- #list_domains(params: nil, options: nil) ⇒ Object
- #list_env_vars(options: nil) ⇒ Object
- #list_parent_commits(commit_id, options: nil) ⇒ Object
- #list_public_commits(options: nil) ⇒ Object
- #list_public_repo_tags(org_name, repo_name, options: nil) ⇒ Object
- #list_public_repositories(options: nil) ⇒ Object
- #list_repo_tags(repo_name, options: nil) ⇒ Object
- #list_repositories(options: nil) ⇒ Object
- #list_tags(options: nil) ⇒ Object
- #list_vms(options: nil) ⇒ Object
- #resize_vm_disk(vm_id, body: nil, params: nil, options: nil) ⇒ Object
- #restore_from_commit(body: nil, options: nil) ⇒ Object
- #set_env_vars(body: nil, options: nil) ⇒ Object
- #set_repository_visibility(repo_name, body: nil, options: nil) ⇒ Object
- #ssh_key(vm_id, options: nil) ⇒ Object
- #update_commit(commit_id, body: nil, options: nil) ⇒ Object
- #update_repo_tag(repo_name, tag_name, body: nil, options: nil) ⇒ Object
- #update_tag(tag_name, body: nil, options: nil) ⇒ Object
- #update_vm_state(vm_id, body: nil, params: nil, options: nil) ⇒ Object
- #vm_logs(vm_id, params: nil, options: nil) ⇒ Object
- #vm_status(vm_id, options: nil) ⇒ Object
Constructor Details
#initialize(base_url: nil, api_key: nil, max_retries: 2, timeout: 30) ⇒ VersSdkClient
Returns a new instance of VersSdkClient.
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.6 ruby/#{RUBY_VERSION} #{RUBY_PLATFORM}" } @default_headers["Authorization"] = "Bearer #{@api_key}" if @api_key end |
Instance Attribute Details
#base_url ⇒ Object (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_retries ⇒ Object (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 |
#timeout ⇒ Object (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_logger ⇒ Object
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
425 426 427 428 429 430 431 432 433 |
# File 'lib/vers_sdk/client.rb', line 425 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: , body: body, query: query) end |
#branch_by_ref(repo_name, tag_name, body: nil, params: nil, options: nil) ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/vers_sdk/client.rb', line 109 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: , body: body, query: query) end |
#branch_by_tag(tag_name, body: nil, params: nil, options: nil) ⇒ Object
132 133 134 135 136 137 138 139 140 |
# File 'lib/vers_sdk/client.rb', line 132 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: , body: body, query: query) end |
#branch_by_vm(vm_id, body: nil, params: nil, options: nil) ⇒ Object
314 315 316 317 318 319 320 321 322 |
# File 'lib/vers_sdk/client.rb', line 314 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: , body: body, query: query) end |
#branch_vm(vm_or_commit_id, body: nil, params: nil, options: nil) ⇒ Object
143 144 145 146 147 148 149 150 151 |
# File 'lib/vers_sdk/client.rb', line 143 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: , body: body, query: query) end |
#commit_vm(vm_id, body: nil, params: nil, options: nil) ⇒ Object
337 338 339 340 341 342 343 344 345 |
# File 'lib/vers_sdk/client.rb', line 337 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: , body: body, query: query) end |
#create_domain(body: nil, options: nil) ⇒ Object
407 408 409 410 |
# File 'lib/vers_sdk/client.rb', line 407 def create_domain(body: nil, options: nil) path = "/api/v1/domains" request("POST", path, options: , body: body) end |
#create_new_root_vm(body: nil, params: nil, options: nil) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/vers_sdk/client.rb', line 87 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: , body: body, query: query) end |
#create_repo_tag(repo_name, body: nil, options: nil) ⇒ Object
366 367 368 369 |
# File 'lib/vers_sdk/client.rb', line 366 def create_repo_tag(repo_name, body: nil, options: nil) path = sprintf("/api/v1/repositories/%s/tags", repo_name) request("POST", path, options: , body: body) end |
#create_repository(body: nil, options: nil) ⇒ Object
213 214 215 216 |
# File 'lib/vers_sdk/client.rb', line 213 def create_repository(body: nil, options: nil) path = "/api/v1/repositories" request("POST", path, options: , body: body) end |
#create_tag(body: nil, options: nil) ⇒ Object
243 244 245 246 |
# File 'lib/vers_sdk/client.rb', line 243 def create_tag(body: nil, options: nil) path = "/api/v1/commit_tags" request("POST", path, options: , body: body) end |
#delete_commit(commit_id, options: nil) ⇒ Object
348 349 350 351 |
# File 'lib/vers_sdk/client.rb', line 348 def delete_commit(commit_id, options: nil) path = sprintf("/api/v1/commits/%s", commit_id) request("DELETE", path, options: ) end |
#delete_domain(domain_id, options: nil) ⇒ Object
231 232 233 234 |
# File 'lib/vers_sdk/client.rb', line 231 def delete_domain(domain_id, options: nil) path = sprintf("/api/v1/domains/%s", domain_id) request("DELETE", path, options: ) end |
#delete_env_var(key, options: nil) ⇒ Object
325 326 327 328 |
# File 'lib/vers_sdk/client.rb', line 325 def delete_env_var(key, options: nil) path = sprintf("/api/v1/env_vars/%s", key) request("DELETE", path, options: ) end |
#delete_repo_tag(repo_name, tag_name, options: nil) ⇒ Object
160 161 162 163 |
# File 'lib/vers_sdk/client.rb', line 160 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: ) end |
#delete_repository(repo_name, options: nil) ⇒ Object
178 179 180 181 |
# File 'lib/vers_sdk/client.rb', line 178 def delete_repository(repo_name, options: nil) path = sprintf("/api/v1/repositories/%s", repo_name) request("DELETE", path, options: ) end |
#delete_tag(tag_name, options: nil) ⇒ Object
302 303 304 305 |
# File 'lib/vers_sdk/client.rb', line 302 def delete_tag(tag_name, options: nil) path = sprintf("/api/v1/commit_tags/%s", tag_name) request("DELETE", path, options: ) end |
#delete_vm(vm_id, params: nil, options: nil) ⇒ Object
279 280 281 282 283 284 285 286 287 |
# File 'lib/vers_sdk/client.rb', line 279 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: , query: query) end |
#exec_vm(vm_id, body: nil, options: nil) ⇒ Object
378 379 380 381 |
# File 'lib/vers_sdk/client.rb', line 378 def exec_vm(vm_id, body: nil, options: nil) path = sprintf("/api/v1/vm/%s/exec", vm_id) request("POST", path, options: , body: body) end |
#exec_vm_stream(vm_id, body: nil, options: nil) ⇒ Object
331 332 333 334 |
# File 'lib/vers_sdk/client.rb', line 331 def exec_vm_stream(vm_id, body: nil, options: nil) path = sprintf("/api/v1/vm/%s/exec/stream", vm_id) request("POST", path, options: , body: body) end |
#exec_vm_stream_attach(vm_id, body: nil, options: nil) ⇒ Object
81 82 83 84 |
# File 'lib/vers_sdk/client.rb', line 81 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: , body: body) end |
#fork_repository(body: nil, options: nil) ⇒ Object
201 202 203 204 |
# File 'lib/vers_sdk/client.rb', line 201 def fork_repository(body: nil, options: nil) path = "/api/v1/repositories/fork" request("POST", path, options: , body: body) end |
#get_domain(domain_id, options: nil) ⇒ Object
225 226 227 228 |
# File 'lib/vers_sdk/client.rb', line 225 def get_domain(domain_id, options: nil) path = sprintf("/api/v1/domains/%s", domain_id) request("GET", path, options: ) end |
#get_public_repo_tag(org_name, repo_name, tag_name, options: nil) ⇒ Object
255 256 257 258 |
# File 'lib/vers_sdk/client.rb', line 255 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: ) end |
#get_public_repository(org_name, repo_name, options: nil) ⇒ Object
419 420 421 422 |
# File 'lib/vers_sdk/client.rb', line 419 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: ) end |
#get_repo_tag(repo_name, tag_name, options: nil) ⇒ Object
154 155 156 157 |
# File 'lib/vers_sdk/client.rb', line 154 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: ) end |
#get_repository(repo_name, options: nil) ⇒ Object
172 173 174 175 |
# File 'lib/vers_sdk/client.rb', line 172 def get_repository(repo_name, options: nil) path = sprintf("/api/v1/repositories/%s", repo_name) request("GET", path, options: ) end |
#get_tag(tag_name, options: nil) ⇒ Object
296 297 298 299 |
# File 'lib/vers_sdk/client.rb', line 296 def get_tag(tag_name, options: nil) path = sprintf("/api/v1/commit_tags/%s", tag_name) request("GET", path, options: ) end |
#get_vm_metadata(vm_id, options: nil) ⇒ Object
261 262 263 264 |
# File 'lib/vers_sdk/client.rb', line 261 def (vm_id, options: nil) path = sprintf("/api/v1/vm/%s/metadata", vm_id) request("GET", path, options: ) end |
#list_commits(options: nil) ⇒ Object
290 291 292 293 |
# File 'lib/vers_sdk/client.rb', line 290 def list_commits(options: nil) path = "/api/v1/commits" request("GET", path, options: ) end |
#list_domains(params: nil, options: nil) ⇒ Object
396 397 398 399 400 401 402 403 404 |
# File 'lib/vers_sdk/client.rb', line 396 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: , query: query) end |
#list_env_vars(options: nil) ⇒ Object
267 268 269 270 |
# File 'lib/vers_sdk/client.rb', line 267 def list_env_vars(options: nil) path = "/api/v1/env_vars" request("GET", path, options: ) end |
#list_parent_commits(commit_id, options: nil) ⇒ Object
184 185 186 187 |
# File 'lib/vers_sdk/client.rb', line 184 def list_parent_commits(commit_id, options: nil) path = sprintf("/api/v1/vm/commits/%s/parents", commit_id) request("GET", path, options: ) end |
#list_public_commits(options: nil) ⇒ Object
120 121 122 123 |
# File 'lib/vers_sdk/client.rb', line 120 def list_public_commits(options: nil) path = "/api/v1/commits/public" request("GET", path, options: ) end |
#list_public_repo_tags(org_name, repo_name, options: nil) ⇒ Object
126 127 128 129 |
# File 'lib/vers_sdk/client.rb', line 126 def (org_name, repo_name, options: nil) path = sprintf("/api/v1/public/repositories/%s/%s/tags", org_name, repo_name) request("GET", path, options: ) end |
#list_public_repositories(options: nil) ⇒ Object
249 250 251 252 |
# File 'lib/vers_sdk/client.rb', line 249 def list_public_repositories(options: nil) path = "/api/v1/public/repositories" request("GET", path, options: ) end |
#list_repo_tags(repo_name, options: nil) ⇒ Object
360 361 362 363 |
# File 'lib/vers_sdk/client.rb', line 360 def (repo_name, options: nil) path = sprintf("/api/v1/repositories/%s/tags", repo_name) request("GET", path, options: ) end |
#list_repositories(options: nil) ⇒ Object
207 208 209 210 |
# File 'lib/vers_sdk/client.rb', line 207 def list_repositories(options: nil) path = "/api/v1/repositories" request("GET", path, options: ) end |
#list_tags(options: nil) ⇒ Object
237 238 239 240 |
# File 'lib/vers_sdk/client.rb', line 237 def (options: nil) path = "/api/v1/commit_tags" request("GET", path, options: ) end |
#list_vms(options: nil) ⇒ Object
390 391 392 393 |
# File 'lib/vers_sdk/client.rb', line 390 def list_vms(options: nil) path = "/api/v1/vms" request("GET", path, options: ) end |
#resize_vm_disk(vm_id, body: nil, params: nil, options: nil) ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/vers_sdk/client.rb', line 70 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: , body: body, query: query) end |
#restore_from_commit(body: nil, options: nil) ⇒ Object
219 220 221 222 |
# File 'lib/vers_sdk/client.rb', line 219 def restore_from_commit(body: nil, options: nil) path = "/api/v1/vm/from_commit" request("POST", path, options: , body: body) end |
#set_env_vars(body: nil, options: nil) ⇒ Object
273 274 275 276 |
# File 'lib/vers_sdk/client.rb', line 273 def set_env_vars(body: nil, options: nil) path = "/api/v1/env_vars" request("PUT", path, options: , body: body) end |
#set_repository_visibility(repo_name, body: nil, options: nil) ⇒ Object
384 385 386 387 |
# File 'lib/vers_sdk/client.rb', line 384 def set_repository_visibility(repo_name, body: nil, options: nil) path = sprintf("/api/v1/repositories/%s/visibility", repo_name) request("PATCH", path, options: , body: body) end |
#ssh_key(vm_id, options: nil) ⇒ Object
372 373 374 375 |
# File 'lib/vers_sdk/client.rb', line 372 def ssh_key(vm_id, options: nil) path = sprintf("/api/v1/vm/%s/ssh_key", vm_id) request("GET", path, options: ) end |
#update_commit(commit_id, body: nil, options: nil) ⇒ Object
354 355 356 357 |
# File 'lib/vers_sdk/client.rb', line 354 def update_commit(commit_id, body: nil, options: nil) path = sprintf("/api/v1/commits/%s", commit_id) request("PATCH", path, options: , body: body) end |
#update_repo_tag(repo_name, tag_name, body: nil, options: nil) ⇒ Object
166 167 168 169 |
# File 'lib/vers_sdk/client.rb', line 166 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: , body: body) end |
#update_tag(tag_name, body: nil, options: nil) ⇒ Object
308 309 310 311 |
# File 'lib/vers_sdk/client.rb', line 308 def update_tag(tag_name, body: nil, options: nil) path = sprintf("/api/v1/commit_tags/%s", tag_name) request("PATCH", path, options: , body: body) end |
#update_vm_state(vm_id, body: nil, params: nil, options: nil) ⇒ Object
190 191 192 193 194 195 196 197 198 |
# File 'lib/vers_sdk/client.rb', line 190 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: , body: body, query: query) end |
#vm_logs(vm_id, params: nil, options: nil) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/vers_sdk/client.rb', line 98 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: , query: query) end |
#vm_status(vm_id, options: nil) ⇒ Object
413 414 415 416 |
# File 'lib/vers_sdk/client.rb', line 413 def vm_status(vm_id, options: nil) path = sprintf("/api/v1/vm/%s/status", vm_id) request("GET", path, options: ) end |