Class: Conversant::V3::Services::OSS::Partner::Analytics
- Inherits:
-
Object
- Object
- Conversant::V3::Services::OSS::Partner::Analytics
- Defined in:
- lib/conversant/v3/services/oss/partner/analytics.rb
Overview
OSS (Object Storage Service) analytics for partner-level reporting
Provides partner-level analytics and reporting for Object Storage Service including storage usage metrics for S3-compatible storage across multiple customer accounts.
Instance Attribute Summary collapse
-
#parent ⇒ Conversant::V3::Services::OSS
readonly
The parent OSS service instance.
Instance Method Summary collapse
-
#current_month_usage(payload = {}) ⇒ Integer?
Get storage usage for current month.
-
#initialize(parent) ⇒ Analytics
constructor
Initialize partner OSS analytics service.
-
#usages(year, params = {}) ⇒ Array<Hash>
Get storage usage metrics for OSS (full year data).
Constructor Details
#initialize(parent) ⇒ Analytics
Initialize partner OSS analytics service
Note: OSS analytics uses the CDN service endpoint for API calls.
24 25 26 |
# File 'lib/conversant/v3/services/oss/partner/analytics.rb', line 24 def initialize(parent) @parent = parent end |
Instance Attribute Details
#parent ⇒ Conversant::V3::Services::OSS (readonly)
Returns the parent OSS service instance.
17 18 19 |
# File 'lib/conversant/v3/services/oss/partner/analytics.rb', line 17 def parent @parent end |
Instance Method Details
#current_month_usage(payload = {}) ⇒ Integer?
Get storage usage for current month
Retrieves disk usage for the month containing the specified date (or current month). This is useful for getting current month's storage usage for billing purposes.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/conversant/v3/services/oss/partner/analytics.rb', line 77 def current_month_usage(payload = {}) require 'date' # Extract the end date from the payload, defaulting to the current date today = if payload.[](:end) || payload.[]('end') (payload[:end] || payload['end']).to_date else Date.today end # Fetch storage usage data for the year containing the end date yearly_data = usages(today.year.to_s) return 0 if yearly_data.nil? || yearly_data.empty? # Find the storage usage for the specific month today_month_format = today.strftime('%Y-%m') month_data = yearly_data.find { |item| item&.[]('month') == today_month_format } month_data&.[]('diskUsage') || 0 rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#usages(year, params = {}) ⇒ Array<Hash>
Get storage usage metrics for OSS (full year data)
Retrieves Object Storage Service usage data including storage capacity, bandwidth usage, and request counts aggregated by month for billing and capacity planning purposes. Returns all months for the specified year.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/conversant/v3/services/oss/partner/analytics.rb', line 47 def usages(year, params = {}) query_string = params.map { |k, v| "#{k}=#{v}" }.join('&') uri = "/oss/storage_usages/#{year}" uri += "?#{query_string}" unless query_string.empty? response = @parent.send(:call, 'GET', uri) JSON.parse(response) || [] rescue StandardError => e @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |