latitude-api 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +10 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +283 -0
  5. data/Rakefile +13 -0
  6. data/lib/latitude/api/api_object.rb +105 -0
  7. data/lib/latitude/api/api_resource.rb +260 -0
  8. data/lib/latitude/api/attributes.rb +64 -0
  9. data/lib/latitude/api/client.rb +80 -0
  10. data/lib/latitude/api/configuration.rb +88 -0
  11. data/lib/latitude/api/errors.rb +134 -0
  12. data/lib/latitude/api/json_api.rb +40 -0
  13. data/lib/latitude/api/list_object.rb +129 -0
  14. data/lib/latitude/api/objects.rb +216 -0
  15. data/lib/latitude/api/operations/action.rb +41 -0
  16. data/lib/latitude/api/operations/create.rb +22 -0
  17. data/lib/latitude/api/operations/delete.rb +22 -0
  18. data/lib/latitude/api/operations/list.rb +54 -0
  19. data/lib/latitude/api/operations/nested.rb +53 -0
  20. data/lib/latitude/api/operations/retrieve.rb +22 -0
  21. data/lib/latitude/api/operations/update.rb +22 -0
  22. data/lib/latitude/api/request_executor.rb +217 -0
  23. data/lib/latitude/api/request_options.rb +86 -0
  24. data/lib/latitude/api/request_params.rb +70 -0
  25. data/lib/latitude/api/resources/api_key.rb +61 -0
  26. data/lib/latitude/api/resources/billing_usage.rb +51 -0
  27. data/lib/latitude/api/resources/elastic_ip.rb +96 -0
  28. data/lib/latitude/api/resources/event.rb +55 -0
  29. data/lib/latitude/api/resources/firewall.rb +129 -0
  30. data/lib/latitude/api/resources/ip.rb +110 -0
  31. data/lib/latitude/api/resources/kubernetes_cluster.rb +184 -0
  32. data/lib/latitude/api/resources/plan.rb +658 -0
  33. data/lib/latitude/api/resources/project.rb +179 -0
  34. data/lib/latitude/api/resources/region.rb +41 -0
  35. data/lib/latitude/api/resources/role.rb +20 -0
  36. data/lib/latitude/api/resources/server.rb +251 -0
  37. data/lib/latitude/api/resources/ssh_key.rb +44 -0
  38. data/lib/latitude/api/resources/storage_filesystem.rb +36 -0
  39. data/lib/latitude/api/resources/storage_object.rb +85 -0
  40. data/lib/latitude/api/resources/storage_volume.rb +64 -0
  41. data/lib/latitude/api/resources/tag.rb +34 -0
  42. data/lib/latitude/api/resources/team.rb +169 -0
  43. data/lib/latitude/api/resources/traffic.rb +215 -0
  44. data/lib/latitude/api/resources/user_data.rb +38 -0
  45. data/lib/latitude/api/resources/user_profile.rb +51 -0
  46. data/lib/latitude/api/resources/user_team.rb +90 -0
  47. data/lib/latitude/api/resources/virtual_machine.rb +146 -0
  48. data/lib/latitude/api/resources/virtual_network.rb +162 -0
  49. data/lib/latitude/api/resources/vpn_session.rb +80 -0
  50. data/lib/latitude/api/singleton_api_resource.rb +22 -0
  51. data/lib/latitude/api/util.rb +64 -0
  52. data/lib/latitude/api/version.rb +7 -0
  53. data/lib/latitude/api.rb +147 -0
  54. data/lib/latitude/metadata/errors.rb +18 -0
  55. data/lib/latitude/metadata/session.rb +109 -0
  56. data/lib/latitude/metadata.rb +43 -0
  57. data/lib/latitude.rb +4 -0
  58. metadata +132 -0
@@ -0,0 +1,658 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Latitude
4
+ module API
5
+ module Resources
6
+ # @!attribute [rw] slug
7
+ # @return [String]
8
+ # @!attribute [rw] name
9
+ # @return [String]
10
+ # @!attribute [rw] features
11
+ # @return [Array]
12
+ # @!attribute [rw] specs
13
+ # @return [Spec]
14
+ # @!attribute [rw] regions
15
+ # @return [Array<Region>]
16
+ class Plan < APIResource
17
+ # @!attribute [r] type
18
+ # @return [String]
19
+ # @!attribute [r] clock
20
+ # @return [Float]
21
+ # @!attribute [r] cores
22
+ # @return [Integer]
23
+ # @!attribute [r] count
24
+ # @return [Integer]
25
+ class Cpu < APIObject
26
+ attribute :type, :string, read_only: true
27
+ attribute :clock, :float, read_only: true
28
+ attribute :cores, :integer, read_only: true
29
+ attribute :count, :integer, read_only: true
30
+ end
31
+
32
+ # @!attribute [r] total
33
+ # @return [Integer]
34
+ class Memory < APIObject
35
+ attribute :total, :integer, read_only: true
36
+ end
37
+
38
+ # @!attribute [r] count
39
+ # @return [Integer]
40
+ # @!attribute [r] size
41
+ # @return [String]
42
+ # @!attribute [r] type
43
+ # @return [String]
44
+ class Drive < APIObject
45
+ attribute :count, :integer, read_only: true
46
+ attribute :size, :string, read_only: true
47
+ attribute :type, :string, read_only: true
48
+ end
49
+
50
+ # @!attribute [r] count
51
+ # @return [Integer]
52
+ # @!attribute [r] type
53
+ # @return [String]
54
+ class Nic < APIObject
55
+ attribute :count, :integer, read_only: true
56
+ attribute :type, :string, read_only: true
57
+ end
58
+
59
+ # @!attribute [r] count
60
+ # @return [Integer]
61
+ # @!attribute [r] type
62
+ # @return [String]
63
+ # @!attribute [r] vram_per_gpu
64
+ # @return [String]
65
+ # @!attribute [r] interconnect
66
+ # @return [String]
67
+ class Gpu < APIObject
68
+ attribute :count, :integer, read_only: true
69
+ attribute :type, :string, read_only: true
70
+ attribute :vram_per_gpu, :string, read_only: true
71
+ attribute :interconnect, :string, read_only: true
72
+ end
73
+
74
+ # @!attribute [r] cpu
75
+ # @return [Cpu]
76
+ # @!attribute [r] memory
77
+ # @return [Memory]
78
+ # @!attribute [r] drives
79
+ # @return [Array<Drive>]
80
+ # @!attribute [r] nics
81
+ # @return [Array<Nic>]
82
+ # @!attribute [r] gpu
83
+ # @return [Gpu]
84
+ class Spec < APIObject
85
+ attribute :cpu, Cpu, read_only: true
86
+ attribute :memory, Memory, read_only: true
87
+ attribute :drives, [Drive], read_only: true
88
+ attribute :nics, [Nic], read_only: true
89
+ attribute :gpu, Gpu, read_only: true
90
+ end
91
+
92
+ # @!attribute [r] available
93
+ # @return [Array]
94
+ # @!attribute [r] in_stock
95
+ # @return [Array]
96
+ class Location < APIObject
97
+ attribute :available, :array, read_only: true
98
+ attribute :in_stock, :array, read_only: true
99
+ end
100
+
101
+ # @!attribute [r] hour
102
+ # @return [Integer]
103
+ # @!attribute [r] month
104
+ # @return [Integer]
105
+ # @!attribute [r] year
106
+ # @return [Integer]
107
+ class USD < APIObject
108
+ attribute :hour, :integer, read_only: true
109
+ attribute :month, :integer, read_only: true
110
+ attribute :year, :integer, read_only: true
111
+ end
112
+
113
+ # @!attribute [r] hour
114
+ # @return [Integer]
115
+ # @!attribute [r] month
116
+ # @return [Float]
117
+ # @!attribute [r] year
118
+ # @return [Integer]
119
+ class BRL < APIObject
120
+ attribute :hour, :integer, read_only: true
121
+ attribute :month, :float, read_only: true
122
+ attribute :year, :integer, read_only: true
123
+ end
124
+
125
+ # @!attribute [r] USD
126
+ # @return [USD]
127
+ # @!attribute [r] BRL
128
+ # @return [BRL]
129
+ class Pricing < APIObject
130
+ attribute :USD, USD, read_only: true
131
+ attribute :BRL, BRL, read_only: true
132
+ end
133
+
134
+ # @!attribute [r] name
135
+ # @return [String]
136
+ # @!attribute [r] deploys_instantly
137
+ # @return [Array]
138
+ # @!attribute [r] locations
139
+ # @return [Location]
140
+ # @!attribute [r] stock_level
141
+ # @return [String]
142
+ # @!attribute [r] pricing
143
+ # @return [Pricing]
144
+ class Region < APIObject
145
+ attribute :name, :string, read_only: true
146
+ attribute :deploys_instantly, :array, read_only: true
147
+ attribute :locations, Location, read_only: true
148
+ attribute :stock_level, :string, read_only: true
149
+ attribute :pricing, Pricing, read_only: true
150
+ end
151
+
152
+ attribute :slug, :string
153
+ attribute :name, :string
154
+ attribute :features, :array
155
+ attribute :specs, Spec
156
+ attribute :regions, [Region]
157
+
158
+ resource_type "plans"
159
+ resource_path "/plans"
160
+ id_prefix "plan_"
161
+
162
+ extend Operations::List
163
+ extend Operations::Retrieve
164
+
165
+ # @!attribute [rw] name
166
+
167
+ # @return [String]
168
+
169
+ # @!attribute [rw] distro
170
+
171
+ # @return [String]
172
+
173
+ # @!attribute [rw] slug
174
+
175
+ # @return [String]
176
+
177
+ # @!attribute [rw] version
178
+
179
+ # @return [String]
180
+
181
+ # @!attribute [rw] user
182
+
183
+ # @return [String]
184
+
185
+ # @!attribute [rw] features
186
+
187
+ # @return [Feature]
188
+
189
+ # @!attribute [rw] provisionable_on
190
+
191
+ # @return [Array]
192
+
193
+ class OperatingSystem < APIResource
194
+
195
+
196
+ class Feature < APIObject
197
+
198
+
199
+ end
200
+
201
+
202
+ attribute :name, :string
203
+
204
+ attribute :distro, :string
205
+
206
+ attribute :slug, :string
207
+
208
+ attribute :version, :string
209
+
210
+ attribute :user, :string
211
+
212
+ attribute :features, Feature
213
+
214
+ attribute :provisionable_on, :array
215
+
216
+ resource_type "operating_system"
217
+ resource_path "/plans/operating_systems"
218
+
219
+ extend Operations::List
220
+ end
221
+
222
+ # @!attribute [rw] region
223
+
224
+ # @return [String]
225
+
226
+ # @!attribute [rw] locations
227
+
228
+ # @return [Array]
229
+
230
+ # @!attribute [rw] pricing
231
+
232
+ # @return [Pricing]
233
+
234
+ class Bandwidth < APIResource
235
+
236
+ # @!attribute [r] monthly
237
+
238
+ # @return [Integer]
239
+
240
+ # @!attribute [r] yearly
241
+
242
+ # @return [Integer]
243
+
244
+ class Usd < APIObject
245
+
246
+ attribute :monthly, :integer, read_only: true
247
+
248
+ attribute :yearly, :integer, read_only: true
249
+
250
+ end
251
+
252
+
253
+ # @!attribute [r] monthly
254
+
255
+ # @return [Integer]
256
+
257
+ # @!attribute [r] yearly
258
+
259
+ # @return [String]
260
+
261
+ class Brl < APIObject
262
+
263
+ attribute :monthly, :integer, read_only: true
264
+
265
+ attribute :yearly, :string, read_only: true
266
+
267
+ end
268
+
269
+
270
+ # @!attribute [r] usd
271
+
272
+ # @return [Usd]
273
+
274
+ # @!attribute [r] brl
275
+
276
+ # @return [Brl]
277
+
278
+ class Pricing < APIObject
279
+
280
+ attribute :usd, Usd, read_only: true
281
+
282
+ attribute :brl, Brl, read_only: true
283
+
284
+ end
285
+
286
+
287
+ attribute :region, :string
288
+
289
+ attribute :locations, :array
290
+
291
+ attribute :pricing, Pricing
292
+
293
+ resource_type "bandwidth_plan"
294
+ resource_path "/plans/bandwidth"
295
+
296
+ extend Operations::List
297
+
298
+ class << self
299
+ def update_packages(attributes = {}, opts = {})
300
+ body = JSONAPI.encode(type: "bandwidth_packages", attributes: attributes)
301
+ execute_request(method: :post, path: resource_path, body: body, opts: opts)
302
+ end
303
+ end
304
+ end
305
+
306
+ # @!attribute [rw] name
307
+
308
+ # @return [String]
309
+
310
+ # @!attribute [rw] regions
311
+
312
+ # @return [Array<Region>]
313
+
314
+ class Storage < APIResource
315
+
316
+ # @!attribute [r] month
317
+
318
+ # @return [Float]
319
+
320
+ class USD < APIObject
321
+
322
+ attribute :month, :float, read_only: true
323
+
324
+ end
325
+
326
+
327
+ # @!attribute [r] month
328
+
329
+ # @return [Float]
330
+
331
+ class BRL < APIObject
332
+
333
+ attribute :month, :float, read_only: true
334
+
335
+ end
336
+
337
+
338
+ # @!attribute [r] USD
339
+
340
+ # @return [USD]
341
+
342
+ # @!attribute [r] BRL
343
+
344
+ # @return [BRL]
345
+
346
+ class Pricing < APIObject
347
+
348
+ attribute :USD, USD, read_only: true
349
+
350
+ attribute :BRL, BRL, read_only: true
351
+
352
+ end
353
+
354
+
355
+ # @!attribute [r] name
356
+
357
+ # @return [String]
358
+
359
+ # @!attribute [r] locations
360
+
361
+ # @return [Array]
362
+
363
+ # @!attribute [r] pricing
364
+
365
+ # @return [Pricing]
366
+
367
+ class Region < APIObject
368
+
369
+ attribute :name, :string, read_only: true
370
+
371
+ attribute :locations, :array, read_only: true
372
+
373
+ attribute :pricing, Pricing, read_only: true
374
+
375
+ end
376
+
377
+
378
+ attribute :name, :string
379
+
380
+ attribute :regions, [Region]
381
+
382
+ resource_type "storage_plans"
383
+ resource_path "/plans/storage"
384
+
385
+ extend Operations::List
386
+ end
387
+
388
+ # @!attribute [rw] name
389
+
390
+ # @return [String]
391
+
392
+ # @!attribute [rw] specs
393
+
394
+ # @return [Spec]
395
+
396
+ # @!attribute [rw] regions
397
+
398
+ # @return [Array<Region>]
399
+
400
+ # @!attribute [rw] stock_level
401
+
402
+ # @return [String]
403
+
404
+ # @!attribute [rw] available_operating_systems
405
+
406
+ # @return [Array]
407
+
408
+ class VirtualMachine < APIResource
409
+
410
+ # @!attribute [r] count
411
+
412
+ # @return [Integer]
413
+
414
+ # @!attribute [r] clock
415
+
416
+ # @return [Float]
417
+
418
+ # @!attribute [r] type
419
+
420
+ # @return [String]
421
+
422
+ class Vcpu < APIObject
423
+
424
+ attribute :count, :integer, read_only: true
425
+
426
+ attribute :clock, :float, read_only: true
427
+
428
+ attribute :type, :string, read_only: true
429
+
430
+ end
431
+
432
+
433
+ # @!attribute [r] type
434
+
435
+ # @return [String]
436
+
437
+ # @!attribute [r] count
438
+
439
+ # @return [String]
440
+
441
+ class Nic < APIObject
442
+
443
+ attribute :type, :string, read_only: true
444
+
445
+ attribute :count, :string, read_only: true
446
+
447
+ end
448
+
449
+
450
+ # @!attribute [r] amount
451
+
452
+ # @return [Integer]
453
+
454
+ # @!attribute [r] unit
455
+
456
+ # @return [String]
457
+
458
+ class Size < APIObject
459
+
460
+ attribute :amount, :integer, read_only: true
461
+
462
+ attribute :unit, :string, read_only: true
463
+
464
+ end
465
+
466
+
467
+ # @!attribute [r] type
468
+
469
+ # @return [String]
470
+
471
+ # @!attribute [r] size
472
+
473
+ # @return [Size]
474
+
475
+ class Disk < APIObject
476
+
477
+ attribute :type, :string, read_only: true
478
+
479
+ attribute :size, Size, read_only: true
480
+
481
+ end
482
+
483
+
484
+ # @!attribute [r] memory
485
+
486
+ # @return [Integer]
487
+
488
+ # @!attribute [r] gpu
489
+
490
+ # @return [String]
491
+
492
+ # @!attribute [r] vram_per_gpu
493
+
494
+ # @return [Integer]
495
+
496
+ # @!attribute [r] vcpus
497
+
498
+ # @return [Integer]
499
+
500
+ # @!attribute [r] vcpu
501
+
502
+ # @return [Vcpu]
503
+
504
+ # @!attribute [r] nics
505
+
506
+ # @return [Array<Nic>]
507
+
508
+ # @!attribute [r] disk
509
+
510
+ # @return [Disk]
511
+
512
+ class Spec < APIObject
513
+
514
+ attribute :memory, :integer, read_only: true
515
+
516
+ attribute :gpu, :string, read_only: true
517
+
518
+ attribute :vram_per_gpu, :integer, read_only: true
519
+
520
+ attribute :vcpus, :integer, read_only: true
521
+
522
+ attribute :vcpu, Vcpu, read_only: true
523
+
524
+ attribute :nics, [Nic], read_only: true
525
+
526
+ attribute :disk, Disk, read_only: true
527
+
528
+ end
529
+
530
+
531
+ # @!attribute [r] available
532
+
533
+ # @return [Array]
534
+
535
+ # @!attribute [r] in_stock
536
+
537
+ # @return [Array]
538
+
539
+ class Location < APIObject
540
+
541
+ attribute :available, :array, read_only: true
542
+
543
+ attribute :in_stock, :array, read_only: true
544
+
545
+ end
546
+
547
+
548
+ # @!attribute [r] hour
549
+
550
+ # @return [Integer]
551
+
552
+ # @!attribute [r] month
553
+
554
+ # @return [Integer]
555
+
556
+ # @!attribute [r] year
557
+
558
+ # @return [Integer]
559
+
560
+ class USD < APIObject
561
+
562
+ attribute :hour, :integer, read_only: true
563
+
564
+ attribute :month, :integer, read_only: true
565
+
566
+ attribute :year, :integer, read_only: true
567
+
568
+ end
569
+
570
+
571
+ # @!attribute [r] hour
572
+
573
+ # @return [Integer]
574
+
575
+ # @!attribute [r] month
576
+
577
+ # @return [Integer]
578
+
579
+ # @!attribute [r] year
580
+
581
+ # @return [Integer]
582
+
583
+ class BRL < APIObject
584
+
585
+ attribute :hour, :integer, read_only: true
586
+
587
+ attribute :month, :integer, read_only: true
588
+
589
+ attribute :year, :integer, read_only: true
590
+
591
+ end
592
+
593
+
594
+ # @!attribute [r] USD
595
+
596
+ # @return [USD]
597
+
598
+ # @!attribute [r] BRL
599
+
600
+ # @return [BRL]
601
+
602
+ class Pricing < APIObject
603
+
604
+ attribute :USD, USD, read_only: true
605
+
606
+ attribute :BRL, BRL, read_only: true
607
+
608
+ end
609
+
610
+
611
+ # @!attribute [r] name
612
+
613
+ # @return [String]
614
+
615
+ # @!attribute [r] locations
616
+
617
+ # @return [Location]
618
+
619
+ # @!attribute [r] stock_level
620
+
621
+ # @return [String]
622
+
623
+ # @!attribute [r] pricing
624
+
625
+ # @return [Pricing]
626
+
627
+ class Region < APIObject
628
+
629
+ attribute :name, :string, read_only: true
630
+
631
+ attribute :locations, Location, read_only: true
632
+
633
+ attribute :stock_level, :string, read_only: true
634
+
635
+ attribute :pricing, Pricing, read_only: true
636
+
637
+ end
638
+
639
+
640
+ attribute :name, :string
641
+
642
+ attribute :specs, Spec
643
+
644
+ attribute :regions, [Region]
645
+
646
+ attribute :stock_level, :string
647
+
648
+ attribute :available_operating_systems, :array
649
+
650
+ resource_type "virtual_machine_plans"
651
+ resource_path "/plans/virtual_machines"
652
+
653
+ extend Operations::List
654
+ end
655
+ end
656
+ end
657
+ end
658
+ end