Class: Netscaler::Service

Inherits:
NetscalerService show all
Defined in:
lib/netscaler/service.rb

Overview

Netscaler::Service handles all service entity calls. This includes #add, #enable, #disable and #show

Instance Method Summary collapse

Methods inherited from NetscalerService

#validate_payload

Constructor Details

#initialize(netscaler) ⇒ Service

Returns a new instance of Service.



8
9
10
# File 'lib/netscaler/service.rb', line 8

def initialize(netscaler)
  @netscaler=netscaler
end

Instance Method Details

#add(payload) ⇒ Object

This method require you already have a server created using Netscaler::Server#add or if it is already configured on the netscaler.

Raises:

  • (ArgumentError)


15
16
17
18
19
# File 'lib/netscaler/service.rb', line 15

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

#disable(payload) ⇒ Object

:args: :name => ‘foo’

Raises:

  • (ArgumentError)


47
48
49
50
51
# File 'lib/netscaler/service.rb', line 47

def disable(payload) # :args:  :name => 'foo'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:name])
  return @netscaler.adapter.post_no_body('config/service/', {'params' => {'action' => 'disable'}, 'service' => payload})
end

#enable(payload) ⇒ Object

:args: :name => ‘foo’

Raises:

  • (ArgumentError)


41
42
43
44
45
# File 'lib/netscaler/service.rb', line 41

def enable(payload) # :args:  :name => 'foo'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:name])
  return @netscaler.adapter.post_no_body('config/service/', {'params' => {'action' => 'enable'}, 'service' => payload})
end

#remove(payload) ⇒ Object

:args: :server

Raises:

  • (ArgumentError)


21
22
23
24
25
# File 'lib/netscaler/service.rb', line 21

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

#show(payload = {}) ⇒ Object

:serverName is optional, if omitted it will return all services configured on the Netscaler.



30
31
32
33
34
35
36
37
38
39
# File 'lib/netscaler/service.rb', line 30

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

#show_binding(payload) ⇒ Object

Raises:

  • (ArgumentError)


53
54
55
56
57
# File 'lib/netscaler/service.rb', line 53

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

#stat(payload = {}) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/netscaler/service.rb', line 59

def stat(payload={})
  if payload[:name] != nil then
    validate_payload(payload, [:name])
    @netscaler.adapter.get("stat/service/#{payload[:name]}")
  else
    @netscaler.adapter.get('stat/service')
  end
end