nightona 0.191.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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +22 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE +190 -0
- data/README.md +184 -0
- data/Rakefile +12 -0
- data/lib/nightona/code_interpreter.rb +359 -0
- data/lib/nightona/common/charts.rb +124 -0
- data/lib/nightona/common/code_interpreter.rb +56 -0
- data/lib/nightona/common/code_language.rb +14 -0
- data/lib/nightona/common/file_system.rb +26 -0
- data/lib/nightona/common/git.rb +19 -0
- data/lib/nightona/common/image.rb +500 -0
- data/lib/nightona/common/nightona.rb +230 -0
- data/lib/nightona/common/process.rb +149 -0
- data/lib/nightona/common/pty.rb +309 -0
- data/lib/nightona/common/resources.rb +39 -0
- data/lib/nightona/common/response.rb +83 -0
- data/lib/nightona/common/snapshot.rb +124 -0
- data/lib/nightona/computer_use.rb +919 -0
- data/lib/nightona/config.rb +116 -0
- data/lib/nightona/file_system.rb +451 -0
- data/lib/nightona/file_transfer.rb +383 -0
- data/lib/nightona/git.rb +334 -0
- data/lib/nightona/lsp_server.rb +139 -0
- data/lib/nightona/nightona.rb +336 -0
- data/lib/nightona/object_storage.rb +172 -0
- data/lib/nightona/otel.rb +183 -0
- data/lib/nightona/process.rb +550 -0
- data/lib/nightona/sandbox.rb +751 -0
- data/lib/nightona/sdk/version.rb +10 -0
- data/lib/nightona/sdk.rb +56 -0
- data/lib/nightona/snapshot_service.rb +238 -0
- data/lib/nightona/util.rb +80 -0
- data/lib/nightona/volume.rb +46 -0
- data/lib/nightona/volume_service.rb +61 -0
- data/lib/nightona.rb +10 -0
- data/project.json +100 -0
- data/scripts/generate-docs.rb +402 -0
- data/sig/nightona/sdk.rbs +6 -0
- metadata +242 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Copyright Daytona Platforms Inc.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module Nightona
|
|
7
|
+
class Resources
|
|
8
|
+
# @return [Integer, nil] Number of CPU cores to allocate
|
|
9
|
+
attr_reader :cpu
|
|
10
|
+
|
|
11
|
+
# @return [Integer, nil] Amount of memory in GiB to allocate
|
|
12
|
+
attr_reader :memory
|
|
13
|
+
|
|
14
|
+
# @return [Integer, nil] Amount of disk space in GiB to allocate
|
|
15
|
+
attr_reader :disk
|
|
16
|
+
|
|
17
|
+
# @return [Integer, nil] Number of GPUs to allocate
|
|
18
|
+
attr_reader :gpu
|
|
19
|
+
|
|
20
|
+
# @return [String, Array<String>, nil] Preferred GPU type for the Sandbox
|
|
21
|
+
attr_reader :gpu_type
|
|
22
|
+
|
|
23
|
+
# @param cpu [Integer, nil] Number of CPU cores to allocate
|
|
24
|
+
# @param memory [Integer, nil] Amount of memory in GiB to allocate
|
|
25
|
+
# @param disk [Integer, nil] Amount of disk space in GiB to allocate
|
|
26
|
+
# @param gpu [Integer, nil] Number of GPUs to allocate
|
|
27
|
+
# @param gpu_type [String, Array<String>, nil] Preferred GPU type for the Sandbox
|
|
28
|
+
def initialize(cpu: nil, memory: nil, disk: nil, gpu: nil, gpu_type: nil)
|
|
29
|
+
@cpu = cpu
|
|
30
|
+
@memory = memory
|
|
31
|
+
@disk = disk
|
|
32
|
+
@gpu = gpu
|
|
33
|
+
@gpu_type = gpu_type
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @return [Hash] Hash representation of the resources
|
|
37
|
+
def to_h = { cpu:, memory:, disk:, gpu:, gpu_type: }.compact
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Copyright Daytona Platforms Inc.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module Nightona
|
|
7
|
+
# Re-export of api-client enum constants under the Nightona namespace so
|
|
8
|
+
# SDK consumers never need to import from NightonaApiClient directly.
|
|
9
|
+
SandboxClass = NightonaApiClient::SandboxClass
|
|
10
|
+
SandboxState = NightonaApiClient::SandboxState
|
|
11
|
+
SandboxListSortField = NightonaApiClient::SandboxListSortField
|
|
12
|
+
SandboxListSortDirection = NightonaApiClient::SandboxListSortDirection
|
|
13
|
+
GpuType = NightonaApiClient::GpuType
|
|
14
|
+
|
|
15
|
+
class PaginatedResource
|
|
16
|
+
# @return [Array<Object>]
|
|
17
|
+
attr_reader :items
|
|
18
|
+
|
|
19
|
+
# @return [Float]
|
|
20
|
+
attr_reader :page
|
|
21
|
+
|
|
22
|
+
# @return [Float]
|
|
23
|
+
attr_reader :total
|
|
24
|
+
|
|
25
|
+
# @return [Float]
|
|
26
|
+
attr_reader :total_pages
|
|
27
|
+
|
|
28
|
+
# @param items [Nightona::Sandbox]
|
|
29
|
+
# @param page [Float]
|
|
30
|
+
# @param total [Float]
|
|
31
|
+
# @param total_pages [Float]
|
|
32
|
+
def initialize(items:, page:, total:, total_pages:)
|
|
33
|
+
@items = items
|
|
34
|
+
@page = page
|
|
35
|
+
@total = total
|
|
36
|
+
@total_pages = total_pages
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Query parameters for filtering and sorting when listing Sandboxes.
|
|
41
|
+
#
|
|
42
|
+
# All fields are optional and default to +nil+. Constructed via keyword
|
|
43
|
+
# arguments and immutable (Ruby 3.2+ Data semantics).
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# query = Nightona::ListSandboxesQuery.new(labels: { 'env' => 'prod' }, limit: 10)
|
|
47
|
+
# nightona.list(query).each { |sandbox| puts sandbox.id }
|
|
48
|
+
ListSandboxesQuery = Data.define(
|
|
49
|
+
:limit,
|
|
50
|
+
:id,
|
|
51
|
+
:name,
|
|
52
|
+
:labels,
|
|
53
|
+
:states,
|
|
54
|
+
:snapshots,
|
|
55
|
+
:targets,
|
|
56
|
+
:min_cpu,
|
|
57
|
+
:max_cpu,
|
|
58
|
+
:min_memory_gib,
|
|
59
|
+
:max_memory_gib,
|
|
60
|
+
:min_disk_gib,
|
|
61
|
+
:max_disk_gib,
|
|
62
|
+
:is_public,
|
|
63
|
+
:is_recoverable,
|
|
64
|
+
:created_at_after,
|
|
65
|
+
:created_at_before,
|
|
66
|
+
:last_activity_after,
|
|
67
|
+
:last_activity_before,
|
|
68
|
+
:sort,
|
|
69
|
+
:order
|
|
70
|
+
) do
|
|
71
|
+
# All members default to nil so callers pass only the filters they care about.
|
|
72
|
+
DEFAULTS = members.to_h { |m| [m, nil] }.freeze
|
|
73
|
+
|
|
74
|
+
class << self
|
|
75
|
+
alias_method :_data_new, :new
|
|
76
|
+
def new(**attrs) = _data_new(**DEFAULTS, **attrs)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Idiomatic Ruby boolean predicate aliases.
|
|
80
|
+
def public? = is_public
|
|
81
|
+
def recoverable? = is_recoverable
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Copyright Daytona Platforms Inc.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module Nightona
|
|
7
|
+
class CreateSnapshotParams
|
|
8
|
+
# @return [String] Name of the snapshot
|
|
9
|
+
attr_reader :name
|
|
10
|
+
|
|
11
|
+
# @return [String, Nightona::Image] Image of the snapshot. If a string is provided,
|
|
12
|
+
# it should be available on some registry. If an Image instance is provided,
|
|
13
|
+
# it will be used to create a new image in Nightona.
|
|
14
|
+
attr_reader :image
|
|
15
|
+
|
|
16
|
+
# @return [Nightona::Resources, nil] Resources of the snapshot
|
|
17
|
+
attr_reader :resources
|
|
18
|
+
|
|
19
|
+
# @return [Array<String>, nil] Entrypoint of the snapshot
|
|
20
|
+
attr_reader :entrypoint
|
|
21
|
+
|
|
22
|
+
# @return [String, nil] ID of the region where the snapshot will be available.
|
|
23
|
+
# Defaults to organization default region if not specified.
|
|
24
|
+
attr_reader :region_id
|
|
25
|
+
|
|
26
|
+
# @return [NightonaApiClient::SandboxClass, nil] Target sandbox class.
|
|
27
|
+
attr_reader :sandbox_class
|
|
28
|
+
|
|
29
|
+
# @param name [String] Name of the snapshot
|
|
30
|
+
# @param image [String, Nightona::Image] Image of the snapshot
|
|
31
|
+
# @param resources [Nightona::Resources, nil] Resources of the snapshot
|
|
32
|
+
# @param entrypoint [Array<String>, nil] Entrypoint of the snapshot
|
|
33
|
+
# @param region_id [String, nil] ID of the region where the snapshot will be available
|
|
34
|
+
# @param sandbox_class [NightonaApiClient::SandboxClass, nil] Target sandbox class
|
|
35
|
+
def initialize(name:, image:, resources: nil, entrypoint: nil, region_id: nil, sandbox_class: nil)
|
|
36
|
+
@name = name
|
|
37
|
+
@image = image
|
|
38
|
+
@resources = resources
|
|
39
|
+
@entrypoint = entrypoint
|
|
40
|
+
@region_id = region_id
|
|
41
|
+
@sandbox_class = sandbox_class
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class Snapshot
|
|
46
|
+
# @return [String] Unique identifier for the Snapshot
|
|
47
|
+
attr_reader :id
|
|
48
|
+
|
|
49
|
+
# @return [String, nil] Organization ID of the Snapshot
|
|
50
|
+
attr_reader :organization_id
|
|
51
|
+
|
|
52
|
+
# @return [Boolean, nil] Whether the Snapshot is general
|
|
53
|
+
attr_reader :general
|
|
54
|
+
|
|
55
|
+
# @return [String] Name of the Snapshot
|
|
56
|
+
attr_reader :name
|
|
57
|
+
|
|
58
|
+
# @return [String] Name of the Image of the Snapshot
|
|
59
|
+
attr_reader :image_name
|
|
60
|
+
|
|
61
|
+
# @return [String] State of the Snapshot
|
|
62
|
+
attr_reader :state
|
|
63
|
+
|
|
64
|
+
# @return [Float, nil] Size of the Snapshot
|
|
65
|
+
attr_reader :size
|
|
66
|
+
|
|
67
|
+
# @return [Array<String>, nil] Entrypoint of the Snapshot
|
|
68
|
+
attr_reader :entrypoint
|
|
69
|
+
|
|
70
|
+
# @return [Float] CPU of the Snapshot
|
|
71
|
+
attr_reader :cpu
|
|
72
|
+
|
|
73
|
+
# @return [Float] GPU of the Snapshot
|
|
74
|
+
attr_reader :gpu
|
|
75
|
+
|
|
76
|
+
# @return [Float] Memory of the Snapshot in GiB
|
|
77
|
+
attr_reader :mem
|
|
78
|
+
|
|
79
|
+
# @return [Float] Disk of the Snapshot in GiB
|
|
80
|
+
attr_reader :disk
|
|
81
|
+
|
|
82
|
+
# @return [String, nil] Error reason of the Snapshot
|
|
83
|
+
attr_reader :error_reason
|
|
84
|
+
|
|
85
|
+
# @return [String] Timestamp when the Snapshot was created
|
|
86
|
+
attr_reader :created_at
|
|
87
|
+
|
|
88
|
+
# @return [String] Timestamp when the Snapshot was last updated
|
|
89
|
+
attr_reader :updated_at
|
|
90
|
+
|
|
91
|
+
# @return [String, nil] Timestamp when the Snapshot was last used
|
|
92
|
+
attr_reader :last_used_at
|
|
93
|
+
|
|
94
|
+
# @return [NightonaApiClient::BuildInfo, nil] Build information for the snapshot
|
|
95
|
+
attr_reader :build_info
|
|
96
|
+
|
|
97
|
+
# @param snapshot_dto [NightonaApiClient::SnapshotDto] The snapshot DTO from the API
|
|
98
|
+
def initialize(snapshot_dto) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
99
|
+
@id = snapshot_dto.id
|
|
100
|
+
@organization_id = snapshot_dto.organization_id
|
|
101
|
+
@general = snapshot_dto.general
|
|
102
|
+
@name = snapshot_dto.name
|
|
103
|
+
@image_name = snapshot_dto.image_name
|
|
104
|
+
@state = snapshot_dto.state
|
|
105
|
+
@size = snapshot_dto.size
|
|
106
|
+
@entrypoint = snapshot_dto.entrypoint
|
|
107
|
+
@cpu = snapshot_dto.cpu
|
|
108
|
+
@gpu = snapshot_dto.gpu
|
|
109
|
+
@mem = snapshot_dto.mem
|
|
110
|
+
@disk = snapshot_dto.disk
|
|
111
|
+
@error_reason = snapshot_dto.error_reason
|
|
112
|
+
@created_at = snapshot_dto.created_at
|
|
113
|
+
@updated_at = snapshot_dto.updated_at
|
|
114
|
+
@last_used_at = snapshot_dto.last_used_at
|
|
115
|
+
@build_info = snapshot_dto.build_info
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Creates a Snapshot instance from a SnapshotDto
|
|
119
|
+
#
|
|
120
|
+
# @param dto [NightonaApiClient::SnapshotDto] The snapshot DTO from the API
|
|
121
|
+
# @return [Nightona::Snapshot] The snapshot instance
|
|
122
|
+
def self.from_dto(dto) = new(dto)
|
|
123
|
+
end
|
|
124
|
+
end
|