Class: Orb::Resources::Metrics
- Inherits:
-
Object
- Object
- Orb::Resources::Metrics
- Defined in:
- lib/orb/resources/metrics.rb,
sig/orb/resources/metrics.rbs
Overview
The Metric resource represents a calculation of a quantity based on events. Metrics are defined by the query that transforms raw usage events into meaningful values for your customers.
Instance Method Summary collapse
-
#create(description:, item_id:, name:, sql:, metadata: nil, request_options: {}) ⇒ Orb::Models::BillableMetric
Some parameter documentations has been truncated, see Models::MetricCreateParams for more details.
-
#fetch(metric_id, request_options: {}) ⇒ Orb::Models::BillableMetric
This endpoint is used to fetch metric details given a metric identifier.
-
#initialize(client:) ⇒ Metrics
constructor
private
A new instance of Metrics.
-
#list(created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::BillableMetric>
Some parameter documentations has been truncated, see Models::MetricListParams for more details.
-
#update(metric_id, metadata: nil, request_options: {}) ⇒ Orb::Models::BillableMetric
Some parameter documentations has been truncated, see Models::MetricUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Metrics
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 Metrics.
140 141 142 |
# File 'lib/orb/resources/metrics.rb', line 140 def initialize(client:) @client = client end |
Instance Method Details
#create(description:, item_id:, name:, sql:, metadata: nil, request_options: {}) ⇒ Orb::Models::BillableMetric
Some parameter documentations has been truncated, see Models::MetricCreateParams for more details.
This endpoint is used to create a metric using a SQL string. See SQL support for a description of constructing SQL queries with examples.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/orb/resources/metrics.rb', line 33 def create(params) parsed, = Orb::MetricCreateParams.dump_request(params) @client.request( method: :post, path: "metrics", body: parsed, model: Orb::BillableMetric, options: ) end |
#fetch(metric_id, request_options: {}) ⇒ Orb::Models::BillableMetric
This endpoint is used to fetch metric details given a metric identifier. It returns information about the metrics including its name, description, and item.
128 129 130 131 132 133 134 135 |
# File 'lib/orb/resources/metrics.rb', line 128 def fetch(metric_id, params = {}) @client.request( method: :get, path: ["metrics/%1$s", metric_id], model: Orb::BillableMetric, options: params[:request_options] ) end |
#list(created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::BillableMetric>
Some parameter documentations has been truncated, see Models::MetricListParams for more details.
This endpoint is used to list metrics. It returns information about the metrics including its name, description, and item.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/orb/resources/metrics.rb', line 98 def list(params = {}) parsed, = Orb::MetricListParams.dump_request(params) query = Orb::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "metrics", query: query.transform_keys( created_at_gt: "created_at[gt]", created_at_gte: "created_at[gte]", created_at_lt: "created_at[lt]", created_at_lte: "created_at[lte]" ), page: Orb::Internal::Page, model: Orb::BillableMetric, options: ) end |
#update(metric_id, metadata: nil, request_options: {}) ⇒ Orb::Models::BillableMetric
Some parameter documentations has been truncated, see Models::MetricUpdateParams for more details.
This endpoint allows you to update the metadata property on a metric. If you
pass null for the metadata value, it will clear any existing metadata for that
invoice.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/orb/resources/metrics.rb', line 62 def update(metric_id, params = {}) parsed, = Orb::MetricUpdateParams.dump_request(params) @client.request( method: :put, path: ["metrics/%1$s", metric_id], body: parsed, model: Orb::BillableMetric, options: ) end |