Sha256: 156ed2c724d1af815fd1d0a1101c39b328c27a3831fef5cd2a14a82ff1a0b4e7

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

# class represents a Docker Volume
class Docker::Volume
  include Docker::Base

  # /volumes/volume_name doesnt return anything
  def remove(opts = {}, conn = Docker.connection)
    conn.delete("/volumes/#{id}")
  end

  def normalize_hash(hash)
    hash['id'] ||= hash['Name']
  end

  class << self

    # get details for a single volume
    def get(name, conn = Docker.connection)
      resp = conn.get("/volumes/#{name}")
      hash = Docker::Util.parse_json(resp) || {}
      new(conn, hash)
    end

    # /volumes endpoint returns an array of hashes incapsulated in an Volumes tag
    def all(opts = {}, conn = Docker.connection)
      resp = conn.get('/volumes')
      json = Docker::Util.parse_json(resp) || {}
      hashes = json['Volumes'] || []
      hashes.map { |hash| new(conn, hash) }
    end

    # creates a volume with an arbitrary name
    def create(name, conn = Docker.connection)
      query = {}
      query['name'] = name if name
      resp = conn.post('/volumes/create', query, :body => query.to_json)
      hash = Docker::Util.parse_json(resp) || {}
      new(conn, hash)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
docker-api-1.31.0 lib/docker/volume.rb
docker-api-1.30.2 lib/docker/volume.rb
docker-api-1.30.1 lib/docker/volume.rb
docker-api-1.30.0 lib/docker/volume.rb
docker-api-1.29.2 lib/docker/volume.rb
docker-api-1.29.1 lib/docker/volume.rb
docker-api-1.29.0 lib/docker/volume.rb
docker-api-1.28.0 lib/docker/volume.rb
docker-api-1.27.0 lib/docker/volume.rb