Top Level Namespace

Defined Under Namespace

Modules: CommandProc, ConfigReader, Interval, MediaType, TrafficUnits, Vzcdn Classes: CommonRestUtils, Configure, Route, Zone

Constant Summary collapse

HOST =

Move this file to ~/.vdms.d/userInfo.rb

"ftp.cpm.BED3.edgecastcdn.net"
USER =
"[email protected]"
PWD =
"kevin123"
API_TOKEN =
"e22db149-7369-4d7b-9c53-38d38746ccea"
ACCT_NUM =
"BED3"
URI_PREFIX =
"https://api.edgecast.com/v2/mcc/customers/" + ACCT_NUM + "/"
URI_CUSTOMERS_SEGMENT =
"customers/" + ACCT_NUM + "/"

Instance Method Summary collapse

Instance Method Details

#add_origin(media_type, directory, host_header, http_host_names, http_load_balancing, https_host_names, https_load_balancing, shield_pops) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/mediaManagment.rb', line 67

def add_origin(media_type, directory, host_header, http_host_names, http_load_balancing, https_host_names, https_load_balancing, shield_pops)
  
  body = { :DirectoryName => directory, :HostHeader => host_header, :HttpHostnames => http_host_names, :HttpLoadBalancing => http_load_balancing, 
    :HttpsHostnames => https_host_names, :HttpsLoadBalancing => https_load_balancing, :ShieldPOPs => shield_pops }
  media_type_s = case when MediaType::HTTP_LARGE then "httplarge"
                   when MediaType::HTTP_SMALL then "httpsmall"
                   when MediaType::FLASH_MEDIA then "flash"
                   when MediaType::ADN then "adn" end
                   
  callMethod("origins/" + media_type_s, :post, body)    
end

#customer_suffix(word) ⇒ Object



39
40
41
# File 'lib/reporting.rb', line 39

def customer_suffix(word)
  URI_CUSTOMERS_SEGMENT + word
end

#delete_customer_origin(origin_id) ⇒ Object



79
80
81
# File 'lib/mediaManagment.rb', line 79

def delete_customer_origin(origin_id)
  callMethod("origins/" + origin_id.to_s, :delete)
end

#get_all_compression_settings ⇒ Object



23
24
25
# File 'lib/mediaManagment.rb', line 23

def get_all_compression_settings
  callMethod("compression", :get)
end

#get_all_customer_origins ⇒ Object



63
64
65
# File 'lib/mediaManagment.rb', line 63

def get_all_customer_origins()
  callMethod("origins/httplarge", :get)
end

#get_all_data_transferred(begin_time, end_time, *pops) ⇒ Object



51
52
53
# File 'lib/reporting.rb', line 51

def get_all_data_transferred(begin_time, end_time, *pops)
  callMethod(interval_suffix("bytestransferred", begin_time, end_time) + to_csv("&pops=", pops), :get)
end

#get_all_query_string_caching_settings ⇒ Object



27
28
29
# File 'lib/mediaManagment.rb', line 27

def get_all_query_string_caching_settings
  callMethod("querystringcaching", :get)
end

#get_all_query_string_logging_settings ⇒ Object



31
32
33
# File 'lib/mediaManagment.rb', line 31

def get_all_query_string_logging_settings
  callMethod("querystringlogging", :get)
end

#get_asset_activity(media_type, begin_time, end_time) ⇒ Object



55
56
57
# File 'lib/reporting.rb', line 55

def get_asset_activity(media_type, begin_time, end_time)
  callMethod(media_suffix(media_type, "filestats", begin_time, end_time), :get)
end

#get_billing_regions ⇒ Object



59
60
61
# File 'lib/reporting.rb', line 59

def get_billing_regions
  callMethod("billing/regions", :get)
end

#get_cache_status_activity(media_type, begin_time, end_time) ⇒ Object



63
64
65
# File 'lib/reporting.rb', line 63

def get_cache_status_activity(media_type, begin_time, end_time)
  callMethod(media_suffix(media_type, "cachestats", begin_time, end_time), :get)
end

#get_compression_setting(media_type) ⇒ Object



35
36
37
# File 'lib/mediaManagment.rb', line 35

def get_compression_setting (media_type)
  callMethod("compression?mediatypeid=" + media_type.to_s, :get)
end

#get_current_bandwidth(media_type) ⇒ Object



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

def get_current_bandwidth(media_type)
  callMethod(media_type.to_s + "/bandwidth", :get)
end

#get_current_cache_status_statistics(media_type) ⇒ Object



9
10
11
# File 'lib/realTimeStats.rb', line 9

def get_current_cache_status_statistics(media_type)
  callMethod(media_type.to_s + "/cachestatus", :get)
end

#get_current_status_code_statistics(media_type) ⇒ Object



13
14
15
# File 'lib/realTimeStats.rb', line 13

def get_current_status_code_statistics(media_type)
  callMethod(media_type.to_s + "/statuscode", :get)
end

#get_current_storage_usage ⇒ Object



67
68
69
# File 'lib/reporting.rb', line 67

def get_current_storage_usage
  callMethod(customer_suffix("lateststorageusage"), :get)
end

#get_current_streams ⇒ Object



17
18
19
# File 'lib/realTimeStats.rb', line 17

def get_current_streams
  callMethod("2/streams", :get)
end

#get_current_total_connections(media_type) ⇒ Object



21
22
23
# File 'lib/realTimeStats.rb', line 21

def get_current_total_connections(media_type)
  callMethod(media_type.to_s + "/connections", :get)
end

#get_customer_account_number(custom_id) ⇒ Object



71
72
73
# File 'lib/reporting.rb', line 71

def (custom_id)
  callMethod("customers/accountnumber?customercustomid=" + CGI.escape(custom_id), :get)
end

#get_customer_name ⇒ Object



75
76
77
# File 'lib/reporting.rb', line 75

def get_customer_name
  callMethod(customer_suffix("customername"), :get)
end

#get_data_transferred_and_hits_by_custom_report_codes(media_type, begin_time, end_time) ⇒ Object



79
80
81
# File 'lib/reporting.rb', line 79

def get_data_transferred_and_hits_by_custom_report_codes(media_type, begin_time, end_time)
  callMethod(media_suffix(media_type, "cnamereportcodes", begin_time, end_time), :get)
end

#get_data_transferred_by_platform(media_type, begin_time, end_time, *pops) ⇒ Object



83
84
85
# File 'lib/reporting.rb', line 83

def get_data_transferred_by_platform(media_type, begin_time, end_time, *pops)
  callMethod(media_suffix(media_type, "bytestransferred", begin_time, end_time) + to_csv("&pops=", pops), :get)
end

#get_data_transferred_by_platform_and_interval(media_type, begin_time, end_time, region_id, interval_id, *pops) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/reporting.rb', line 87

def get_data_transferred_by_platform_and_interval(media_type, begin_time, end_time, region_id, interval_id, *pops)
  suffix = interval_suffix("bytestransferred/interval", begin_time, end_time);
  if (media_type)
    suffix = suffix + "&mediatypeid=" + media_type.to_s
  end
  if (interval_id)
    suffix = suffix + "&intervalid=" + interval_id.to_s
  end
  suffix = suffix + to_csv("&pops=", pops)
  if (region_id)
    suffix = suffix + "&regionid=" + region_id.to_s
  end
  puts "suffix: " + suffix
  callMethod(suffix, :get)
end

#get_directory_activity(media_type, begin_time, end_time) ⇒ Object



103
104
105
# File 'lib/reporting.rb', line 103

def get_directory_activity(media_type, begin_time, end_time)
  callMethod(media_suffix(media_type, "directorystats", begin_time, end_time), :get)
end

#get_download_activity(media_type, begin_time, end_time) ⇒ Object



107
108
109
# File 'lib/reporting.rb', line 107

def get_download_activity(media_type, begin_time, end_time)
  callMethod(media_suffix(media_type, "completedownloads", begin_time, end_time), :get)
end

#get_maximum_storage_usage(begin_time, end_time) ⇒ Object



111
112
113
# File 'lib/reporting.rb', line 111

def get_maximum_storage_usage(begin_time, end_time)
  callMethod(interval_suffix("maxstorageusage", begin_time, end_time), :get)
end

#get_query_string_caching_setting(media_type) ⇒ Object



39
40
41
# File 'lib/mediaManagment.rb', line 39

def get_query_string_caching_setting(media_type)
  callMethod("querystringcaching?mediatypeid=" + media_type.to_s, :get)
end

#get_query_string_logging_setting(media_type) ⇒ Object



43
44
45
# File 'lib/mediaManagment.rb', line 43

def get_query_string_logging_setting(media_type)
  callMethod("querystringlogging?mediatypeid=" + media_type.to_s, :get)
end

#get_report_codes(media_type) ⇒ Object



115
116
117
118
119
120
121
# File 'lib/reporting.rb', line 115

def get_report_codes(media_type)
  suffix = customer_suffix("reportcodes")
  if (media_type)
    suffix = suffix + "?mediatypeid=" + media_type.to_s
  end
  callMethod(suffix, :get)
end

#get_traffic_usage(media_type, region_id, units, billing_month) ⇒ Object



123
124
125
126
127
128
# File 'lib/reporting.rb', line 123

def get_traffic_usage(media_type, region_id, units, billing_month)
  suffix = URI_CUSTOMERS_SEGMENT +
    "media/" + media_type.to_s + "/region/" + region_id.to_s + "/units/" + units.to_s + "/trafficusage" +
    "?begindate=" + billing_month.strftime("%Y-%m-01")
  callMethod(suffix, :get)
end

#getAllEdgeNodes ⇒ Object



9
10
11
# File 'lib/mediaManagment.rb', line 9

def getAllEdgeNodes()
  callMethod("edgenodes", :get)
end

#getPurgeRequest(id) ⇒ Object



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

def getPurgeRequest(id)
  callMethod("edge/purge/" + id, :get)
end

#interval(begin_time, end_time) ⇒ Object



35
36
37
# File 'lib/reporting.rb', line 35

def interval(begin_time, end_time)
  "?begindate=" + time_to_q(begin_time) + "&enddate=" + time_to_q(end_time)
end

#interval_suffix(word, begin_time, end_time) ⇒ Object



43
44
45
# File 'lib/reporting.rb', line 43

def interval_suffix(word, begin_time, end_time)
  URI_CUSTOMERS_SEGMENT + word + interval(begin_time, end_time)
end

#loadContent(path, type) ⇒ Object



13
14
15
16
# File 'lib/mediaManagment.rb', line 13

def loadContent(path, type)
  body = {:MediaPath => path, :MediaType => type}
  callMethod("edge/load", :put, body)
end

#media_suffix(media_type, word, begin_time, end_time) ⇒ Object



47
48
49
# File 'lib/reporting.rb', line 47

def media_suffix(media_type, word, begin_time, end_time)
  URI_CUSTOMERS_SEGMENT + "media/" + media_type.to_s + "/" + word + interval(begin_time, end_time)
end

#purgeContent(path, type) ⇒ Object



18
19
20
21
# File 'lib/mediaManagment.rb', line 18

def purgeContent(path, type)
  body = {:MediaPath => path, :MediaType => type}
  callMethod("edge/purge", :put, body)
end

#time_to_q(time) ⇒ Object



31
32
33
# File 'lib/reporting.rb', line 31

def time_to_q(time)
  time.strftime("%Y-%m-%dT%H:%M:%S")
end

#to_csv(prefix, pops_list) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/reporting.rb', line 19

def to_csv(prefix, pops_list)
  result = ""
  if (pops_list.count > 0)
    result = prefix + pops_list[0]
    pops_list.shift
    pops_list.each { |pop|
      result = result + "," + pop
    }
  end
  result
end

#update_compression_settings(media_type, enable, *content_types) ⇒ Object



47
48
49
50
# File 'lib/mediaManagment.rb', line 47

def update_compression_settings(media_type, enable, *content_types) 
  body = { :ContentTypes => content_types, :MediaTypeId => media_type, :Status => (enable ? 1 :0) }
  callMethod("compression", :put, body)
end

#update_query_string_caching_setting(query_string_caching, media_type) ⇒ Object



52
53
54
55
# File 'lib/mediaManagment.rb', line 52

def update_query_string_caching_setting (query_string_caching, media_type)
  body = { :QueryStringCaching => query_string_caching, :MediaTypeId => media_type}
  callMethod("querystringcaching", :put, body)  
end

#update_query_string_logging_status(media_type, logging) ⇒ Object



57
58
59
60
# File 'lib/mediaManagment.rb', line 57

def update_query_string_logging_status(media_type, logging)
  body = { :QueryStringLogging => logging, :MediaTypeId => media_type}
  callMethod("querystringlogging", :put, body)    
end