Skip to content

Commit 46da556

Browse files
feat(api): api update
1 parent d845469 commit 46da556

29 files changed

+382
-137
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hdr-parth-agrawal%2Ffirecracker-manager-07b6a4a1a7515802531be41461e4d9b4badad13e93492f5a408d54f51693d717.yml
3-
openapi_spec_hash: aba885b7687af21c2151833c9d7a2dab
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hdr-parth-agrawal%2Ffirecracker-manager-fc1351bc8599fc6873d1be7f16ed805907442c3a50f68659b312076be10bd5d0.yml
3+
openapi_spec_hash: 15a3d34206ed2dca0702a8a3291e1d7b
44
config_hash: ba476ff7e5c71b83e72ad86fcb01beeb

lib/vers/models.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ module Vers
5151

5252
VmCommitParams = Vers::Models::VmCommitParams
5353

54-
VmCommitResponse = Vers::Models::VmCommitResponse
55-
5654
VmCreateRootParams = Vers::Models::VmCreateRootParams
5755

5856
VmDeleteParams = Vers::Models::VmDeleteParams

lib/vers/models/vm.rb

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,39 @@ class VmAPI < Vers::Internal::Type::BaseModel
1313
# @return [String]
1414
required :owner_id, String
1515

16+
# @!attribute state
17+
# The state of a VM
18+
#
19+
# @return [Symbol, Vers::Models::VmAPI::State]
20+
required :state, enum: -> { Vers::VmAPI::State }
21+
1622
# @!attribute vm_id
1723
#
1824
# @return [String]
1925
required :vm_id, String
2026

21-
# @!attribute parent
22-
#
23-
# @return [String, nil]
24-
optional :parent, String, nil?: true
25-
26-
# @!method initialize(created_at:, owner_id:, vm_id:, parent: nil)
27+
# @!method initialize(created_at:, owner_id:, state:, vm_id:)
2728
# @param created_at [Time]
29+
#
2830
# @param owner_id [String]
31+
#
32+
# @param state [Symbol, Vers::Models::VmAPI::State] The state of a VM
33+
#
2934
# @param vm_id [String]
30-
# @param parent [String, nil]
35+
36+
# The state of a VM
37+
#
38+
# @see Vers::Models::VmAPI#state
39+
module State
40+
extend Vers::Internal::Type::Enum
41+
42+
BOOTING = :booting
43+
RUNNING = :running
44+
PAUSED = :paused
45+
46+
# @!method self.values
47+
# @return [Array<Symbol>]
48+
end
3149
end
3250
end
3351
end

lib/vers/models/vm_commit_params.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,23 @@ class VmCommitParams < Vers::Internal::Type::BaseModel
77
extend Vers::Internal::Type::RequestParameters::Converter
88
include Vers::Internal::Type::RequestParameters
99

10-
# @!method initialize(request_options: {})
10+
# @!attribute keep_paused
11+
# If true, keep VM paused after commit
12+
#
13+
# @return [Boolean, nil]
14+
optional :keep_paused, Vers::Internal::Type::Boolean
15+
16+
# @!attribute skip_wait_boot
17+
# If true, return an error immediately if the VM is still booting. Default: false
18+
#
19+
# @return [Boolean, nil]
20+
optional :skip_wait_boot, Vers::Internal::Type::Boolean
21+
22+
# @!method initialize(keep_paused: nil, skip_wait_boot: nil, request_options: {})
23+
# @param keep_paused [Boolean] If true, keep VM paused after commit
24+
#
25+
# @param skip_wait_boot [Boolean] If true, return an error immediately if the VM is still booting. Default: false
26+
#
1127
# @param request_options [Vers::RequestOptions, Hash{Symbol=>Object}]
1228
end
1329
end

lib/vers/models/vm_commit_response.rb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,14 @@ module Models
55
# @see Vers::Resources::Vm#commit
66
class VmCommitResponse < Vers::Internal::Type::BaseModel
77
# @!attribute commit_id
8-
# The commit ID, a (v4) UUID
98
#
109
# @return [String]
1110
required :commit_id, String
1211

13-
# @!attribute host_architecture
14-
# The host architecture, eg: "x86_64" (currently implemented with `uname -m``)
12+
# @!method initialize(commit_id:)
13+
# A summary of a commit, appropriate for displaying on the frontend
1514
#
16-
# @return [String]
17-
required :host_architecture, String
18-
19-
# @!method initialize(commit_id:, host_architecture:)
20-
# The response body for POST /api/vm/{vm_id}/commit
21-
#
22-
# @param commit_id [String] The commit ID, a (v4) UUID
23-
#
24-
# @param host_architecture [String] The host architecture, eg: "x86_64" (currently implemented with `uname -m``)
15+
# @param commit_id [String]
2516
end
2617
end
2718
end

lib/vers/models/vm_create_root_params.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ class VmCreateRootParams < Vers::Models::NewRootRequest
77
extend Vers::Internal::Type::RequestParameters::Converter
88
include Vers::Internal::Type::RequestParameters
99

10-
# @!method initialize(request_options: {})
10+
# @!attribute wait_boot
11+
# If true, wait for the newly-created VM to finish booting before returning.
12+
# Default: false.
13+
#
14+
# @return [Boolean, nil]
15+
optional :wait_boot, Vers::Internal::Type::Boolean
16+
17+
# @!method initialize(wait_boot: nil, request_options: {})
18+
# Some parameter documentations has been truncated, see
19+
# {Vers::Models::VmCreateRootParams} for more details.
20+
#
21+
# @param wait_boot [Boolean] If true, wait for the newly-created VM to finish booting before returning. Defau
22+
#
1123
# @param request_options [Vers::RequestOptions, Hash{Symbol=>Object}]
1224
end
1325
end

lib/vers/models/vm_delete_params.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ class VmDeleteParams < Vers::Internal::Type::BaseModel
77
extend Vers::Internal::Type::RequestParameters::Converter
88
include Vers::Internal::Type::RequestParameters
99

10-
# @!method initialize(request_options: {})
10+
# @!attribute skip_wait_boot
11+
# If true, return an error immediately if the VM is still booting. Default: false
12+
#
13+
# @return [Boolean, nil]
14+
optional :skip_wait_boot, Vers::Internal::Type::Boolean
15+
16+
# @!method initialize(skip_wait_boot: nil, request_options: {})
17+
# @param skip_wait_boot [Boolean] If true, return an error immediately if the VM is still booting. Default: false
18+
#
1119
# @param request_options [Vers::RequestOptions, Hash{Symbol=>Object}]
1220
end
1321
end

lib/vers/models/vm_delete_response.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ module Vers
44
module Models
55
# @see Vers::Resources::Vm#delete
66
class VmDeleteResponse < Vers::Internal::Type::BaseModel
7-
# @!attribute deleted_ids
7+
# @!attribute vm_id
88
#
9-
# @return [Array<String>]
10-
required :deleted_ids, Vers::Internal::Type::ArrayOf[String]
9+
# @return [String]
10+
required :vm_id, String
1111

12-
# @!method initialize(deleted_ids:)
12+
# @!method initialize(vm_id:)
1313
# Response body for DELETE /api/vm/{vm_id}
1414
#
15-
# @param deleted_ids [Array<String>]
15+
# @param vm_id [String]
1616
end
1717
end
1818
end

lib/vers/models/vm_update_state_params.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ class VmUpdateStateParams < Vers::Models::VmUpdateStateRequest
77
extend Vers::Internal::Type::RequestParameters::Converter
88
include Vers::Internal::Type::RequestParameters
99

10-
# @!method initialize(request_options: {})
10+
# @!attribute skip_wait_boot
11+
# If true, error immediately if the VM is not finished booting. Defaults to false
12+
#
13+
# @return [Boolean, nil]
14+
optional :skip_wait_boot, Vers::Internal::Type::Boolean
15+
16+
# @!method initialize(skip_wait_boot: nil, request_options: {})
17+
# @param skip_wait_boot [Boolean] If true, error immediately if the VM is not finished booting. Defaults to false
18+
#
1119
# @param request_options [Vers::RequestOptions, Hash{Symbol=>Object}]
1220
end
1321
end

lib/vers/resources/vm.rb

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,25 @@ def list(params = {})
1919
)
2020
end
2121

22-
# @overload delete(vm_id, request_options: {})
22+
# @overload delete(vm_id, skip_wait_boot: nil, request_options: {})
2323
#
2424
# @param vm_id [String] VM ID to delete
2525
#
26+
# @param skip_wait_boot [Boolean] If true, return an error immediately if the VM is still booting. Default: false
27+
#
2628
# @param request_options [Vers::RequestOptions, Hash{Symbol=>Object}, nil]
2729
#
2830
# @return [Vers::Models::VmDeleteResponse]
2931
#
3032
# @see Vers::Models::VmDeleteParams
3133
def delete(vm_id, params = {})
34+
parsed, options = Vers::VmDeleteParams.dump_request(params)
3235
@client.request(
3336
method: :delete,
3437
path: ["vm/%1$s", vm_id],
38+
query: parsed,
3539
model: Vers::VmDeleteResponse,
36-
options: params[:request_options]
40+
options: options
3741
)
3842
end
3943

@@ -55,27 +59,38 @@ def branch(vm_id, params = {})
5559
)
5660
end
5761

58-
# @overload commit(vm_id, request_options: {})
62+
# @overload commit(vm_id, keep_paused: nil, skip_wait_boot: nil, request_options: {})
5963
#
6064
# @param vm_id [String] VM ID to commit
6165
#
66+
# @param keep_paused [Boolean] If true, keep VM paused after commit
67+
#
68+
# @param skip_wait_boot [Boolean] If true, return an error immediately if the VM is still booting. Default: false
69+
#
6270
# @param request_options [Vers::RequestOptions, Hash{Symbol=>Object}, nil]
6371
#
6472
# @return [Vers::Models::VmCommitResponse]
6573
#
6674
# @see Vers::Models::VmCommitParams
6775
def commit(vm_id, params = {})
76+
parsed, options = Vers::VmCommitParams.dump_request(params)
6877
@client.request(
6978
method: :post,
7079
path: ["vm/%1$s/commit", vm_id],
71-
model: Vers::VmCommitResponse,
72-
options: params[:request_options]
80+
query: parsed,
81+
model: Vers::Models::VmCommitResponse,
82+
options: options
7383
)
7484
end
7585

76-
# @overload create_root(vm_config:, request_options: {})
86+
# Some parameter documentations has been truncated, see
87+
# {Vers::Models::VmCreateRootParams} for more details.
7788
#
78-
# @param vm_config [Vers::Models::NewRootRequest::VmConfig] Struct representing configuration options common to all VMs
89+
# @overload create_root(vm_config:, wait_boot: nil, request_options: {})
90+
#
91+
# @param vm_config [Vers::Models::NewRootRequest::VmConfig] Body param: Struct representing configuration options common to all VMs
92+
#
93+
# @param wait_boot [Boolean] Query param: If true, wait for the newly-created VM to finish booting before ret
7994
#
8095
# @param request_options [Vers::RequestOptions, Hash{Symbol=>Object}, nil]
8196
#
@@ -84,10 +99,12 @@ def commit(vm_id, params = {})
8499
# @see Vers::Models::VmCreateRootParams
85100
def create_root(params)
86101
parsed, options = Vers::VmCreateRootParams.dump_request(params)
102+
query_params = [:wait_boot]
87103
@client.request(
88104
method: :post,
89105
path: "vm/new_root",
90-
body: parsed,
106+
query: parsed.slice(*query_params),
107+
body: parsed.except(*query_params),
91108
model: Vers::NewVmResponse,
92109
options: options
93110
)
@@ -130,11 +147,16 @@ def restore_from_commit(params)
130147
)
131148
end
132149

133-
# @overload update_state(vm_id, state:, request_options: {})
150+
# Some parameter documentations has been truncated, see
151+
# {Vers::Models::VmUpdateStateParams} for more details.
134152
#
135-
# @param vm_id [String] VM ID
153+
# @overload update_state(vm_id, state:, skip_wait_boot: nil, request_options: {})
136154
#
137-
# @param state [Symbol, Vers::Models::VmUpdateStateRequest::State] The requested state for the VM
155+
# @param vm_id [String] Path param: VM ID
156+
#
157+
# @param state [Symbol, Vers::Models::VmUpdateStateRequest::State] Body param: The requested state for the VM
158+
#
159+
# @param skip_wait_boot [Boolean] Query param: If true, error immediately if the VM is not finished booting. Defau
138160
#
139161
# @param request_options [Vers::RequestOptions, Hash{Symbol=>Object}, nil]
140162
#
@@ -143,10 +165,12 @@ def restore_from_commit(params)
143165
# @see Vers::Models::VmUpdateStateParams
144166
def update_state(vm_id, params)
145167
parsed, options = Vers::VmUpdateStateParams.dump_request(params)
168+
query_params = [:skip_wait_boot]
146169
@client.request(
147170
method: :patch,
148171
path: ["vm/%1$s/state", vm_id],
149-
body: parsed,
172+
query: parsed.slice(*query_params),
173+
body: parsed.except(*query_params),
150174
model: NilClass,
151175
options: options
152176
)

0 commit comments

Comments
 (0)