conversant 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.env.example +39 -0
  3. data/.gitignore +52 -0
  4. data/.gitlab-ci.yml +108 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +16 -0
  7. data/.yardopts +7 -0
  8. data/CHANGELOG.md +487 -0
  9. data/Gemfile +12 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +860 -0
  12. data/RELEASE.md +726 -0
  13. data/Rakefile +21 -0
  14. data/conversant.gemspec +49 -0
  15. data/examples/inheritance_integration.rb +348 -0
  16. data/examples/rails_initializer.rb +69 -0
  17. data/lib/conversant/configuration.rb +132 -0
  18. data/lib/conversant/v3/base.rb +47 -0
  19. data/lib/conversant/v3/http_client.rb +456 -0
  20. data/lib/conversant/v3/mixins/authentication.rb +221 -0
  21. data/lib/conversant/v3/services/authorization.rb +194 -0
  22. data/lib/conversant/v3/services/cdn/analytics.rb +483 -0
  23. data/lib/conversant/v3/services/cdn/audit.rb +71 -0
  24. data/lib/conversant/v3/services/cdn/business.rb +122 -0
  25. data/lib/conversant/v3/services/cdn/certificate.rb +180 -0
  26. data/lib/conversant/v3/services/cdn/dashboard.rb +109 -0
  27. data/lib/conversant/v3/services/cdn/domain.rb +223 -0
  28. data/lib/conversant/v3/services/cdn/monitoring.rb +65 -0
  29. data/lib/conversant/v3/services/cdn/partner/analytics.rb +233 -0
  30. data/lib/conversant/v3/services/cdn/partner.rb +60 -0
  31. data/lib/conversant/v3/services/cdn.rb +221 -0
  32. data/lib/conversant/v3/services/lms/dashboard.rb +99 -0
  33. data/lib/conversant/v3/services/lms/domain.rb +108 -0
  34. data/lib/conversant/v3/services/lms/job.rb +211 -0
  35. data/lib/conversant/v3/services/lms/partner/analytics.rb +266 -0
  36. data/lib/conversant/v3/services/lms/partner/business.rb +151 -0
  37. data/lib/conversant/v3/services/lms/partner/report.rb +170 -0
  38. data/lib/conversant/v3/services/lms/partner.rb +58 -0
  39. data/lib/conversant/v3/services/lms/preset.rb +57 -0
  40. data/lib/conversant/v3/services/lms.rb +173 -0
  41. data/lib/conversant/v3/services/oss/partner/analytics.rb +105 -0
  42. data/lib/conversant/v3/services/oss/partner.rb +48 -0
  43. data/lib/conversant/v3/services/oss.rb +128 -0
  44. data/lib/conversant/v3/services/portal/dashboard.rb +114 -0
  45. data/lib/conversant/v3/services/portal.rb +219 -0
  46. data/lib/conversant/v3/services/vms/analytics.rb +114 -0
  47. data/lib/conversant/v3/services/vms/business.rb +190 -0
  48. data/lib/conversant/v3/services/vms/partner/analytics.rb +133 -0
  49. data/lib/conversant/v3/services/vms/partner/business.rb +90 -0
  50. data/lib/conversant/v3/services/vms/partner.rb +57 -0
  51. data/lib/conversant/v3/services/vms/transcoding.rb +184 -0
  52. data/lib/conversant/v3/services/vms.rb +166 -0
  53. data/lib/conversant/v3.rb +36 -0
  54. data/lib/conversant/version.rb +5 -0
  55. data/lib/conversant.rb +108 -0
  56. data/publish.sh +107 -0
  57. data/sig/conversant/v3/services/authorization.rbs +34 -0
  58. data/sig/conversant/v3/services/cdn.rbs +123 -0
  59. data/sig/conversant/v3/services/lms.rbs +80 -0
  60. data/sig/conversant/v3/services/portal.rbs +22 -0
  61. data/sig/conversant/v3/services/vms.rbs +64 -0
  62. data/sig/conversant/v3.rbs +85 -0
  63. data/sig/conversant.rbs +37 -0
  64. metadata +267 -0
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Conversant
4
+ module V3
5
+ module Services
6
+ class CDN
7
+ # Audit service for CDN activity logging
8
+ #
9
+ # Provides access to audit logs and compliance tracking
10
+ # for CDN configuration changes and administrative actions.
11
+ #
12
+ # @example View audit logs
13
+ # cdn = Conversant::V3.cdn(12345)
14
+ #
15
+ # logs = cdn.audit.list({
16
+ # startTime: "2025-01-01T00:00:00Z",
17
+ # endTime: "2025-01-01T23:59:59Z",
18
+ # pageSize: 100,
19
+ # pageNumber: 0
20
+ # })
21
+ #
22
+ # logs.each do |log|
23
+ # puts "#{log['timestamp']}: #{log['action']} by #{log['user']}"
24
+ # end
25
+ #
26
+ # @since 1.0.0
27
+ class Audit
28
+ # @return [CDN] the parent CDN service instance
29
+ attr_reader :parent
30
+
31
+ # Initialize audit service
32
+ #
33
+ # @param parent [CDN] the parent CDN service instance
34
+ def initialize(parent)
35
+ @parent = parent
36
+ end
37
+
38
+ # Get audit log entries
39
+ #
40
+ # @param payload [Hash] audit query parameters
41
+ # @option payload [String] :startTime start time for audit logs
42
+ # @option payload [String] :endTime end time for audit logs
43
+ # @option payload [String] :action specific action to filter by
44
+ # @option payload [String] :user user ID to filter by
45
+ # @option payload [Integer] :pageSize number of results per page
46
+ # @option payload [Integer] :pageNumber page number (0-based)
47
+ #
48
+ # @return [Array] array of audit log entries, or empty array on error
49
+ #
50
+ # @example Get recent audit logs
51
+ # logs = cdn.audit.list({
52
+ # startTime: "2025-01-01T00:00:00Z",
53
+ # endTime: "2025-01-01T23:59:59Z",
54
+ # pageSize: 100,
55
+ # pageNumber: 0
56
+ # })
57
+ # logs.each { |log| puts "#{log['timestamp']}: #{log['action']} by #{log['user']}" }
58
+ #
59
+ # @since 1.0.0
60
+ def list(payload)
61
+ response = JSON.parse(@parent.send(:call, 'POST', '/api/audit_list', payload))
62
+ response&.[]('list') || []
63
+ rescue StandardError => e
64
+ @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
65
+ []
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Conversant
4
+ module V3
5
+ module Services
6
+ class CDN
7
+ # Business metrics service for CDN billing and usage reporting
8
+ #
9
+ # Provides access to business-level metrics used for billing calculations,
10
+ # usage reporting, and 95th percentile bandwidth measurements.
11
+ # These metrics are typically used for financial reporting and capacity planning.
12
+ #
13
+ # @example Get billing metrics
14
+ # business = cdn.business
15
+ #
16
+ # # Get traffic usage for billing
17
+ # usage = business.bandwidth({
18
+ # startTime: "2025-01-01T00:00:00Z",
19
+ # endTime: "2025-01-31T23:59:59Z",
20
+ # pageSize: 1000,
21
+ # pageNumber: 0
22
+ # })
23
+ #
24
+ # # Get 95th percentile bandwidth
25
+ # bandwidth_95th = business.bandwidth95th(year: 2025)
26
+ #
27
+ # @since 1.0.1
28
+ class Business
29
+ # @return [CDN] the parent CDN service instance
30
+ attr_reader :parent
31
+
32
+ # Initialize business metrics service
33
+ #
34
+ # @param parent [CDN] the parent CDN service instance
35
+ def initialize(parent)
36
+ @parent = parent
37
+ end
38
+
39
+ # Get domain traffic usage for billing
40
+ #
41
+ # Retrieves detailed traffic usage data by domain for billing and reporting purposes.
42
+ # This data is typically used for invoicing and usage analysis.
43
+ #
44
+ # @param payload [Hash] query parameters for traffic usage
45
+ # @option payload [String] :startTime start time in ISO 8601 format ("2025-01-01T00:00:00Z")
46
+ # @option payload [String] :endTime end time in ISO 8601 format ("2025-01-31T23:59:59Z")
47
+ # @option payload [Integer] :pageSize number of results per page (recommended: 1000)
48
+ # @option payload [Integer] :pageNumber page number for pagination (0-based)
49
+ #
50
+ # @return [Array, Array] array of domain traffic usage records, or empty array on error
51
+ #
52
+ # @example Get monthly traffic usage
53
+ # usage = cdn.business.bandwidth({
54
+ # startTime: "2025-01-01T00:00:00Z",
55
+ # endTime: "2025-01-31T23:59:59Z",
56
+ # pageSize: 1000,
57
+ # pageNumber: 0
58
+ # })
59
+ #
60
+ # usage.each do |record|
61
+ # puts "Domain: #{record['domain']}"
62
+ # puts "Traffic: #{record['traffic_bytes']} bytes"
63
+ # puts "Period: #{record['period']}"
64
+ # end
65
+ #
66
+ # @since 1.0.1
67
+ def bandwidth(payload)
68
+ response = @parent.send(:call, 'POST', '/api/domain_traffic_usage', payload)
69
+ return [] if response.nil?
70
+
71
+ JSON.parse(response)&.[]('list') || []
72
+ rescue StandardError => e
73
+ logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
74
+ []
75
+ end
76
+
77
+ # Get 95th percentile bandwidth measurements
78
+ #
79
+ # Retrieves 95th percentile bandwidth measurements for the specified year.
80
+ # This metric is commonly used in CDN billing to calculate peak usage
81
+ # while excluding traffic spikes that occur less than 5% of the time.
82
+ #
83
+ # @param params [Hash] query parameters
84
+ # @option params [Integer] :year the year to get 95th percentile data for (e.g., 2025)
85
+ #
86
+ # @return [Array, Array] array of 95th percentile bandwidth measurements, or empty array on error
87
+ #
88
+ # @example Get 95th percentile for current year
89
+ # bandwidth_95th = cdn.business.bandwidth95th(year: 2025)
90
+ #
91
+ # bandwidth_95th.each do |measurement|
92
+ # puts "Month: #{measurement['month']}"
93
+ # puts "95th Percentile: #{measurement['bandwidth_95th']} bps"
94
+ # puts "Peak: #{measurement['peak_bandwidth']} bps"
95
+ # end
96
+ #
97
+ # @example Calculate annual 95th percentile
98
+ # measurements = cdn.business.bandwidth95th(year: 2025)
99
+ # annual_95th = measurements.map { |m| m['bandwidth_95th'] }.max
100
+ # puts "Annual 95th percentile: #{annual_95th} bps"
101
+ #
102
+ # @since 1.0.1
103
+ def bandwidth95th(params)
104
+ response = @parent.send(:call, 'GET', "/api/report/bandwidth95th/#{params[:year]}", nil)
105
+ return [] if response.nil?
106
+
107
+ JSON.parse(response)
108
+ rescue StandardError => e
109
+ logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
110
+ []
111
+ end
112
+
113
+ private
114
+
115
+ def logger
116
+ @parent.send(:logger)
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Conversant
4
+ module V3
5
+ module Services
6
+ class CDN
7
+ # SSL/TLS certificate management service for CDN domains
8
+ #
9
+ # Provides comprehensive certificate management functionality including:
10
+ # - Certificate listing and filtering
11
+ # - Auto-certificate information retrieval
12
+ # - Automatic certificate deployment
13
+ # - Let's Encrypt integration support
14
+ #
15
+ # @example Basic certificate operations
16
+ # certificates = cdn.certificate.all
17
+ # cert_info = cdn.certificate.auto_certificate_info(cert_id, domain_name)
18
+ #
19
+ # # Deploy auto certificate
20
+ # success = cdn.certificate.deploy_auto_certificate(cert_id, domain_name, {
21
+ # enable: true,
22
+ # domains: ["example.com", "www.example.com"]
23
+ # })
24
+ #
25
+ # @since 1.0.1
26
+ class Certificate
27
+ # @return [CDN] the parent CDN service instance
28
+ attr_reader :parent
29
+
30
+ # Initialize certificate service
31
+ #
32
+ # @param parent [CDN] the parent CDN service instance
33
+ def initialize(parent)
34
+ @parent = parent
35
+ end
36
+
37
+ # Get all SSL certificates for the customer
38
+ #
39
+ # Retrieves a comprehensive list of SSL certificates associated with the customer account.
40
+ # Supports filtering and pagination through query parameters.
41
+ #
42
+ # @param params [Hash] optional query parameters for filtering and pagination
43
+ # @option params [Integer] :pageSize number of results per page
44
+ # @option params [Integer] :pageNumber page number for pagination (0-based)
45
+ # @option params [String] :status filter by certificate status (active, expired, pending)
46
+ # @option params [String] :domain filter by domain name
47
+ #
48
+ # @return [Array<Hash>, Array] array of certificate objects with properties like id, name, status, expiry, etc.
49
+ # Returns empty array on error or if no certificates exist.
50
+ #
51
+ # @example Get all certificates
52
+ # certificates = cdn.certificate.all
53
+ # certificates.each do |cert|
54
+ # puts "Certificate: #{cert['name']} (ID: #{cert['id']})"
55
+ # puts " Status: #{cert['status']}"
56
+ # puts " Expires: #{cert['expiry_date']}"
57
+ # puts " Domains: #{cert['domains']&.join(', ')}"
58
+ # end
59
+ #
60
+ # @example Get certificates with pagination
61
+ # certificates = cdn.certificate.all({
62
+ # pageSize: 50,
63
+ # pageNumber: 0,
64
+ # status: "active"
65
+ # })
66
+ #
67
+ # @since 1.0.1
68
+ def all(params = {})
69
+ response = @parent.send(:call, 'GET', "/list-certificate?#{params.to_query}")
70
+ return [] if response.nil?
71
+
72
+ JSON.parse(response)&.[]('list') || []
73
+ rescue StandardError => e
74
+ logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
75
+ []
76
+ end
77
+
78
+ # Get auto-certificate information for a specific domain
79
+ #
80
+ # Retrieves detailed information about an auto-certificate (Let's Encrypt) for a specific
81
+ # certificate ID and domain name. This includes certificate status, validation details,
82
+ # and deployment configuration.
83
+ #
84
+ # @param certificate_id [Integer, String] the certificate ID to query
85
+ # @param name [String] the domain name to get certificate info for
86
+ #
87
+ # @return [Hash, nil] certificate information hash containing status, domains, validation details, etc.
88
+ # Returns nil on error or if certificate doesn't exist.
89
+ #
90
+ # @example Get auto-certificate info
91
+ # cert_info = cdn.certificate.auto_certificate_info(12345, "example.com")
92
+ # if cert_info
93
+ # puts "Certificate Status: #{cert_info['status']}"
94
+ # puts "Validation Method: #{cert_info['validation_method']}"
95
+ # puts "Domains: #{cert_info['domains']&.join(', ')}"
96
+ # puts "Auto-renewal: #{cert_info['auto_renewal'] ? 'Enabled' : 'Disabled'}"
97
+ # else
98
+ # puts "Certificate not found or error occurred"
99
+ # end
100
+ #
101
+ # @example Check certificate validation status
102
+ # cert_info = cdn.certificate.auto_certificate_info(cert_id, domain)
103
+ # if cert_info && cert_info['validation_status'] == 'valid'
104
+ # puts "Certificate is valid and ready for deployment"
105
+ # end
106
+ #
107
+ # @since 1.0.1
108
+ def auto_certificate_info(certificate_id, name)
109
+ response = @parent.send(:call, 'GET', "/api/auto-certificate/#{certificate_id}/#{name}")
110
+ return nil if response.nil?
111
+
112
+ JSON.parse(response)
113
+ rescue StandardError => e
114
+ logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
115
+ nil
116
+ end
117
+
118
+ # Deploy auto-certificate for a domain
119
+ #
120
+ # Deploys or updates an auto-certificate (Let's Encrypt) configuration for the specified
121
+ # certificate ID and domain. This enables automatic SSL certificate provisioning and renewal.
122
+ #
123
+ # @param certificate_id [Integer, String] the certificate ID to deploy
124
+ # @param name [String] the primary domain name for the certificate
125
+ # @param payload [Hash] deployment configuration
126
+ # @option payload [Boolean] :enable enable auto-certificate for this domain
127
+ # @option payload [Array<String>] :domains list of domains to include in the certificate
128
+ # @option payload [String] :validation_method validation method (dns, http, etc.)
129
+ # @option payload [Boolean] :auto_renewal enable automatic certificate renewal
130
+ # @option payload [Hash] :dns_settings DNS validation settings (if using DNS validation)
131
+ #
132
+ # @return [Boolean] true if deployment was successful, false otherwise
133
+ #
134
+ # @example Deploy auto-certificate for single domain
135
+ # success = cdn.certificate.deploy_auto_certificate(12345, "example.com", {
136
+ # enable: true,
137
+ # domains: ["example.com"],
138
+ # validation_method: "http",
139
+ # auto_renewal: true
140
+ # })
141
+ #
142
+ # if success
143
+ # puts "Auto-certificate deployed successfully"
144
+ # else
145
+ # puts "Failed to deploy auto-certificate"
146
+ # end
147
+ #
148
+ # @example Deploy auto-certificate for multiple domains
149
+ # success = cdn.certificate.deploy_auto_certificate(cert_id, "example.com", {
150
+ # enable: true,
151
+ # domains: ["example.com", "www.example.com", "api.example.com"],
152
+ # validation_method: "dns",
153
+ # auto_renewal: true,
154
+ # dns_settings: {
155
+ # provider: "cloudflare",
156
+ # api_token: "your_api_token"
157
+ # }
158
+ # })
159
+ #
160
+ # @since 1.0.1
161
+ def deploy_auto_certificate(certificate_id, name, payload)
162
+ response = @parent.send(:call, 'POST', "/api/auto-certificate/#{certificate_id}/#{name}", payload)
163
+ return false if response.nil?
164
+
165
+ JSON.parse(response)&.[]('status') == 'ok'
166
+ rescue StandardError => e
167
+ logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
168
+ false
169
+ end
170
+
171
+ private
172
+
173
+ def logger
174
+ @parent.send(:logger)
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Conversant
4
+ module V3
5
+ module Services
6
+ class CDN
7
+ # Dashboard service for CDN quick metrics
8
+ #
9
+ # Provides daily aggregated metrics for bandwidth and volume
10
+ # suitable for dashboard displays and quick overviews.
11
+ #
12
+ # @example Get dashboard metrics
13
+ # cdn = Conversant::V3.cdn(12345)
14
+ #
15
+ # bandwidth = cdn.dashboard.bandwidth({
16
+ # customerId: "12345",
17
+ # startTime: "2025-01-01T00:00:00Z",
18
+ # endTime: "2025-01-31T00:00:00Z",
19
+ # interval: "day",
20
+ # fillFixedTime: true
21
+ # })
22
+ #
23
+ # volume = cdn.dashboard.volume({
24
+ # customerId: "12345",
25
+ # startTime: "2025-01-01T00:00:00Z",
26
+ # endTime: "2025-01-31T00:00:00Z",
27
+ # interval: "day"
28
+ # })
29
+ #
30
+ # @since 1.0.8
31
+ class Dashboard
32
+ # @return [CDN] the parent CDN service instance
33
+ attr_reader :parent
34
+
35
+ # Initialize dashboard service
36
+ #
37
+ # @param parent [CDN] the parent CDN service instance
38
+ def initialize(parent)
39
+ @parent = parent
40
+ end
41
+
42
+ # Get daily bandwidth metrics
43
+ #
44
+ # @param payload [Hash] bandwidth query parameters
45
+ # @option payload [String] :customerId customer ID
46
+ # @option payload [String] :startTime start time in ISO 8601 format
47
+ # @option payload [String] :endTime end time in ISO 8601 format
48
+ # @option payload [String] :interval time interval (typically "day")
49
+ # @option payload [Boolean] :fillFixedTime fill missing time slots
50
+ # @option payload [String] :daHostName specific hostname filter
51
+ #
52
+ # @return [Hash] bandwidth data with time series, or nil on error
53
+ #
54
+ # @example Get daily bandwidth for dashboard
55
+ # bandwidth = cdn.dashboard.bandwidth({
56
+ # customerId: "34194",
57
+ # startTime: "2025-01-01T00:00:00Z",
58
+ # endTime: "2025-01-31T00:00:00Z",
59
+ # interval: "day",
60
+ # fillFixedTime: true,
61
+ # daHostName: ""
62
+ # })
63
+ # puts "Total: #{bandwidth['total']} Mbps"
64
+ #
65
+ # @since 1.0.8
66
+ def bandwidth(payload)
67
+ response = @parent.send(:call, 'POST', '/api/report/bandwidth/day', payload)
68
+ JSON.parse(response)
69
+ rescue StandardError => e
70
+ @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:dashboard.bandwidth.EXCEPTION:#{e.message}"
71
+ nil
72
+ end
73
+
74
+ # Get daily volume metrics
75
+ #
76
+ # @param payload [Hash] volume query parameters
77
+ # @option payload [String] :customerId customer ID
78
+ # @option payload [String] :startTime start time in ISO 8601 format
79
+ # @option payload [String] :endTime end time in ISO 8601 format
80
+ # @option payload [String] :interval time interval (typically "day")
81
+ # @option payload [Boolean] :fillFixedTime fill missing time slots
82
+ # @option payload [String] :daHostName specific hostname filter
83
+ #
84
+ # @return [Hash] volume data with time series, or nil on error
85
+ #
86
+ # @example Get daily volume for dashboard
87
+ # volume = cdn.dashboard.volume({
88
+ # customerId: "34194",
89
+ # startTime: "2025-01-01T00:00:00Z",
90
+ # endTime: "2025-01-31T00:00:00Z",
91
+ # interval: "day",
92
+ # fillFixedTime: true,
93
+ # daHostName: ""
94
+ # })
95
+ # puts "Total: #{volume['total']} GB"
96
+ #
97
+ # @since 1.0.8
98
+ def volume(payload)
99
+ response = @parent.send(:call, 'POST', '/api/report/volume/day', payload)
100
+ JSON.parse(response)
101
+ rescue StandardError => e
102
+ @parent.send(:logger).error "#{@parent.send(:identifier)}.METHOD:dashboard.volume.EXCEPTION:#{e.message}"
103
+ nil
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end