Class: Daytona::CreateSandboxBaseParams

Inherits:
Object
  • Object
show all
Defined in:
lib/daytona/common/daytona.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(language: nil, os_user: nil, env_vars: nil, labels: nil, public: nil, timeout: nil, auto_stop_interval: nil, auto_archive_interval: nil, auto_delete_interval: nil, volumes: nil, secrets: nil, network_block_all: nil, network_allow_list: nil, domain_allow_list: nil, ephemeral: nil, linked_sandbox: nil) ⇒ CreateSandboxBaseParams

Initialize CreateSandboxBaseParams

Parameters:

  • language (Symbol, nil) (defaults to: nil)

    Programming language for the Sandbox

  • os_user (String, nil) (defaults to: nil)

    OS user for the Sandbox

  • env_vars (Hash<String, String>, nil) (defaults to: nil)

    Environment variables to set in the Sandbox

  • labels (Hash<String, String>, nil) (defaults to: nil)

    Custom labels for the Sandbox

  • public (Boolean, nil) (defaults to: nil)

    Whether the Sandbox should be public

  • timeout (Float, nil) (defaults to: nil)

    Timeout in seconds for Sandbox to be created and started

  • auto_stop_interval (Integer, nil) (defaults to: nil)

    Auto-stop interval in minutes

  • auto_archive_interval (Integer, nil) (defaults to: nil)

    Auto-archive interval in minutes

  • auto_delete_interval (Integer, nil) (defaults to: nil)

    Auto-delete interval in minutes

  • volumes (Array<DaytonaApiClient::SandboxVolume>, nil) (defaults to: nil)

    List of volumes mounts to attach to the Sandbox

  • secrets (Hash<String, String>, nil) (defaults to: nil)

    Organization Secrets to expose in the Sandbox, as a mapping of env var name to existing Secret name

  • network_block_all (Boolean, nil) (defaults to: nil)

    Whether to block all network access for the Sandbox

  • network_allow_list (String, nil) (defaults to: nil)

    Comma-separated list of allowed CIDR network addresses for the Sandbox

  • domain_allow_list (String, nil) (defaults to: nil)

    Comma-separated list of allowed domains for the Sandbox

  • ephemeral (Boolean, nil) (defaults to: nil)

    Whether the Sandbox should be ephemeral

  • linked_sandbox (String, nil) (defaults to: nil)

    ID or name of an existing Sandbox to link the new Sandbox to



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
# File 'lib/daytona/common/daytona.rb', line 82

def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
  language: nil,
  os_user: nil,
  env_vars: nil,
  labels: nil,
  public: nil,
  timeout: nil,
  auto_stop_interval: nil,
  auto_archive_interval: nil,
  auto_delete_interval: nil,
  volumes: nil,
  secrets: nil,
  network_block_all: nil,
  network_allow_list: nil,
  domain_allow_list: nil,
  ephemeral: nil,
  linked_sandbox: nil
)
  @language = language
  @os_user = os_user
  @env_vars = env_vars
  @labels = labels
  @public = public
  @timeout = timeout
  @auto_stop_interval = auto_stop_interval
  @auto_archive_interval = auto_archive_interval
  @auto_delete_interval = auto_delete_interval
  @volumes = volumes
  @secrets = secrets
  @network_block_all = network_block_all
  @network_allow_list = network_allow_list
  @domain_allow_list = domain_allow_list
  @ephemeral = ephemeral
  @linked_sandbox = linked_sandbox

  # Handle ephemeral and auto_delete_interval conflict
  handle_ephemeral_auto_delete_conflict
end

Instance Attribute Details

#auto_archive_intervalInteger?

Returns Auto-archive interval in minutes.

Returns:

  • (Integer, nil)

    Auto-archive interval in minutes



32
33
34
# File 'lib/daytona/common/daytona.rb', line 32

def auto_archive_interval
  @auto_archive_interval
end

#auto_delete_intervalInteger?

Returns Auto-delete interval in minutes.

Returns:

  • (Integer, nil)

    Auto-delete interval in minutes



35
36
37
# File 'lib/daytona/common/daytona.rb', line 35

def auto_delete_interval
  @auto_delete_interval
end

#auto_stop_intervalInteger?

Returns Auto-stop interval in minutes.

Returns:

  • (Integer, nil)

    Auto-stop interval in minutes



29
30
31
# File 'lib/daytona/common/daytona.rb', line 29

def auto_stop_interval
  @auto_stop_interval
end

#domain_allow_listString?

Returns Comma-separated list of allowed domains for the Sandbox.

Returns:

  • (String, nil)

    Comma-separated list of allowed domains for the Sandbox



52
53
54
# File 'lib/daytona/common/daytona.rb', line 52

def domain_allow_list
  @domain_allow_list
end

#env_varsHash<String, String>?

Returns Environment variables to set in the Sandbox.

Returns:

  • (Hash<String, String>, nil)

    Environment variables to set in the Sandbox



17
18
19
# File 'lib/daytona/common/daytona.rb', line 17

def env_vars
  @env_vars
end

#ephemeralBoolean?

Returns Whether the Sandbox should be ephemeral.

Returns:

  • (Boolean, nil)

    Whether the Sandbox should be ephemeral



55
56
57
# File 'lib/daytona/common/daytona.rb', line 55

def ephemeral
  @ephemeral
end

#labelsHash<String, String>?

Returns Custom labels for the Sandbox.

Returns:

  • (Hash<String, String>, nil)

    Custom labels for the Sandbox



20
21
22
# File 'lib/daytona/common/daytona.rb', line 20

def labels
  @labels
end

#languageSymbol?

Returns Programming language for the Sandbox.

Returns:

  • (Symbol, nil)

    Programming language for the Sandbox



11
12
13
# File 'lib/daytona/common/daytona.rb', line 11

def language
  @language
end

#linked_sandboxString?

Returns ID or name of an existing Sandbox to link the new Sandbox to. The new Sandbox will be scheduled on the same runner as the linked Sandbox so a local network can be established between them. Linked Sandboxes must be ephemeral (auto_delete_interval=0) and cannot themselves be linked to another Sandbox.

Returns:

  • (String, nil)

    ID or name of an existing Sandbox to link the new Sandbox to. The new Sandbox will be scheduled on the same runner as the linked Sandbox so a local network can be established between them. Linked Sandboxes must be ephemeral (auto_delete_interval=0) and cannot themselves be linked to another Sandbox.



61
62
63
# File 'lib/daytona/common/daytona.rb', line 61

def linked_sandbox
  @linked_sandbox
end

#network_allow_listString?

Returns Comma-separated list of allowed CIDR network addresses for the Sandbox.

Returns:

  • (String, nil)

    Comma-separated list of allowed CIDR network addresses for the Sandbox



49
50
51
# File 'lib/daytona/common/daytona.rb', line 49

def network_allow_list
  @network_allow_list
end

#network_block_allBoolean?

Returns Whether to block all network access for the Sandbox.

Returns:

  • (Boolean, nil)

    Whether to block all network access for the Sandbox



46
47
48
# File 'lib/daytona/common/daytona.rb', line 46

def network_block_all
  @network_block_all
end

#os_userString?

Returns OS user for the Sandbox.

Returns:

  • (String, nil)

    OS user for the Sandbox



14
15
16
# File 'lib/daytona/common/daytona.rb', line 14

def os_user
  @os_user
end

#publicBoolean?

Returns Whether the Sandbox should be public.

Returns:

  • (Boolean, nil)

    Whether the Sandbox should be public



23
24
25
# File 'lib/daytona/common/daytona.rb', line 23

def public
  @public
end

#secretsHash<String, String>?

Returns Organization Secrets to expose in the Sandbox, as a mapping of env var name to existing Secret name. The injected env var holds an opaque placeholder that is resolved to the real value only for the Secret’s allowed hosts.

Returns:

  • (Hash<String, String>, nil)

    Organization Secrets to expose in the Sandbox, as a mapping of env var name to existing Secret name. The injected env var holds an opaque placeholder that is resolved to the real value only for the Secret’s allowed hosts.



43
44
45
# File 'lib/daytona/common/daytona.rb', line 43

def secrets
  @secrets
end

#timeoutFloat?

Returns Timeout in seconds for Sandbox to be created and started.

Returns:

  • (Float, nil)

    Timeout in seconds for Sandbox to be created and started



26
27
28
# File 'lib/daytona/common/daytona.rb', line 26

def timeout
  @timeout
end

#volumesArray<DaytonaApiClient::SandboxVolume>?

Returns List of volumes mounts to attach to the Sandbox.

Returns:

  • (Array<DaytonaApiClient::SandboxVolume>, nil)

    List of volumes mounts to attach to the Sandbox



38
39
40
# File 'lib/daytona/common/daytona.rb', line 38

def volumes
  @volumes
end

Instance Method Details

#to_hHash<Symbol, Object>

Convert to hash representation

Returns:

  • (Hash<Symbol, Object>)

    Hash representation of the parameters



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/daytona/common/daytona.rb', line 124

def to_h # rubocop:disable Metrics/MethodLength
  {
    language:,
    os_user:,
    env_vars:,
    labels:,
    public:,
    timeout:,
    auto_stop_interval:,
    auto_archive_interval:,
    auto_delete_interval:,
    volumes:,
    secrets:,
    network_block_all:,
    network_allow_list:,
    domain_allow_list:,
    ephemeral:,
    linked_sandbox:
  }.compact
end