Class: MetronomeSDK::Resources::V1::BillableMetrics
- Inherits:
-
Object
- Object
- MetronomeSDK::Resources::V1::BillableMetrics
- Defined in:
- lib/metronome_sdk/resources/v1/billable_metrics.rb
Instance Method Summary collapse
-
#archive(id: , request_options: {}) ⇒ MetronomeSDK::Models::V1::BillableMetricArchiveResponse
Use this endpoint to retire billable metrics that are no longer used.
-
#create(name: , aggregation_key: nil, aggregation_type: nil, custom_fields: nil, event_type_filter: nil, group_keys: nil, property_filters: nil, sql: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::BillableMetricCreateResponse
Some parameter documentations has been truncated, see Models::V1::BillableMetricCreateParams for more details.
-
#initialize(client:) ⇒ BillableMetrics
constructor
private
A new instance of BillableMetrics.
-
#list(include_archived: nil, limit: nil, next_page: nil, request_options: {}) ⇒ MetronomeSDK::Internal::CursorPage<MetronomeSDK::Models::V1::BillableMetricListResponse>
Retrieves all billable metrics with their complete configurations.
-
#retrieve(billable_metric_id: , request_options: {}) ⇒ MetronomeSDK::Models::V1::BillableMetricRetrieveResponse
Retrieves the complete configuration for a specific billable metric by its ID.
Constructor Details
#initialize(client:) ⇒ BillableMetrics
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of BillableMetrics.
171 172 173 |
# File 'lib/metronome_sdk/resources/v1/billable_metrics.rb', line 171 def initialize(client:) @client = client end |
Instance Method Details
#archive(id: , request_options: {}) ⇒ MetronomeSDK::Models::V1::BillableMetricArchiveResponse
Use this endpoint to retire billable metrics that are no longer used. After a billable metric is archived, that billable metric can no longer be used in any new Products to define how that product should be metered. If you archive a billable metric that is already associated with a Product, the Product will continue to function as usual, metering based on the definition of the archived billable metric.
Archived billable metrics will be returned on the ‘getBillableMetric` and `listBillableMetrics` endpoints with a populated `archived_at` field.
157 158 159 160 161 162 163 164 165 166 |
# File 'lib/metronome_sdk/resources/v1/billable_metrics.rb', line 157 def archive(params) parsed, = MetronomeSDK::V1::BillableMetricArchiveParams.dump_request(params) @client.request( method: :post, path: "v1/billable-metrics/archive", body: parsed, model: MetronomeSDK::Models::V1::BillableMetricArchiveResponse, options: ) end |
#create(name: , aggregation_key: nil, aggregation_type: nil, custom_fields: nil, event_type_filter: nil, group_keys: nil, property_filters: nil, sql: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::BillableMetricCreateResponse
Some parameter documentations has been truncated, see Models::V1::BillableMetricCreateParams for more details.
Create billable metrics programmatically with this endpoint—an essential step in configuring your pricing and packaging in Metronome.
A billable metric is a customizable query that filters and aggregates events from your event stream. These metrics are continuously tracked as usage data enters Metronome through the ingestion pipeline. The ingestion process transforms raw usage data into actionable pricing metrics, enabling accurate metering and billing for your products.
### Use this endpoint to:
-
Create individual or multiple billable metrics as part of a setup workflow.
-
Automate the entire pricing configuration process, from metric creation to customer contract setup.
-
Define metrics using either standard filtering/aggregation or a custom SQL query.
### Key response fields:
-
The ID of the billable metric that was created
-
The created billable metric will be available to be used in Products, usage endpoints, and alerts.
### Usage guidelines:
-
Metrics defined using standard filtering and aggregation are Streaming billable metrics, which have been optimized for ultra low latency and high throughput workflows.
-
Use SQL billable metrics if you require more flexible aggregation options.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/metronome_sdk/resources/v1/billable_metrics.rb', line 63 def create(params) parsed, = MetronomeSDK::V1::BillableMetricCreateParams.dump_request(params) @client.request( method: :post, path: "v1/billable-metrics/create", body: parsed, model: MetronomeSDK::Models::V1::BillableMetricCreateResponse, options: ) end |
#list(include_archived: nil, limit: nil, next_page: nil, request_options: {}) ⇒ MetronomeSDK::Internal::CursorPage<MetronomeSDK::Models::V1::BillableMetricListResponse>
Retrieves all billable metrics with their complete configurations. Use this for programmatic discovery and management of billable metrics, such as associating metrics to products and auditing for orphaned or archived metrics. Important: Archived metrics are excluded by default; use ‘include_archived`=`true` parameter to include them.
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/metronome_sdk/resources/v1/billable_metrics.rb', line 127 def list(params = {}) parsed, = MetronomeSDK::V1::BillableMetricListParams.dump_request(params) @client.request( method: :get, path: "v1/billable-metrics", query: parsed, page: MetronomeSDK::Internal::CursorPage, model: MetronomeSDK::Models::V1::BillableMetricListResponse, options: ) end |
#retrieve(billable_metric_id: , request_options: {}) ⇒ MetronomeSDK::Models::V1::BillableMetricRetrieveResponse
Retrieves the complete configuration for a specific billable metric by its ID. Use this to review billable metric setup before associating it with products. Returns the metric’s ‘name`, `event_type_filter`, `property_filters`, `aggregation_type`, `aggregation_key`, `group_keys`, `custom fields`, and `SQL query` (if it’s a SQL billable metric).
Important:
-
Archived billable metrics will include an ‘archived_at` timestamp; they no longer process new usage events but remain accessible for historical reference.
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/metronome_sdk/resources/v1/billable_metrics.rb', line 94 def retrieve(params) parsed, = MetronomeSDK::V1::BillableMetricRetrieveParams.dump_request(params) billable_metric_id = parsed.delete(:billable_metric_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["v1/billable-metrics/%1$s", billable_metric_id], model: MetronomeSDK::Models::V1::BillableMetricRetrieveResponse, options: ) end |