Class: Conversant::V3::Services::CDN::Dashboard

Inherits:
Object
  • Object
show all
Defined in:
lib/conversant/v3/services/cdn/dashboard.rb

Overview

Dashboard service for CDN quick metrics

Provides daily aggregated metrics for bandwidth and volume suitable for dashboard displays and quick overviews.

Examples:

Get dashboard metrics

cdn = Conversant::V3.cdn(12345)

bandwidth = cdn.dashboard.bandwidth({
  customerId: "12345",
  startTime: "2025-01-01T00:00:00Z",
  endTime: "2025-01-31T00:00:00Z",
  interval: "day",
  fillFixedTime: true
})

volume = cdn.dashboard.volume({
  customerId: "12345",
  startTime: "2025-01-01T00:00:00Z",
  endTime: "2025-01-31T00:00:00Z",
  interval: "day"
})

Since:

  • 1.0.8

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Dashboard

Initialize dashboard service

Since:

  • 1.0.8



38
39
40
# File 'lib/conversant/v3/services/cdn/dashboard.rb', line 38

def initialize(parent)
  @parent = parent
end

Instance Attribute Details

#parentCDN (readonly)

Returns the parent CDN service instance.

Since:

  • 1.0.8



33
34
35
# File 'lib/conversant/v3/services/cdn/dashboard.rb', line 33

def parent
  @parent
end

Instance Method Details

#bandwidth(payload) ⇒ Hash

Get daily bandwidth metrics

Examples:

Get daily bandwidth for dashboard

bandwidth = cdn.dashboard.bandwidth({
  customerId: "34194",
  startTime: "2025-01-01T00:00:00Z",
  endTime: "2025-01-31T00:00:00Z",
  interval: "day",
  fillFixedTime: true,
  daHostName: ""
})
puts "Total: #{bandwidth['total']} Mbps"

Options Hash (payload):

  • :customerId (String)

    customer ID

  • :startTime (String)

    start time in ISO 8601 format

  • :endTime (String)

    end time in ISO 8601 format

  • :interval (String)

    time interval (typically "day")

  • :fillFixedTime (Boolean)

    fill missing time slots

  • :daHostName (String)

    specific hostname filter

Since:

  • 1.0.8



66
67
68
69
70
71
72
# File 'lib/conversant/v3/services/cdn/dashboard.rb', line 66

def bandwidth(payload)
  response = @parent.send(:call, 'POST', '/api/report/bandwidth/day', payload)
  JSON.parse(response)
rescue StandardError => e
  @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:dashboard.bandwidth.EXCEPTION:#{e.message}"
  nil
end

#volume(payload) ⇒ Hash

Get daily volume metrics

Examples:

Get daily volume for dashboard

volume = cdn.dashboard.volume({
  customerId: "34194",
  startTime: "2025-01-01T00:00:00Z",
  endTime: "2025-01-31T00:00:00Z",
  interval: "day",
  fillFixedTime: true,
  daHostName: ""
})
puts "Total: #{volume['total']} GB"

Options Hash (payload):

  • :customerId (String)

    customer ID

  • :startTime (String)

    start time in ISO 8601 format

  • :endTime (String)

    end time in ISO 8601 format

  • :interval (String)

    time interval (typically "day")

  • :fillFixedTime (Boolean)

    fill missing time slots

  • :daHostName (String)

    specific hostname filter

Since:

  • 1.0.8



98
99
100
101
102
103
104
# File 'lib/conversant/v3/services/cdn/dashboard.rb', line 98

def volume(payload)
  response = @parent.send(:call, 'POST', '/api/report/volume/day', payload)
  JSON.parse(response)
rescue StandardError => e
  @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:dashboard.volume.EXCEPTION:#{e.message}"
  nil
end