Repository navigation
Expand file tree
/
Copy pathrentals_gen.go
More file actions
1902 lines (1664 loc) · 69.8 KB
/
Copy pathrentals_gen.go
File metadata and controls
1902 lines (1664 loc) · 69.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright 2026 Hyperbolic Labs, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by internal/gen from openapi/openapi.json and openapi/sdk.yaml. DO NOT EDIT.
package hyperbolic
import (
"context"
"encoding/json"
"errors"
"fmt"
"iter"
"net/http"
"net/url"
"time"
"github.com/oapi-codegen/nullable"
"github.com/oapi-codegen/runtime"
)
// RentalsService manages on-demand and reserved GPU rentals.
type RentalsService struct {
t *transport
}
// ActiveSummary calls GET /v2/on-demand/active-rental-summary: get a summary of
// active rentals.
//
// Count the caller's active rentals and sum their hourly cost in cents, in
// total and per term type.
func (s *RentalsService) ActiveSummary(ctx context.Context) (*ActiveRentalSummary, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/active-rental-summary", idempotent: true}
var out ActiveRentalSummary
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// AttachSSHKey calls POST /v2/on-demand/rentals/ssh-keys/attach: attach an SSH
// key to a rental.
//
// Attach a saved SSH public key to a running or pending virtual machine rental,
// without a restart.
func (s *RentalsService) AttachSSHKey(ctx context.Context, params AttachSSHKeyParams) (*SuccessResponse, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/rentals/ssh-keys/attach", idempotent: true, body: params}
var out SuccessResponse
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// ConversionQuote calls GET /v2/on-demand/get-reserved-conversion-quote: get a
// reserved conversion quote.
//
// Get a reserved conversion quote. Pass `termPeriodDays` to also get the price
// for that length as `requestedOption`.
func (s *RentalsService) ConversionQuote(ctx context.Context, params GetReservedConversionQuoteParams) (*ReservedConversionQuote, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/get-reserved-conversion-quote", idempotent: true, query: params.query()}
var out ReservedConversionQuote
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
func (p GetReservedConversionQuoteParams) query() url.Values {
q := url.Values{}
q.Set("rentalId", fmt.Sprint(p.RentalID))
if p.TermPeriodDays != nil {
q.Set("termPeriodDays", fmt.Sprint(*p.TermPeriodDays))
}
return q
}
// ConvertToReserved calls POST /v2/on-demand/convert-to-reserved: convert a
// rental to a reserved term.
//
// It is not retried after a failure that may have reached the server. Such a
// failure matches [ErrOutcomeUnknown]: check whether the call took effect
// before making it again.
func (s *RentalsService) ConvertToReserved(ctx context.Context, params ConvertRentalToReservedParams) (*ReservedRentalConversion, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/convert-to-reserved", idempotent: false, body: params}
var out ReservedRentalConversion
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// Create calls POST /v2/on-demand/rentals: create a rental.
//
// Rent a virtual machine or a bare metal server. `rentalType` decides which
// machine-type-specific fields apply; sending a field for the other type is a
// BAD_REQUEST (INVALID_INPUT_FOR_RENTAL_TYPE).
//
// It is not retried after a failure that may have reached the server. Such a
// failure matches [ErrOutcomeUnknown]: check whether the call took effect
// before making it again.
func (s *RentalsService) Create(ctx context.Context, params CreateRentalParams) (*Rental, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/rentals", idempotent: false, body: params}
var out Rental
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// DetachSSHKey calls POST /v2/on-demand/rentals/ssh-keys/detach: detach an SSH
// key from a rental.
//
// Detach a saved SSH public key from a running or pending virtual machine
// rental, without a restart.
func (s *RentalsService) DetachSSHKey(ctx context.Context, params DetachSSHKeyParams) (*SuccessResponse, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/rentals/ssh-keys/detach", idempotent: true, body: params}
var out SuccessResponse
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// ExtendReserved calls POST /v2/on-demand/extend-reserved: extend a reserved
// rental.
//
// It is not retried after a failure that may have reached the server. Such a
// failure matches [ErrOutcomeUnknown]: check whether the call took effect
// before making it again.
func (s *RentalsService) ExtendReserved(ctx context.Context, params ExtendReservedRentalParams) (*ReservedRentalExtension, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/extend-reserved", idempotent: false, body: params}
var out ReservedRentalExtension
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// ExtensionQuote calls GET /v2/on-demand/get-reservation-extension-quote: get a
// reservation extension quote.
//
// Get a reservation extension quote. Pass `termPeriodDays` to also get the
// price for that length as `requestedOption`.
func (s *RentalsService) ExtensionQuote(ctx context.Context, params GetReservationExtensionQuoteParams) (*ReservationExtensionQuote, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/get-reservation-extension-quote", idempotent: true, query: params.query()}
var out ReservationExtensionQuote
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
func (p GetReservationExtensionQuoteParams) query() url.Values {
q := url.Values{}
q.Set("rentalId", fmt.Sprint(p.RentalID))
if p.TermPeriodDays != nil {
q.Set("termPeriodDays", fmt.Sprint(*p.TermPeriodDays))
}
return q
}
// Get calls GET /v2/on-demand/rental: get a rental.
//
// Look up one rental by its ID, whether it is still running or has ended.
// Returns null when no rental with that ID belongs to the caller.
//
// When nothing matches, the error matches [ErrNotFound].
func (s *RentalsService) Get(ctx context.Context, params GetRentalParams) (*RentalLookup, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/rental", idempotent: true, query: params.query()}
var raw json.RawMessage
if err := s.t.do(ctx, c, &raw); err != nil {
return nil, err
}
if isNull(raw) {
return nil, notFound(c)
}
var out RentalLookup
if err := json.Unmarshal(raw, &out); err != nil {
return nil, decodeError(c, err)
}
return &out, nil
}
func (p GetRentalParams) query() url.Values {
q := url.Values{}
q.Set("rentalId", fmt.Sprint(p.RentalID))
return q
}
// HasHistory calls GET /v2/on-demand/has-rental-history: check whether any past
// rentals exist.
//
// Whether the caller has at least one rental that has ended.
func (s *RentalsService) HasHistory(ctx context.Context, params HasRentalHistoryParams) (bool, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/has-rental-history", idempotent: true, query: params.query()}
var out bool
if err := s.t.do(ctx, c, &out); err != nil {
return false, err
}
return out, nil
}
func (p HasRentalHistoryParams) query() url.Values {
q := url.Values{}
if p.IncludePrivateCloud != nil {
q.Set("includePrivateCloud", fmt.Sprint(*p.IncludePrivateCloud))
}
return q
}
// ListActive calls GET /v2/on-demand/rentals/active: list active rentals.
//
// Active rentals with their live status, most recently started first, as
// numbered pages. Pass `rentalType` to list one machine type; omit it to list
// all of them.
func (s *RentalsService) ListActive(ctx context.Context, params ListActiveRentalsParams) (*ActiveRentalsPage, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/rentals/active", idempotent: true, query: params.query()}
var out ActiveRentalsPage
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// ListActiveAll iterates over the items of every page ListActive returns, from
// params.Page (the first page when unset). It stops at the first error,
// yielding it.
func (s *RentalsService) ListActiveAll(ctx context.Context, params ListActiveRentalsParams) iter.Seq2[RentalWithStatus, error] {
return pages(params.Page, func(page int) ([]RentalWithStatus, bool, error) {
params.Page = &page
r, err := s.ListActive(ctx, params)
if err != nil {
return nil, false, err
}
return r.Items, page < r.TotalPages, nil
})
}
func (p ListActiveRentalsParams) query() url.Values {
q := url.Values{}
if p.Page != nil {
q.Set("page", fmt.Sprint(*p.Page))
}
if p.PageSize != nil {
q.Set("pageSize", fmt.Sprint(*p.PageSize))
}
if p.GPUType != nil {
q.Set("gpuType", fmt.Sprint(*p.GPUType))
}
if p.Region != nil {
q.Set("region", fmt.Sprint(*p.Region))
}
if p.TermType != nil {
q.Set("termType", fmt.Sprint(*p.TermType))
}
if p.IncludePrivateCloud != nil {
q.Set("includePrivateCloud", fmt.Sprint(*p.IncludePrivateCloud))
}
if p.RentalType != nil {
q.Set("rentalType", fmt.Sprint(*p.RentalType))
}
if p.IncludeClusterPools != nil {
q.Set("includeClusterPools", fmt.Sprint(*p.IncludeClusterPools))
}
return q
}
// ListHistory calls GET /v2/on-demand/rentals/history: list past rentals.
//
// Past rentals, most recently terminated first, one page at a time. Pass the
// response's `nextCursor` as `cursor` to read the next page.
func (s *RentalsService) ListHistory(ctx context.Context, params ListRentalHistoryParams) (*RentalHistoryPage, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/rentals/history", idempotent: true, query: params.query()}
var out RentalHistoryPage
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// ListHistoryAll iterates over the items of every page ListHistory returns, from
// params.Cursor (the first page when unset). It stops at the first error,
// yielding it.
func (s *RentalsService) ListHistoryAll(ctx context.Context, params ListRentalHistoryParams) iter.Seq2[HistoricalRental, error] {
return cursors(params.Cursor, func(cursor *string) ([]HistoricalRental, *string, error) {
params.Cursor = cursor
r, err := s.ListHistory(ctx, params)
if err != nil {
return nil, nil, err
}
return r.Items, nextCursor(r.NextCursor), nil
})
}
func (p ListRentalHistoryParams) query() url.Values {
q := url.Values{}
if p.Cursor != nil {
q.Set("cursor", fmt.Sprint(*p.Cursor))
}
if p.Limit != nil {
q.Set("limit", fmt.Sprint(*p.Limit))
}
if p.GPUType != nil {
q.Set("gpuType", fmt.Sprint(*p.GPUType))
}
if p.Region != nil {
q.Set("region", fmt.Sprint(*p.Region))
}
if p.TermType != nil {
q.Set("termType", fmt.Sprint(*p.TermType))
}
if p.IncludePrivateCloud != nil {
q.Set("includePrivateCloud", fmt.Sprint(*p.IncludePrivateCloud))
}
if p.RentalType != nil {
q.Set("rentalType", fmt.Sprint(*p.RentalType))
}
return q
}
// Options calls GET /v2/on-demand/rental-options: get a list of rental options.
func (s *RentalsService) Options(ctx context.Context) ([]RentalOption, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/rental-options", idempotent: true}
var out []RentalOption
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return out, nil
}
// RebootInstance calls POST /v2/on-demand/rentals/reboot-instance: reboot a
// single instance within a rental.
//
// Reboots one instance. Call it only for an instance whose
// `instances[].supportsReboot` is true. Depending on the instance, this is
// either a warm in-place guest reset or a hard power cycle. Disk contents are
// preserved either way; unsaved in-memory work is lost. `instanceRef` is an
// entry of the rental's `instances[].instanceRef` (`<rentalId>-<node index>`).
// Reports INVALID_INSTANCE_REF for an `instanceRef` outside this rental,
// REBOOT_NOT_SUPPORTED for a rental that does not support reboot,
// REBOOT_ALREADY_IN_PROGRESS while one is in flight, and
// INSTANCE_NOT_READY_FOR_REBOOT when the instance is not running or has another
// operation in progress.
//
// It is not retried after a failure that may have reached the server. Such a
// failure matches [ErrOutcomeUnknown]: check whether the call took effect
// before making it again.
func (s *RentalsService) RebootInstance(ctx context.Context, params RebootRentalInstanceParams) (*RentalInstanceReboot, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/rentals/reboot-instance", idempotent: false, body: params}
var out RentalInstanceReboot
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// RequestReservation calls POST /v2/on-demand/request-reservation: request a
// reservation.
//
// # Request a reservation for a large instance
//
// It is not retried after a failure that may have reached the server. Such a
// failure matches [ErrOutcomeUnknown]: check whether the call took effect
// before making it again.
func (s *RentalsService) RequestReservation(ctx context.Context, params RequestReservationParams) (*ReservationRequest, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/request-reservation", idempotent: false, body: params}
var out ReservationRequest
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// ReserveOptions calls GET /v2/on-demand/reserve-options: get a list of reserve
// options.
//
// Get a list of reserve options. Pass `termPeriodDays` to also get the discount
// for that length as `requestedOption`.
func (s *RentalsService) ReserveOptions(ctx context.Context, params ListReserveOptionsParams) (*ReserveOptions, error) {
c := call{method: http.MethodGet, path: "/v2/on-demand/reserve-options", idempotent: true, query: params.query()}
var out ReserveOptions
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
func (p ListReserveOptionsParams) query() url.Values {
q := url.Values{}
if p.TermPeriodDays != nil {
q.Set("termPeriodDays", fmt.Sprint(*p.TermPeriodDays))
}
return q
}
// SetMonitoringOptOut calls POST /v2/on-demand/rentals/monitoring-opt-out: opt
// a rental in or out of Hyperbolic telemetry.
//
// Opt a running or pending virtual machine rental in or out of Hyperbolic
// telemetry. Takes effect within a few minutes, without a restart. Collection
// is on unless a rental is opted out. Only standalone virtual machine rentals
// in supported regions can opt out, not Kubernetes cluster node pools: other
// rentals get a 400. An unknown rental gets `RENTAL_NOT_FOUND`, and a failed
// update a 500 that is safe to retry.
func (s *RentalsService) SetMonitoringOptOut(ctx context.Context, params SetRentalMonitoringOptOutParams) (*SuccessResponse, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/rentals/monitoring-opt-out", idempotent: true, body: params}
var out SuccessResponse
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// Terminate calls POST /v2/on-demand/rentals/terminate: terminate a rental.
//
// Terminate a virtual machine or bare metal rental.
func (s *RentalsService) Terminate(ctx context.Context, params TerminateRentalParams) (*RentalTermination, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/rentals/terminate", idempotent: true, body: params}
var out RentalTermination
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// Update calls POST /v2/on-demand/rentals/update: update a rental.
//
// Update a rental's label and/or its reserved-term end-of-term action. Pass an
// empty label to clear it.
func (s *RentalsService) Update(ctx context.Context, params UpdateRentalParams) (*Rental, error) {
c := call{method: http.MethodPost, path: "/v2/on-demand/rentals/update", idempotent: true, body: params}
var out Rental
if err := s.t.do(ctx, c, &out); err != nil {
return nil, err
}
return &out, nil
}
// ActiveRentalLookup A rental lookup that found a running rental.
type ActiveRentalLookup struct {
// Rental A GPU rental with its live status.
Rental RentalWithStatus `json:"rental"`
State ActiveRentalLookupState `json:"state"`
}
// ActiveRentalLookupState defines model for ActiveRentalLookup.State.
type ActiveRentalLookupState string
// Defines values for ActiveRentalLookupState.
const (
ActiveRentalLookupStateActive ActiveRentalLookupState = "active"
)
// Valid indicates whether the value is a known member of the ActiveRentalLookupState enum.
func (e ActiveRentalLookupState) Valid() bool {
switch e {
case ActiveRentalLookupStateActive:
return true
default:
return false
}
}
// ActiveRentalSummary How many rentals the caller has active, and their summed hourly cost in cents.
type ActiveRentalSummary struct {
// ByTermType Active rental totals for each term type.
ByTermType ActiveRentalSummaryByTermType `json:"byTermType"`
CostPerHourCents int `json:"costPerHourCents"`
Count int `json:"count"`
}
// ActiveRentalSummaryByTermType Active rental totals for each term type.
type ActiveRentalSummaryByTermType struct {
// OnDemand How many active rentals are on one term type, and their summed hourly cost in cents.
OnDemand RentalTermTypeSummary `json:"on-demand"`
// PrivateCloud How many active rentals are on one term type, and their summed hourly cost in cents.
PrivateCloud RentalTermTypeSummary `json:"private-cloud"`
// Reserved How many active rentals are on one term type, and their summed hourly cost in cents.
Reserved RentalTermTypeSummary `json:"reserved"`
}
// ActiveRentalsPage One numbered page of active rentals, most recently started first.
type ActiveRentalsPage struct {
Items []RentalWithStatus `json:"items"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
Total int `json:"total"`
TotalPages int `json:"totalPages"`
}
// AttachSSHKeyParams defines model for AttachSSHKeyParams.
type AttachSSHKeyParams struct {
RentalID string `json:"rentalId"`
SSHPublicKeyID int `json:"sshPublicKeyId"`
}
// AttachedStorage A storage volume as seen from a rental it is attached to.
type AttachedStorage struct {
CostPerHourCents float64 `json:"costPerHourCents"`
Label string `json:"label"`
SizeInGb int `json:"sizeInGb"`
StorageVolumeID string `json:"storageVolumeId"`
VirtualIP string `json:"virtualIp"`
}
// BareMetalOption defines model for BareMetalOption.
type BareMetalOption struct {
ConnectionType ConnectionType `json:"connectionType"`
CostPerHourCents float64 `json:"costPerHourCents"`
Enabled bool `json:"enabled"`
EthernetVariant *EthernetVariant `json:"ethernetVariant,omitempty"`
GPUCount int `json:"gpuCount"`
GPUFormFactor GPUFormFactor `json:"gpuFormFactor"`
GPUType string `json:"gpuType"`
MachineType BareMetalOptionMachineType `json:"machineType"`
Nodes []struct {
CPUCount int `json:"cpuCount"`
CPUModel string `json:"cpuModel"`
GPUCount int `json:"gpuCount"`
RAMGb int `json:"ramGb"`
StorageGb int `json:"storageGb"`
} `json:"nodes"`
Region string `json:"region"`
// SpotAvailable GPUs a new spot rental of this option can still claim, where the provider reports spot capacity.
SpotAvailable *int `json:"spotAvailable,omitempty"`
// SpotNoticeSeconds The shortest notice a new spot rental of this option would get before an interruption.
SpotNoticeSeconds *int `json:"spotNoticeSeconds,omitempty"`
// SpotOnly Whether this option can only be rented on the spot term.
SpotOnly *bool `json:"spotOnly,omitempty"`
SupportsCustomPorts bool `json:"supportsCustomPorts"`
SupportsMultipleSSHKeys bool `json:"supportsMultipleSshKeys"`
SupportsSSHKeyUpdates bool `json:"supportsSshKeyUpdates"`
TotalAvailable *int `json:"totalAvailable,omitempty"`
}
// BareMetalOptionMachineType defines model for BareMetalOption.MachineType.
type BareMetalOptionMachineType string
// Defines values for BareMetalOptionMachineType.
const (
BareMetalOptionMachineTypeBareMetal BareMetalOptionMachineType = "bare-metal"
)
// Valid indicates whether the value is a known member of the BareMetalOptionMachineType enum.
func (e BareMetalOptionMachineType) Valid() bool {
switch e {
case BareMetalOptionMachineTypeBareMetal:
return true
default:
return false
}
}
// ConnectionType defines model for ConnectionType.
type ConnectionType string
// Defines values for ConnectionType.
const (
ConnectionTypeEthernet ConnectionType = "ethernet"
ConnectionTypeInfiniband ConnectionType = "infiniband"
)
// Valid indicates whether the value is a known member of the ConnectionType enum.
func (e ConnectionType) Valid() bool {
switch e {
case ConnectionTypeEthernet:
return true
case ConnectionTypeInfiniband:
return true
default:
return false
}
}
// ConvertRentalToReservedParams defines model for ConvertRentalToReservedParams.
type ConvertRentalToReservedParams struct {
ExpectedTotalPriceCents int `json:"expectedTotalPriceCents"`
RentalID string `json:"rentalId"`
// TermPeriodDays Any whole number of days from 1 to 30 where custom reservation lengths are enabled for your account; otherwise one of the standard terms in `options` from `GET /v2/on-demand/reserve-options`.
TermPeriodDays int `json:"termPeriodDays"`
}
// CreateRentalParams defines model for CreateRentalParams.
type CreateRentalParams struct {
ConvertToOnDemandOnExpiry *bool `json:"convertToOnDemandOnExpiry,omitempty"`
// CUDAVersion Bare metal only.
CUDAVersion *CreateRentalParamsCUDAVersion `json:"cudaVersion,omitempty"`
// CustomPorts Virtual machines only.
CustomPorts *[]int `json:"customPorts,omitempty"`
DiscountPercentage *float64 `json:"discountPercentage,omitempty"`
// GPUCount GPUs to rent. Bare metal rents whole nodes, so a multiple of 8.
GPUCount int `json:"gpuCount"`
GPUType *string `json:"gpuType,omitempty"`
Label *string `json:"label,omitempty"`
MonitoringEnabled *bool `json:"monitoringEnabled,omitempty"`
// MonitoringOptOut Virtual machines only. Opt the rental out of Hyperbolic telemetry: the GPU health and system metrics (CPU, memory, root filesystem, network interfaces) Hyperbolic collects from inside the virtual machine to detect hardware faults. No logs, process lists or file contents are collected. Omitted or `false` leaves collection on. Only standalone virtual machine rentals in supported regions can opt out; elsewhere `true` gets a 400.
MonitoringOptOut *bool `json:"monitoringOptOut,omitempty"`
// NetworkType Required for bare metal. Virtual machines default to `ethernet`.
NetworkType *CreateRentalParamsNetworkType `json:"networkType,omitempty"`
// Region A region that offers the chosen machine type.
Region *string `json:"region,omitempty"`
RentalType RentalType `json:"rentalType"`
// SSHPublicKeyID The saved SSH key to authorize on the rental. Defaults to the most recently added key.
SSHPublicKeyID *int `json:"sshPublicKeyId,omitempty"`
// SSHPublicKeyIds The saved SSH keys to authorize on the rental.
SSHPublicKeyIds *[]int `json:"sshPublicKeyIds,omitempty"`
// StorageVolume Bare metal only.
StorageVolume *StorageVolumeChoice `json:"storageVolume,omitempty"`
// TermPeriodDays Any whole number of days from 1 to 30 where custom reservation lengths are enabled for your account; otherwise one of the standard terms in `options` from `GET /v2/on-demand/reserve-options`.
TermPeriodDays *int `json:"termPeriodDays,omitempty"`
TermType *TermType `json:"termType,omitempty"`
}
// CreateRentalParamsCUDAVersion Bare metal only.
type CreateRentalParamsCUDAVersion string
// Defines values for CreateRentalParamsCUDAVersion.
const (
CreateRentalParamsCUDAVersionCuda128 CreateRentalParamsCUDAVersion = "cuda12.8"
CreateRentalParamsCUDAVersionCuda129 CreateRentalParamsCUDAVersion = "cuda12.9"
)
// Valid indicates whether the value is a known member of the CreateRentalParamsCUDAVersion enum.
func (e CreateRentalParamsCUDAVersion) Valid() bool {
switch e {
case CreateRentalParamsCUDAVersionCuda128:
return true
case CreateRentalParamsCUDAVersionCuda129:
return true
default:
return false
}
}
// CreateRentalParamsNetworkType Required for bare metal. Virtual machines default to `ethernet`.
type CreateRentalParamsNetworkType string
// Defines values for CreateRentalParamsNetworkType.
const (
CreateRentalParamsNetworkTypeEthernet CreateRentalParamsNetworkType = "ethernet"
CreateRentalParamsNetworkTypeInfiniband CreateRentalParamsNetworkType = "infiniband"
)
// Valid indicates whether the value is a known member of the CreateRentalParamsNetworkType enum.
func (e CreateRentalParamsNetworkType) Valid() bool {
switch e {
case CreateRentalParamsNetworkTypeEthernet:
return true
case CreateRentalParamsNetworkTypeInfiniband:
return true
default:
return false
}
}
// DetachSSHKeyParams defines model for DetachSSHKeyParams.
type DetachSSHKeyParams struct {
RentalID string `json:"rentalId"`
SSHPublicKeyID int `json:"sshPublicKeyId"`
}
// EthernetVariant defines model for EthernetVariant.
type EthernetVariant string
// Defines values for EthernetVariant.
const (
EthernetVariantNormal EthernetVariant = "normal"
EthernetVariantRocev2 EthernetVariant = "rocev2"
)
// Valid indicates whether the value is a known member of the EthernetVariant enum.
func (e EthernetVariant) Valid() bool {
switch e {
case EthernetVariantNormal:
return true
case EthernetVariantRocev2:
return true
default:
return false
}
}
// ExistingStorageVolume defines model for ExistingStorageVolume.
type ExistingStorageVolume struct {
ID string `json:"id"`
IsNew ExistingStorageVolumeIsNew `json:"isNew"`
}
// ExistingStorageVolumeIsNew defines model for ExistingStorageVolume.IsNew.
type ExistingStorageVolumeIsNew bool
// Defines values for ExistingStorageVolumeIsNew.
const (
ExistingStorageVolumeIsNewFalse ExistingStorageVolumeIsNew = false
)
// Valid indicates whether the value is a known member of the ExistingStorageVolumeIsNew enum.
func (e ExistingStorageVolumeIsNew) Valid() bool {
switch e {
case ExistingStorageVolumeIsNewFalse:
return true
default:
return false
}
}
// ExtendReservedRentalParams defines model for ExtendReservedRentalParams.
type ExtendReservedRentalParams struct {
// CurrentReservedUntil The reservation's current end date: the reservation extension quote's top-level `reservedUntil`, not the option's `newReservedUntil`. The extension is rejected if the end date has changed since the quote.
//
// Example: 2025-01-31T12:00:00.000Z
CurrentReservedUntil time.Time `json:"currentReservedUntil"`
ExpectedTotalPriceCents int `json:"expectedTotalPriceCents"`
RentalID string `json:"rentalId"`
// TermPeriodDays Any whole number of days from 1 to 30 where custom reservation lengths are enabled for your account; otherwise one of the standard terms in `options` from `GET /v2/on-demand/reserve-options`.
TermPeriodDays int `json:"termPeriodDays"`
}
// GPUFormFactor defines model for GPUFormFactor.
type GPUFormFactor string
// Defines values for GPUFormFactor.
const (
GPUFormFactorPCIE GPUFormFactor = "pcie"
GPUFormFactorSxm5 GPUFormFactor = "sxm5"
GPUFormFactorSxm6 GPUFormFactor = "sxm6"
)
// Valid indicates whether the value is a known member of the GPUFormFactor enum.
func (e GPUFormFactor) Valid() bool {
switch e {
case GPUFormFactorPCIE:
return true
case GPUFormFactorSxm5:
return true
case GPUFormFactorSxm6:
return true
default:
return false
}
}
// HistoricalRental A GPU rental that has ended, with its total cost.
type HistoricalRental struct {
AttachedStorage []AttachedStorage `json:"attachedStorage"`
ConnectionType ConnectionType `json:"connectionType"`
ConvertToOnDemandOnExpiry nullable.Nullable[bool] `json:"convertToOnDemandOnExpiry"`
// CreatedAt Example: 2025-01-31T12:00:00.000Z
CreatedAt time.Time `json:"createdAt"`
// CreatedBy The user who created a rental.
CreatedBy RentalCreator `json:"createdBy"`
CurrentTerm RentalTerm `json:"currentTerm"`
EthernetVariant nullable.Nullable[EthernetVariant] `json:"ethernetVariant"`
ExposedPorts []int `json:"exposedPorts"`
GPUCount int `json:"gpuCount"`
GPUFormFactor GPUFormFactor `json:"gpuFormFactor"`
GPUType string `json:"gpuType"`
Label nullable.Nullable[string] `json:"label"`
ManagedCluster nullable.Nullable[ManagedClusterRef] `json:"managedCluster"`
MonitoringEnabled bool `json:"monitoringEnabled"`
Name nullable.Nullable[string] `json:"name"`
NetworkInterfaces []NetworkInterface `json:"networkInterfaces"`
Nodes []RentalNode `json:"nodes"`
OrgID nullable.Nullable[string] `json:"orgId"`
PortMappings []PortMapping `json:"portMappings"`
PrivateCluster nullable.Nullable[PrivateCluster] `json:"privateCluster"`
Region string `json:"region"`
RentalID string `json:"rentalId"`
RentalType RentalType `json:"rentalType"`
SSHEndpoints []SSHEndpoint `json:"sshEndpoints"`
StartedAt nullable.Nullable[time.Time] `json:"startedAt"`
Status RentalStatus `json:"status"`
SupportsAttachedStorage bool `json:"supportsAttachedStorage"`
SupportsCustomPorts bool `json:"supportsCustomPorts"`
SupportsMultipleSSHKeys bool `json:"supportsMultipleSshKeys"`
SupportsPortForwarding bool `json:"supportsPortForwarding"`
SupportsSSHKeyUpdates bool `json:"supportsSshKeyUpdates"`
// TerminatedAt Example: 2025-01-31T12:00:00.000Z
TerminatedAt time.Time `json:"terminatedAt"`
TerminationReason nullable.Nullable[string] `json:"terminationReason"`
TotalCost float64 `json:"totalCost"`
UpdatedAt nullable.Nullable[time.Time] `json:"updatedAt"`
UserID string `json:"userId"`
}
// ManagedClusterRef The managed Kubernetes cluster a rental is a node pool of.
type ManagedClusterRef struct {
Label nullable.Nullable[string] `json:"label"`
Name string `json:"name"`
}
// NetworkInterface The public and private addresses of one node of a rental.
type NetworkInterface struct {
PrivateIP string `json:"privateIp"`
PublicIP string `json:"publicIp"`
}
// NewStorageVolume defines model for NewStorageVolume.
type NewStorageVolume struct {
IsNew NewStorageVolumeIsNew `json:"isNew"`
Label string `json:"label"`
SizeInGb int `json:"sizeInGb"`
}
// NewStorageVolumeIsNew defines model for NewStorageVolume.IsNew.
type NewStorageVolumeIsNew bool
// Defines values for NewStorageVolumeIsNew.
const (
NewStorageVolumeIsNewTrue NewStorageVolumeIsNew = true
)
// Valid indicates whether the value is a known member of the NewStorageVolumeIsNew enum.
func (e NewStorageVolumeIsNew) Valid() bool {
switch e {
case NewStorageVolumeIsNewTrue:
return true
default:
return false
}
}
// OnDemandTerm defines model for OnDemandTerm.
type OnDemandTerm struct {
CostPerHour float64 `json:"costPerHour"`
DiscountPercentage nullable.Nullable[any] `json:"discountPercentage"`
// EffectiveAt Example: 2025-01-31T12:00:00.000Z
EffectiveAt time.Time `json:"effectiveAt"`
OriginalCostPerHour nullable.Nullable[any] `json:"originalCostPerHour"`
ReservationEndsAt nullable.Nullable[any] `json:"reservationEndsAt"`
ReservedUntil nullable.Nullable[any] `json:"reservedUntil"`
TermPeriodDays nullable.Nullable[any] `json:"termPeriodDays"`
TermType OnDemandTermTermType `json:"termType"`
}
// OnDemandTermTermType defines model for OnDemandTerm.TermType.
type OnDemandTermTermType string
// Defines values for OnDemandTermTermType.
const (
OnDemandTermTermTypeOnDemand OnDemandTermTermType = "on-demand"
)
// Valid indicates whether the value is a known member of the OnDemandTermTermType enum.
func (e OnDemandTermTermType) Valid() bool {
switch e {
case OnDemandTermTermTypeOnDemand:
return true
default:
return false
}
}
// PortMapping A port reachable from outside, and the port it reaches inside the machine.
type PortMapping struct {
ExternalPort int `json:"externalPort"`
InternalPort int `json:"internalPort"`
}
// PrivateCloudTerm defines model for PrivateCloudTerm.
type PrivateCloudTerm struct {
CostPerHour float64 `json:"costPerHour"`
DiscountPercentage nullable.Nullable[any] `json:"discountPercentage"`
// EffectiveAt Example: 2025-01-31T12:00:00.000Z
EffectiveAt time.Time `json:"effectiveAt"`
OriginalCostPerHour nullable.Nullable[any] `json:"originalCostPerHour"`
ReservationEndsAt nullable.Nullable[any] `json:"reservationEndsAt"`
ReservedUntil nullable.Nullable[any] `json:"reservedUntil"`
TermPeriodDays nullable.Nullable[any] `json:"termPeriodDays"`
TermType PrivateCloudTermTermType `json:"termType"`
}
// PrivateCloudTermTermType defines model for PrivateCloudTerm.TermType.
type PrivateCloudTermTermType string
// Defines values for PrivateCloudTermTermType.
const (
PrivateCloudTermTermTypePrivateCloud PrivateCloudTermTermType = "private-cloud"
)
// Valid indicates whether the value is a known member of the PrivateCloudTermTermType enum.
func (e PrivateCloudTermTermType) Valid() bool {
switch e {
case PrivateCloudTermTermTypePrivateCloud:
return true
default:
return false
}
}
// PrivateCluster The topology of a dedicated private cluster.
type PrivateCluster struct {
GPUModel nullable.Nullable[string] `json:"gpuModel"`
Handover map[string]any `json:"handover"`
Location nullable.Nullable[string] `json:"location"`
Nodes []PrivateClusterNode `json:"nodes"`
SSHPort nullable.Nullable[float64] `json:"sshPort"`
SSHUser string `json:"sshUser"`
}
// PrivateClusterNode One machine of a dedicated private cluster.
type PrivateClusterNode struct {
Hostname nullable.Nullable[string] `json:"hostname"`
PrivateIP string `json:"privateIp"`
PublicIP nullable.Nullable[string] `json:"publicIp"`
Role PrivateClusterNodeRole `json:"role"`
}
// PrivateClusterNodeRole defines model for PrivateClusterNode.Role.
type PrivateClusterNodeRole string
// Defines values for PrivateClusterNodeRole.
const (
PrivateClusterNodeRoleCompute PrivateClusterNodeRole = "compute"
PrivateClusterNodeRoleHead PrivateClusterNodeRole = "head"
PrivateClusterNodeRoleLogin PrivateClusterNodeRole = "login"
)
// Valid indicates whether the value is a known member of the PrivateClusterNodeRole enum.
func (e PrivateClusterNodeRole) Valid() bool {
switch e {
case PrivateClusterNodeRoleCompute:
return true
case PrivateClusterNodeRoleHead:
return true
case PrivateClusterNodeRoleLogin:
return true
default:
return false
}
}
// RebootRentalInstanceParams defines model for RebootRentalInstanceParams.
type RebootRentalInstanceParams struct {
InstanceRef string `json:"instanceRef"`
RentalID string `json:"rentalId"`
}
// Rental A GPU rental.
type Rental struct {
AttachedStorage []AttachedStorage `json:"attachedStorage"`
ConnectionType ConnectionType `json:"connectionType"`
ConvertToOnDemandOnExpiry nullable.Nullable[bool] `json:"convertToOnDemandOnExpiry"`
// CreatedAt Example: 2025-01-31T12:00:00.000Z
CreatedAt time.Time `json:"createdAt"`
// CreatedBy The user who created a rental.
CreatedBy RentalCreator `json:"createdBy"`
CurrentTerm RentalTerm `json:"currentTerm"`
EthernetVariant nullable.Nullable[EthernetVariant] `json:"ethernetVariant"`
ExposedPorts []int `json:"exposedPorts"`
GPUCount int `json:"gpuCount"`
GPUFormFactor GPUFormFactor `json:"gpuFormFactor"`
GPUType string `json:"gpuType"`
Label nullable.Nullable[string] `json:"label"`
ManagedCluster nullable.Nullable[ManagedClusterRef] `json:"managedCluster"`
MonitoringEnabled bool `json:"monitoringEnabled"`
Name nullable.Nullable[string] `json:"name"`
NetworkInterfaces []NetworkInterface `json:"networkInterfaces"`
Nodes []RentalNode `json:"nodes"`
OrgID nullable.Nullable[string] `json:"orgId"`
PortMappings []PortMapping `json:"portMappings"`
PrivateCluster nullable.Nullable[PrivateCluster] `json:"privateCluster"`