Class: Orb::Resources::Metrics
- Inherits:
-
Object
- Object
- Orb::Resources::Metrics
- Defined in:
- lib/orb/resources/metrics.rb
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 list [metrics](/core-concepts#metric).
-
#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.
136 137 138 |
# File 'lib/orb/resources/metrics.rb', line 136 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](/core-concepts###metric) using a SQL string. See [SQL support](/extensibility/advanced-metrics#sql-support) for a description of constructing SQL queries with examples.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/orb/resources/metrics.rb', line 30 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 list [metrics](/core-concepts#metric). It returns information about the metrics including its name, description, and item.
124 125 126 127 128 129 130 131 |
# File 'lib/orb/resources/metrics.rb', line 124 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 fetch [metric](/core-concepts##metric) details given a metric identifier. It returns information about the metrics including its name, description, and item.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/orb/resources/metrics.rb', line 96 def list(params = {}) parsed, = Orb::MetricListParams.dump_request(params) @client.request( method: :get, path: "metrics", query: parsed.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.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/orb/resources/metrics.rb', line 59 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 |