vzcdn 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7308b4c03e37ceb4e8929e429f5ea3cdf4b5a879
4
- data.tar.gz: 76b3478d0d082d625bbd17e43aa0c86dfda8ee18
3
+ metadata.gz: e8cf5a8765894451f57b2419a20e69fbfa1187d8
4
+ data.tar.gz: 3100211e9da6d904a6592deabb9495bf4dcbcb6e
5
5
  SHA512:
6
- metadata.gz: 6b241986733b7fd7b4be2823a01269aaae95a6e161714783ceb8349ac084a8284dd1b0a0861739e4e3e61afa7278a88d3da230bcecca79df8d9122fb87ec1e3c
7
- data.tar.gz: 097f7f170f2a0bb6a41d6c838058c69c72522db5cd560ab42d1ee22a39c0a26f969653c250881db92901443d746f1aa0798b6285f66947ad149fc4232ce03cc9
6
+ metadata.gz: e9fece79699a66aa2478849826c711078a80029fda078f5a19dc04315435a6d42b98e1aeaaaedcb3e2040890ed57c4c55668319fa219c7edba480fe28bc0af06
7
+ data.tar.gz: 8c029ca1fd312e13784f001ca7b3c0ea73c19f0b305eae60e50eb66d9f33cfd6ccdcc7d6862f33e8d6747fcf563cc8ced7eb3bbd392a5bf1d07b153d5be5d421
data/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  Commandline UI for Edgecast API
4
4
 
5
5
  ##RELEASE NOTES
6
+ 2014/05/21 0.2.3
7
+ * Testcases added.
8
+
6
9
  2014/05/15 0.2.2
7
10
  * Bug fix: pull command would fail if zones directory does not exists.
8
11
 
@@ -0,0 +1,6 @@
1
+ --url:https://api.edgecast.com/v2/mcc/customers/BED3/dns/routezones,method:get
2
+ [{"DomainName":"mockzone.","Status":1,"Version":1400171377,"ZoneId":5385,"ZoneType":1},{"DomainName":"nitin.","Status":1,"Version":1400096702,"ZoneId":5284,"ZoneType":1},{"DomainName":"pythonzone.","Status":1,"Version":1400169998,"ZoneId":5366,"ZoneType":1},{"DomainName":"vdmstest.com.","Status":1,"Version":1398108874,"ZoneId":4980,"ZoneType":1}]
3
+ --url:https://api.edgecast.com/v2/mcc//dns/routezonestatus,method:get
4
+ [{"Id"=>1, "Name"=>"Active"}, {"Id"=>2, "Name"=>"Inactive"}]
5
+ --url:https://api.edgecast.com/v2/mcc//dns/routezonetypes,method:get
6
+ [{"Id"=>1, "Name"=>"CNAME"}, {"Id"=>2, "Name"=>"Subdomain"}, {"Id"=>3, "Name"=>"Zone"}]
@@ -1,7 +1,8 @@
1
- require 'rest_client'
2
1
  require 'json'
3
2
  require 'config_reader'
4
3
  require_relative 'proxy_credentials'
4
+ require_relative 'http_send'
5
+ require_relative 'mock_http_send'
5
6
 
6
7
  class CommonRestUtils
7
8
  include ConfigReader
@@ -9,51 +10,29 @@ class CommonRestUtils
9
10
  url = @uri_prefix + url_suffix
10
11
  if (body)
11
12
  json_body = JSON.pretty_generate body
13
+ else
14
+ json_body = nil
12
15
  end
13
16
  begin
14
- response =
15
- case http_method
16
- when :put
17
- RestClient.put(url, json_body, @headers)
18
- when :get
19
- RestClient.get(url, @headers)
20
- when :post
21
- RestClient.post(url, json_body, @headers)
22
- when :delete
23
- RestClient.delete(url, @headers)
24
- else
25
- "unsupported http method:" + http_method
26
- end
17
+ if ($mock_env)
18
+ code, response = MockHttpSend.new($mock_env).send(url, http_method, @headers, json_body)
19
+ else
20
+ code, response = HttpSend.new.send(url, http_method, @headers, json_body)
21
+ end
27
22
  rescue Exception => e
28
- puts "Problem executing REST command to server " + param("rest_base_url")
23
+ puts "Exception thrown by HttpSend.new.send(); should not occur"
29
24
  puts e.message
30
- puts "#{e.response}"
31
- proxy_auth_req = (e.message =~ /\A407 /)
32
- if e.message =~ /\A407 /
33
- ProxyCredentials.proxy_credentials param("proxy")
34
- if @proxy_retries && @proxy_retries > 3
35
- raise e.message + " too many retries"
36
- else
37
- @proxy_retries = @proxy_retries ? @proxy_retries + 1 : 1
38
- return callMethod(url_suffix, http_method, body)
39
- end
40
- end
41
- exit
42
- if $debug > 0
43
- puts "full URL is:" + url
44
- if (body)
45
- puts "body is: json_body"
46
- end
47
- end
48
- raise e.message + " (" + e.class.to_s + ")"
25
+ raise e.message + " (#{e.class})"
49
26
  end
50
- if ( ! response.nil? && response.respond_to?(:code) && response.code != 200)
51
- raise "Bad response code:" + response.code.to_s
52
- end
53
- if (response.length > 0)
54
- if $debug > 1
55
- File.open("raw.json", "w").write(response)
27
+ if code != 200
28
+ puts "Problem invoking REST method at server #{param "rest_base_url"}"
29
+ if code > 0
30
+ raise "Bad http response code: #{code} --- response:#{response}"
31
+ else
32
+ raise response
56
33
  end
34
+ end
35
+ if (response.length >= 2)
57
36
  JSON.parse response
58
37
  else
59
38
  nil
@@ -62,13 +41,9 @@ class CommonRestUtils
62
41
 
63
42
  def initialize(uri_prefix)
64
43
  @uri_prefix = uri_prefix
65
- proxy = param("proxy")
66
- if proxy != ""
67
- RestClient.proxy = proxy
68
- end
69
- @headers = {:Content_type => "Application/json",
70
- :Authorization => "TOK:" + param("token"),
71
- :Accept => "Application/json"}
44
+ @headers = {"Content-Type" => "Application/json",
45
+ "Authorization" => "TOK:" + param("token"),
46
+ "Accept" => "Application/json"}
72
47
  end
73
48
 
74
49
 
@@ -1,8 +1,12 @@
1
- require 'util'
1
+ require_relative 'util'
2
+ require_relative 'method'
2
3
 
3
4
  class ConfigHandler
4
5
  CONFIG_DIRECTORY = ".vdms.d"
5
6
  CONFIG_FILENAME = "config"
7
+ AUTHORS='SCP & NMK'
8
+ PASSWORD='Password'
9
+ @@config_values = nil
6
10
 
7
11
  def get_config_file
8
12
  if (! File.directory?(CONFIG_DIRECTORY))
@@ -26,13 +30,13 @@ class ConfigHandler
26
30
  new_file.puts(line)
27
31
  end
28
32
  }
29
- if ( ! wrote_line)
33
+ if ( ! wrote_line && ! value.nil?)
30
34
  new_file.puts(new_config_line)
31
35
  end
32
36
  end
33
37
 
34
38
  def load_config_values
35
- if defined? @@config_values
39
+ if @@config_values.class == Hash
36
40
  return
37
41
  else
38
42
  @@config_values = {}
@@ -46,6 +50,9 @@ class ConfigHandler
46
50
  end
47
51
  name, value = Util.parse_line(line)
48
52
  if value
53
+ if name.end_with? PASSWORD
54
+ value = Methodical.new(AUTHORS).backward value
55
+ end
49
56
  @@config_values[name] = value
50
57
  end
51
58
  }
@@ -65,6 +72,9 @@ class ConfigHandler
65
72
  end
66
73
 
67
74
  def set(name, value)
75
+ if value && name.end_with?(PASSWORD)
76
+ value = Methodical.new(AUTHORS).forward value
77
+ end
68
78
  config_file = get_config_file
69
79
  if ! File.exists? config_file
70
80
  # make empty file
@@ -78,6 +88,7 @@ class ConfigHandler
78
88
  orig_file.close
79
89
  FileUtils.rm(config_file, force: true)
80
90
  FileUtils.mv(new_config_file, config_file, :force => true)
91
+ @@config_values = nil
81
92
  end
82
93
 
83
94
  def delete(name)
@@ -0,0 +1,110 @@
1
+ require_relative 'proxy_credentials'
2
+ require 'net/http'
3
+
4
+ class HttpSend
5
+ include ConfigReader
6
+
7
+ def get_proxy_params
8
+ @proxy = param("proxy")
9
+ @proxy_username = param("proxy-Username")
10
+ @proxy_password = param("proxy-Password")
11
+ end
12
+
13
+ def initialize
14
+ get_proxy_params
15
+ end
16
+
17
+ def set_headers(request, headers)
18
+ headers.each { |name, value|
19
+ request[name.to_s] = value
20
+ }
21
+ end
22
+
23
+ def create_request(uri, method)
24
+ case method
25
+ when :put
26
+ request = Net::HTTP::Put.new(uri)
27
+ when :get
28
+ request = Net::HTTP::Get.new(uri)
29
+ when :post
30
+ request = Net::HTTP::Post.new(uri)
31
+ when :delete
32
+ request = Net::HTTP::Delete.new(uri)
33
+ end
34
+ end
35
+
36
+ def adjust(http, uri)
37
+ # http.set_debug_output $stderr
38
+ http.read_timeout = 60
39
+ http.open_timeout = 60
40
+ if uri.scheme == 'https'
41
+ http.use_ssl = true
42
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
43
+ end
44
+ end
45
+
46
+ def save_http(url, method, body, response_code, response_body)
47
+ if File.exists? $http_save_file
48
+ array = JSON.parse(File.open($http_save_file).read)
49
+ else
50
+ array = [ ]
51
+ end
52
+ o = Hash.new
53
+ o["url"] = url
54
+ o["method"] = method
55
+ o["body"] = body
56
+ o["response_code"] = response_code
57
+ o["response_body"] = response_body
58
+ array << o
59
+ file = File.open($http_save_file + ".tmp", "w")
60
+ file.write(JSON.pretty_generate(array))
61
+ file.close
62
+ FileUtils.mv($http_save_file + ".tmp", $http_save_file, :force => true)
63
+ end
64
+
65
+ def send(url, method, headers, body = nil)
66
+ uri = URI(url)
67
+ request = create_request(uri, method)
68
+ if body
69
+ request.body = body
70
+ end
71
+ set_headers(request, headers)
72
+ if @proxy
73
+ proxy_uri = URI(@proxy)
74
+ http = Net::HTTP.new(uri.host, uri.port, proxy_uri.hostname, proxy_uri.port, @proxy_username, @proxy_password)
75
+ else
76
+ http = Net::HTTP.new(uri.host, uri.port)
77
+ end
78
+ adjust(http, uri)
79
+ response_code = -1
80
+ response_body = nil
81
+ begin
82
+ response = http.request(request)
83
+ response_code = response.code.to_i
84
+ response_body = response.body
85
+ rescue Net::HTTPServerException => e
86
+ if e.message == '407 "Proxy Authentication Required"'
87
+ ProxyCredentials.proxy_credentials(@proxy)
88
+ get_proxy_params
89
+ return self.retry(url, method, headers, body)
90
+ else
91
+ response_body = "#{e.class} exception occurred:#{e.message}"
92
+ end
93
+ rescue Exception => e
94
+ response_body = "#{e.class} exception occurred:#{e.message}"
95
+ end
96
+ if defined? $http_save_file
97
+ save_http(url, method, body, response_code, response_body)
98
+ end
99
+ return response_code, response_body
100
+ end
101
+
102
+ def retry(url, method, headers, body)
103
+ if @proxy_retries && @proxy_retries > 1
104
+ raise "Proxy Authentication Failed"
105
+ else
106
+ @proxy_retries = @proxy_retries ? @proxy_retries + 1 : 1
107
+ send(url, method, headers, body)
108
+ end
109
+ end
110
+ end
@@ -1,5 +1,26 @@
1
- class Method
2
- def initialize(args)
3
-
1
+ require 'openssl'
2
+ require 'base64'
3
+
4
+ class Methodical
5
+ ALPHABET = 'abcdefghiklmnoprstuvwxyz'
6
+
7
+ def initialize(severence)
8
+ @severence = severence[0...8]
9
+ @runner = OpenSSL::Cipher::Cipher.new("des-ede3-cbc")
10
+ end
11
+
12
+ def forward(string)
13
+ @runner.encrypt
14
+ @runner.key = ALPHABET
15
+ @runner.iv = @severence
16
+ Base64.encode64(@severence + @runner.update(string) + @runner.final).gsub(/\n/, '')
17
+ end
18
+
19
+ def backward(string)
20
+ @runner.decrypt
21
+ @runner.key = ALPHABET
22
+ encrypted = Base64.decode64(string)
23
+ @runner.iv = encrypted.slice!(0,8)
24
+ @runner.update(encrypted) + @runner.final
4
25
  end
5
26
  end
@@ -0,0 +1,15 @@
1
+ class MockHttpSend
2
+ def initialize(mockfile)
3
+ @mock_results = JSON.parse(File.open(mockfile).read)
4
+ end
5
+
6
+ def send(url, method, headers=nil, body = nil)
7
+ @mock_results.each { |result|
8
+ if result["url"] == url && result["method"] == method.to_s
9
+ return result["response_code"], result["response_body"]
10
+ end
11
+ }
12
+ return -1, "unable to find match for #{url},#{method} in mock file"
13
+ end
14
+ end
15
+
@@ -3,6 +3,8 @@ require_relative 'util'
3
3
  require_relative 'config_reader'
4
4
 
5
5
  class TablePrint
6
+ include ConfigReader
7
+
6
8
  DELIM = '|'
7
9
 
8
10
  def char_repeat(n, char)
@@ -179,6 +181,9 @@ class TablePrint
179
181
  # will lines fit in terminal
180
182
  width_needed = maxwidth.reduce(:+) + (@ncols-1) * 2
181
183
  term_width, h = Util.detect_terminal_size
184
+ if param('mock-env') != ''
185
+ term_width = 1000000
186
+ end
182
187
  if (width_needed <= term_width)
183
188
  print_table_normally(maxwidth)
184
189
  else
@@ -1,8 +1,9 @@
1
- require 'net/http'
2
1
  require 'rubygems/user_interaction'
2
+ require_relative 'config_handler'
3
3
 
4
4
  class ProxyCredentials
5
5
  include Gem::UserInteraction
6
+
6
7
  def self.proxy_credentials(proxy)
7
8
  new.get_credentials(proxy)
8
9
  end
@@ -14,17 +15,8 @@ class ProxyCredentials
14
15
  proxy_port = uri.port
15
16
  proxy_user = ask("username:")
16
17
  proxy_password = ask_for_password("password:")
17
-
18
- uri = URI("http://blogsearch.google.com/ping/RPC2")
19
- req = Net::HTTP::Get.new(uri)
20
- net = Net::HTTP.new(uri.hostname, uri.port, proxy_host, proxy_port, proxy_user, proxy_password)
21
- puts "created net"
22
- net.read_timeout = 20
23
- net.open_timeout = 20
24
-
25
- net.start { |http|
26
- response = http.request(req)
27
- puts "response code from internet web service is #{response.code}, message is #{response.message}"
28
- }
18
+ config = ConfigHandler.new
19
+ config.set("proxy-Username", proxy_user)
20
+ config.set("proxy-Password", proxy_password)
29
21
  end
30
22
  end
@@ -1,9 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative 'common.rb'
3
- require 'cgi'
4
-
5
- URI_PREFIX="https://api.edgecast.com/v2/reporting/"
6
- URI_CUSTOMERS_SEGMENT = "customers/" + ACCT_NUM + "/"
2
+ require_relative 'config_reader'
3
+ require_relative 'common'
7
4
 
8
5
  module Interval
9
6
  FIVE_MINUTE = 1
@@ -16,113 +13,132 @@ module TrafficUnits
16
13
  GB = 2
17
14
  end
18
15
 
19
- def to_csv(prefix, pops_list)
20
- result = ""
21
- if (pops_list.count > 0)
22
- result = prefix + pops_list[0]
23
- pops_list.shift
24
- pops_list.each { |pop|
25
- result = result + "," + pop
26
- }
16
+ class Reporting
17
+ include ConfigReader
18
+
19
+ @@instance = nil
20
+
21
+ def self.do
22
+ @@instance ? @@instance : @@instance = Reporting.new
27
23
  end
28
- result
29
- end
30
24
 
31
- def time_to_q(time)
32
- time.strftime("%Y-%m-%dT%H:%M:%S")
33
- end
25
+ def initialize
26
+ rest_base_url = param("rest_base_url")
27
+ if (rest_base_url.nil? || rest_base_url.length == 0)
28
+ raise "configuration file does not contain expected parameters -- try config init"
29
+ end
30
+ @common = CommonRestUtils.new(rest_base_url + "reporting/")
31
+ @uri_customers_segment = "customers/" + param("acct-num") + "/"
32
+ end
34
33
 
35
- def interval(begin_time, end_time)
36
- "?begindate=" + time_to_q(begin_time) + "&enddate=" + time_to_q(end_time)
37
- end
34
+ def to_csv(prefix, pops_list)
35
+ result = ""
36
+ if (pops_list.count > 0)
37
+ result = prefix + pops_list[0]
38
+ pops_list.shift
39
+ pops_list.each { |pop|
40
+ result = result + "," + pop
41
+ }
42
+ end
43
+ result
44
+ end
38
45
 
39
- def customer_suffix(word)
40
- URI_CUSTOMERS_SEGMENT + word
41
- end
46
+ def time_to_q(time)
47
+ time.strftime("%Y-%m-%dT%H:%M:%S")
48
+ end
42
49
 
43
- def interval_suffix(word, begin_time, end_time)
44
- URI_CUSTOMERS_SEGMENT + word + interval(begin_time, end_time)
45
- end
50
+ def interval(begin_time, end_time)
51
+ "?begindate=" + time_to_q(begin_time) + "&enddate=" + time_to_q(end_time)
52
+ end
46
53
 
47
- def media_suffix(media_type, word, begin_time, end_time)
48
- URI_CUSTOMERS_SEGMENT + "media/" + media_type.to_s + "/" + word + interval(begin_time, end_time)
49
- end
54
+ def customer_suffix(word)
55
+ @uri_customers_segment + word
56
+ end
50
57
 
51
- def get_all_data_transferred(begin_time, end_time, *pops)
52
- callMethod(interval_suffix("bytestransferred", begin_time, end_time) + to_csv("&pops=", pops), :get)
53
- end
58
+ def interval_suffix(word, begin_time, end_time)
59
+ @uri_customers_segment + word + interval(begin_time, end_time)
60
+ end
54
61
 
55
- def get_asset_activity(media_type, begin_time, end_time)
56
- callMethod(media_suffix(media_type, "filestats", begin_time, end_time), :get)
57
- end
62
+ def media_suffix(media_type, word, begin_time, end_time)
63
+ @uri_customers_segment + "media/" + media_type.to_s + "/" + word + interval(begin_time, end_time)
64
+ end
58
65
 
59
- def get_billing_regions
60
- callMethod("billing/regions", :get)
61
- end
66
+ def get_all_data_transferred(begin_time, end_time, *pops)
67
+ @common.callMethod(interval_suffix("bytestransferred", begin_time, end_time) + to_csv("&pops=", pops), :get)
68
+ end
62
69
 
63
- def get_cache_status_activity(media_type, begin_time, end_time)
64
- callMethod(media_suffix(media_type, "cachestats", begin_time, end_time), :get)
65
- end
70
+ def get_asset_activity(media_type, begin_time, end_time)
71
+ @common.callMethod(media_suffix(media_type, "filestats", begin_time, end_time), :get)
72
+ end
66
73
 
67
- def get_current_storage_usage
68
- callMethod(customer_suffix("lateststorageusage"), :get)
69
- end
74
+ def get_billing_regions
75
+ @common.callMethod("billing/regions", :get)
76
+ end
70
77
 
71
- def get_customer_account_number(custom_id)
72
- callMethod("customers/accountnumber?customercustomid=" + CGI.escape(custom_id), :get)
73
- end
78
+ def get_cache_status_activity(media_type, begin_time, end_time)
79
+ @common.callMethod(media_suffix(media_type, "cachestats", begin_time, end_time), :get)
80
+ end
74
81
 
75
- def get_customer_name
76
- callMethod(customer_suffix("customername"), :get)
77
- end
82
+ def get_current_storage_usage
83
+ @common.callMethod(customer_suffix("lateststorageusage"), :get)
84
+ end
78
85
 
79
- def get_data_transferred_and_hits_by_custom_report_codes(media_type, begin_time, end_time)
80
- callMethod(media_suffix(media_type, "cnamereportcodes", begin_time, end_time), :get)
81
- end
86
+ def get_customer_account_number(custom_id)
87
+ @common.callMethod("customers/accountnumber?customercustomid=" + custom_id, :get)
88
+ end
82
89
 
83
- def get_data_transferred_by_platform(media_type, begin_time, end_time, *pops)
84
- callMethod(media_suffix(media_type, "bytestransferred", begin_time, end_time) + to_csv("&pops=", pops), :get)
85
- end
90
+ def get_customer_name
91
+ @common.callMethod(customer_suffix("customername"), :get)
92
+ end
86
93
 
87
- def get_data_transferred_by_platform_and_interval(media_type, begin_time, end_time, region_id, interval_id, *pops)
88
- suffix = interval_suffix("bytestransferred/interval", begin_time, end_time);
89
- if (media_type)
90
- suffix = suffix + "&mediatypeid=" + media_type.to_s
94
+ def get_data_transferred_and_hits_by_custom_report_codes(media_type, begin_time, end_time)
95
+ @common.callMethod(media_suffix(media_type, "cnamereportcodes", begin_time, end_time), :get)
91
96
  end
92
- if (interval_id)
93
- suffix = suffix + "&intervalid=" + interval_id.to_s
97
+
98
+ def get_data_transferred_by_platform(media_type, begin_time, end_time, *pops)
99
+ @common.callMethod(media_suffix(media_type, "bytestransferred", begin_time, end_time) + to_csv("&pops=", pops), :get)
94
100
  end
95
- suffix = suffix + to_csv("&pops=", pops)
96
- if (region_id)
97
- suffix = suffix + "&regionid=" + region_id.to_s
101
+
102
+ def get_data_transferred_by_platform_and_interval(media_type, begin_time, end_time, region_id, interval_id, *pops)
103
+ suffix = interval_suffix("bytestransferred/interval", begin_time, end_time);
104
+ if (media_type)
105
+ suffix = suffix + "&mediatypeid=" + media_type.to_s
106
+ end
107
+ if (interval_id)
108
+ suffix = suffix + "&intervalid=" + interval_id.to_s
109
+ end
110
+ suffix = suffix + to_csv("&pops=", pops)
111
+ if (region_id)
112
+ suffix = suffix + "&regionid=" + region_id.to_s
113
+ end
114
+ puts "suffix: " + suffix
115
+ @common.callMethod(suffix, :get)
98
116
  end
99
- puts "suffix: " + suffix
100
- callMethod(suffix, :get)
101
- end
102
117
 
103
- def get_directory_activity(media_type, begin_time, end_time)
104
- callMethod(media_suffix(media_type, "directorystats", begin_time, end_time), :get)
105
- end
118
+ def get_directory_activity(media_type, begin_time, end_time)
119
+ @common.callMethod(media_suffix(media_type, "directorystats", begin_time, end_time), :get)
120
+ end
106
121
 
107
- def get_download_activity(media_type, begin_time, end_time)
108
- callMethod(media_suffix(media_type, "completedownloads", begin_time, end_time), :get)
109
- end
122
+ def get_download_activity(media_type, begin_time, end_time)
123
+ @common.callMethod(media_suffix(media_type, "completedownloads", begin_time, end_time), :get)
124
+ end
110
125
 
111
- def get_maximum_storage_usage(begin_time, end_time)
112
- callMethod(interval_suffix("maxstorageusage", begin_time, end_time), :get)
113
- end
126
+ def get_maximum_storage_usage(begin_time, end_time)
127
+ @common.callMethod(interval_suffix("maxstorageusage", begin_time, end_time), :get)
128
+ end
114
129
 
115
- def get_report_codes(media_type)
116
- suffix = customer_suffix("reportcodes")
117
- if (media_type)
118
- suffix = suffix + "?mediatypeid=" + media_type.to_s
130
+ def get_report_codes(media_type)
131
+ suffix = customer_suffix("reportcodes")
132
+ if (media_type)
133
+ suffix = suffix + "?mediatypeid=" + media_type.to_s
134
+ end
135
+ @common.callMethod(suffix, :get)
119
136
  end
120
- callMethod(suffix, :get)
121
- end
122
137
 
123
- def get_traffic_usage(media_type, region_id, units, billing_month)
124
- suffix = URI_CUSTOMERS_SEGMENT +
125
- "media/" + media_type.to_s + "/region/" + region_id.to_s + "/units/" + units.to_s + "/trafficusage" +
126
- "?begindate=" + billing_month.strftime("%Y-%m-01")
127
- callMethod(suffix, :get)
138
+ def get_traffic_usage(media_type, region_id, units, billing_month)
139
+ suffix = @uri_customers_segment +
140
+ "media/" + media_type.to_s + "/region/" + region_id.to_s + "/units/" + units.to_s + "/trafficusage" +
141
+ "?begindate=" + billing_month.strftime("%Y-%m-01")
142
+ @common.callMethod(suffix, :get)
143
+ end
128
144
  end