Class: Daytona::VolumeService
- Inherits:
-
Object
- Object
- Daytona::VolumeService
- Defined in:
- lib/daytona/volume_service.rb
Instance Method Summary collapse
-
#create(name) ⇒ Daytona::Volume
Create new Volume.
-
#delete(volume) ⇒ void
Delete a Volume.
-
#get(name, create: false) ⇒ Daytona::Volume
Get a Volume by name.
-
#initialize(volumes_api) ⇒ VolumeService
constructor
Service for managing Daytona Volumes.
-
#list ⇒ Array<Daytona::Volume>
List all Volumes.
Constructor Details
#initialize(volumes_api) ⇒ VolumeService
Service for managing Daytona Volumes. Can be used to list, get, create and delete Volumes.
8 9 10 |
# File 'lib/daytona/volume_service.rb', line 8 def initialize(volumes_api) @volumes_api = volumes_api end |
Instance Method Details
#create(name) ⇒ Daytona::Volume
Create new Volume.
16 |
# File 'lib/daytona/volume_service.rb', line 16 def create(name) = Volume.new(volumes_api.create_volume(DaytonaApiClient::CreateVolume.new(name:))) |
#delete(volume) ⇒ void
This method returns an undefined value.
Delete a Volume.
22 |
# File 'lib/daytona/volume_service.rb', line 22 def delete(volume) = volumes_api.delete_volume(volume.id) |
#get(name, create: false) ⇒ Daytona::Volume
Get a Volume by name.
29 30 31 32 33 34 35 |
# File 'lib/daytona/volume_service.rb', line 29 def get(name, create: false) Volume.new(volumes_api.get_volume_by_name(name)) rescue DaytonaApiClient::ApiError => e raise unless create && e.code == 404 && e..include?("Volume with name #{name} not found") create(name) end |
#list ⇒ Array<Daytona::Volume>
List all Volumes.
40 41 42 |
# File 'lib/daytona/volume_service.rb', line 40 def list volumes_api.list_volumes.map { |volume| Volume.new(volume) } end |