Module: ConfigOpenApi

Included in:
CdnetworksClient
Defined in:
lib/cdnetworks-client/config_open_api.rb

Instance Method Summary collapse

Instance Method Details

#add(options = {}) ⇒ Object



15
16
17
# File 'lib/cdnetworks-client/config_open_api.rb', line 15

def add(options={})
  call(config_open_path("add"),add_config_credentials(options))
end

#add_config_credentials(options) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cdnetworks-client/config_open_api.rb', line 31

def add_config_credentials(options)
  if location == "Beta"
    session_token = get_session_token
    keys = get_api_key_list(session_token)
    api_key = keys.find{|k| k["type"] == 0}["apiKey"]

    options[:sessionToken] = session_token
    options[:apiKey] = api_key
  else
    options[:user]     = @user
    options[:pass] = @password
  end

  options
end

#config_open_path(command) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/cdnetworks-client/config_open_api.rb', line 23

def config_open_path(command)
  if location == "Beta"
    "/api/rest/pan/site/#{command}"
  else
    "/config/rest/pan/site/#{command}"
  end
end

#edit(options = {}) ⇒ Object



19
20
21
# File 'lib/cdnetworks-client/config_open_api.rb', line 19

def edit(options={})
  call(config_open_path("edit"),add_config_credentials(options))
end

#list(options = {}) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/cdnetworks-client/config_open_api.rb', line 2

def list(options={})
  response = call(config_open_path("list"), add_config_credentials(options))
  if location == "Beta"
    response[:body]["PadConfigResponse"]["data"]["data"]
  else
    response
  end
end

#view(options = {}) ⇒ Object



11
12
13
# File 'lib/cdnetworks-client/config_open_api.rb', line 11

def view(options={})
  call(config_open_path("view"),add_config_credentials(options))
end