Sha256: 0cb893477afa4baf28cee1c779468ba4b3d06f91bae8523472cad6eac78fa490

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

module Hcloud
  class Server
    Attributes = {
      id: nil,
      name: nil,
      status: nil,
      created: :time,
      public_net: nil,
      server_type: ServerType,
      datacenter: Datacenter,
      image: Image,
      iso: nil,
      rescue_enabled: nil,
      locked: nil,
      backup_window: nil,
      outgoing_traffic: nil,
      ingoing_traffic: nil,
      included_traffic: nil
    }

    include EntryLoader

    def update(name:) 
      Server.new(
        Oj.load(request(base_path, j: {name: name}, method: :put).run.body)["server"],
        parent,
        client
      )
    end

    def destroy
      Action.new(
        Oj.load(request(base_path, method: :delete).run.body)["action"],
        parent,
        client
      )
    end

    private

    def base_path
      return "servers/#{id}" unless id.nil?
      raise ResourcePathError, "Unable to build resource path. Id is nil." 
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hcloud-0.1.0.pre.alpha0 lib/hcloud/server.rb