Sha256: 81f5af58adbff794bd4a68e30232a6ae36cf750575c9579e4ed8409018faa0a1

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require 'netscaler/netscaler_service'

module Netscaler
  class Lb
    class Vserver < NetscalerService
      def initialize(netscaler)
        @netscaler=netscaler
      end

      def show(payload={})
        if payload[:name] != nil then
          validate_payload(payload, [:name])
          return @netscaler.adapter.get("config/lbvserver/#{payload[:name]}")
        elsif payload == {} then
          return @netscaler.adapter.get('config/lbvserver/')
        else
          raise ArgumentError, 'payload supplied must have been missing :name'
        end
      end

      def show_binding(payload)
        raise ArgumentError, 'payload cannot be null' if payload.nil?
        payload = Netscaler.hash_hack(payload)
        validate_payload(payload, [:name])
        return @netscaler.adapter.get("config/lbvserver_binding/#{payload[:name]}")
      end

      def remove(payload) # :args: :name
        raise ArgumentError, 'payload cannot be null' if payload.nil?
        payload = Netscaler.hash_hack(payload)
        validate_payload(payload, [:name])
        return @netscaler.adapter.delete("config/lbvserver/#{payload[:name]}")
      end

      def add(payload)
        raise ArgumentError, 'payload cannot be null' if payload.nil?
        payload = Netscaler.hash_hack(payload)
        validate_payload(payload, [:name, :serviceType, :ipv46, :port])
        return @netscaler.adapter.post_no_body('config/lbvserver/', {'lbvserver' => payload})
      end

      def bind
        Bind.new @netscaler
      end

      def unbind
        Unbind.new @netscaler
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netscaler-0.3.1 lib/netscaler/lb/vserver.rb
netscaler-0.3.0 lib/netscaler/lb/vserver.rb