Class: Netscaler::ServiceGroup

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

Instance Method Summary collapse

Methods inherited from NetscalerService

#validate_payload

Constructor Details

#initialize(netscaler) ⇒ ServiceGroup

Returns a new instance of ServiceGroup.



5
6
7
# File 'lib/netscaler/servicegroup.rb', line 5

def initialize(netscaler)
  @netscaler=netscaler
end

Instance Method Details

#add(payload) ⇒ Object

:args: :serviceGroupName => ‘foo’, :serviceType => ‘HTTP’

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/netscaler/servicegroup.rb', line 9

def add(payload)  # :args: :serviceGroupName => 'foo', :serviceType => 'HTTP'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:serviceGroupName, :serviceType])
  return @netscaler.adapter.post_no_body("config/servicegroup/", "servicegroup" => payload)
end

#bind(payload) ⇒ Object

:args: :serviceGroupName => ‘foo’, :port => ‘80’, :serverName => ‘bar’

Raises:

  • (ArgumentError)


62
63
64
65
66
# File 'lib/netscaler/servicegroup.rb', line 62

def bind(payload) # :args:  :serviceGroupName => 'foo', :port => '80', :serverName => 'bar'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:serviceGroupName, :port, :serverName])
  return @netscaler.adapter.post_no_body("config/servicegroup_servicegroupmember_binding/#{payload['serviceGroupName']}?action=bind", {'params' => {'action' => 'bind'}, 'servicegroup_servicegroupmember_binding' => payload})
end

#disable(payload) ⇒ Object

:arg: service_group



32
33
34
# File 'lib/netscaler/servicegroup.rb', line 32

def disable(payload) # :arg: service_group
  toggle('disable', payload)
end

#disable_server(payload) ⇒ Object

:arg: service_group, servername, port

Raises:

  • (ArgumentError)


47
48
49
50
51
52
53
54
55
56
# File 'lib/netscaler/servicegroup.rb', line 47

def disable_server(payload) # :arg: service_group, servername, port
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:serviceGroupName, :serverName, :port])
  return @netscaler.adapter.post('config/', {"params" =>
                                                 {"action" => "disable"},
                                             "servicegroup" =>
                                                 {"servicegroupname" => payload[:serviceGroupName],
                                                  "serverName" => payload[:serverName],
                                                  "port" => payload[:port] }})
end

#enable(payload) ⇒ Object

:arg: service_group



28
29
30
# File 'lib/netscaler/servicegroup.rb', line 28

def enable(payload) # :arg: service_group
  toggle('enable', payload)
end

#enable_server(payload) ⇒ Object

:arg: service_group, serverName, port

Raises:

  • (ArgumentError)


36
37
38
39
40
41
42
43
44
45
# File 'lib/netscaler/servicegroup.rb', line 36

def enable_server(payload) # :arg: service_group, serverName, port
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:serviceGroupName, :serverName, :port])
  return @netscaler.adapter.post('config/', {"params" =>
                                                 {"action" => "enable"},
                                             "servicegroup" =>
                                                 {"servicegroupname" => payload[:serviceGroupName],
                                                  "serverName" => payload[:serverName],
                                                  "port" => payload[:port] }})
end

#remove(payload) ⇒ Object

:arg: serviceGroupName

Raises:

  • (ArgumentError)


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

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

#show(payload = {}) ⇒ Object

argument is optional, if left empty it will return all servicegroups



23
24
25
26
# File 'lib/netscaler/servicegroup.rb', line 23

def show(payload={}) # :arg: servicegroupname
  @netscaler.adapter.get("config/servicegroup/") if payload.empty?
  @netscaler.adapter.get("config/servicegroup/#{payload}")
end

#show_bindings(payload) ⇒ Object

:args: servicegroupname



58
59
60
# File 'lib/netscaler/servicegroup.rb', line 58

def show_bindings(payload)  # :args: servicegroupname
  return @netscaler.adapter.get("config/servicegroup_servicegroupmember_binding/#{payload}")
end

#stat(payload = {}) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# File 'lib/netscaler/servicegroup.rb', line 74

def stat(payload={})
  if payload[:name] != nil then
    validate_payload(payload, [:name])
    @netscaler.adapter.get("stat/servicegroup/#{payload[:name]}")
  elsif payload == {} then
    @netscaler.adapter.get('stat/servicegroup')
  else
    raise ArgumentError, 'payload cannot be null' if payload.nil?
  end
end

#unbind(payload) ⇒ Object

:args: :serviceGroupName => ‘foo’, :port => ‘80’, :serverName => ‘bar’

Raises:

  • (ArgumentError)


68
69
70
71
72
# File 'lib/netscaler/servicegroup.rb', line 68

def unbind(payload) # :args:  :serviceGroupName => 'foo', :port => '80', :serverName => 'bar'
  raise ArgumentError, 'payload cannot be null' if payload.nil?
  validate_payload(payload, [:serviceGroupName, :port, :serverName])
  return @netscaler.adapter.post_no_body("config/servicegroup_servicegroupmember_binding/#{payload['serviceGroupName']}?action=unbind", {'params' => {'action' => 'unbind'}, 'servicegroup_servicegroupmember_binding' => payload})
end