orb-billing 1.51.0 → 1.53.0

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +1 -1
  4. data/lib/orb/models/billable_metric_edited_webhook_event.rb +33 -1
  5. data/lib/orb/models/credit_block_accounting_sync_failed_webhook_event.rb +7 -1
  6. data/lib/orb/models/credit_block_accounting_sync_succeeded_webhook_event.rb +7 -1
  7. data/lib/orb/models/credit_block_list_invoices_response.rb +7 -1
  8. data/lib/orb/models/credit_block_retrieve_response.rb +7 -1
  9. data/lib/orb/models/credit_block_update_response.rb +7 -1
  10. data/lib/orb/models/customer_credit_ledger_incremented_webhook_event.rb +7 -1
  11. data/lib/orb/models/metric_create_params.rb +24 -1
  12. data/lib/orb/models/metric_list_params.rb +1 -1
  13. data/lib/orb/models/metric_publish_params.rb +20 -0
  14. data/lib/orb/models/metric_update_params.rb +20 -1
  15. data/lib/orb/models/plan.rb +9 -1
  16. data/lib/orb/models/plan_version_phase.rb +9 -1
  17. data/lib/orb/models/webhooks/billable_metric_edited_standard_webhook_event.rb +35 -1
  18. data/lib/orb/models/webhooks/credit_block_accounting_sync_failed_standard_webhook_event.rb +7 -1
  19. data/lib/orb/models/webhooks/credit_block_accounting_sync_succeeded_standard_webhook_event.rb +7 -1
  20. data/lib/orb/models/webhooks/customer_credit_ledger_incremented_standard_webhook_event.rb +7 -1
  21. data/lib/orb/models.rb +2 -0
  22. data/lib/orb/resources/credit_blocks.rb +2 -1
  23. data/lib/orb/resources/metrics.rb +34 -2
  24. data/lib/orb/version.rb +1 -1
  25. data/lib/orb.rb +1 -0
  26. data/rbi/orb/models/billable_metric_edited_webhook_event.rbi +76 -3
  27. data/rbi/orb/models/credit_block_accounting_sync_failed_webhook_event.rbi +11 -0
  28. data/rbi/orb/models/credit_block_accounting_sync_succeeded_webhook_event.rbi +11 -0
  29. data/rbi/orb/models/credit_block_list_invoices_response.rbi +11 -0
  30. data/rbi/orb/models/credit_block_retrieve_response.rbi +11 -0
  31. data/rbi/orb/models/credit_block_update_response.rbi +11 -0
  32. data/rbi/orb/models/customer_credit_ledger_incremented_webhook_event.rbi +11 -0
  33. data/rbi/orb/models/metric_create_params.rbi +37 -0
  34. data/rbi/orb/models/metric_list_params.rbi +1 -1
  35. data/rbi/orb/models/metric_publish_params.rbi +33 -0
  36. data/rbi/orb/models/metric_update_params.rbi +22 -0
  37. data/rbi/orb/models/plan.rbi +11 -3
  38. data/rbi/orb/models/plan_version_phase.rbi +11 -3
  39. data/rbi/orb/models/webhooks/billable_metric_edited_standard_webhook_event.rbi +76 -3
  40. data/rbi/orb/models/webhooks/credit_block_accounting_sync_failed_standard_webhook_event.rbi +11 -0
  41. data/rbi/orb/models/webhooks/credit_block_accounting_sync_succeeded_standard_webhook_event.rbi +11 -0
  42. data/rbi/orb/models/webhooks/customer_credit_ledger_incremented_standard_webhook_event.rbi +11 -0
  43. data/rbi/orb/models.rbi +2 -0
  44. data/rbi/orb/resources/credit_blocks.rbi +2 -1
  45. data/rbi/orb/resources/metrics.rbi +31 -0
  46. data/sig/orb/models/billable_metric_edited_webhook_event.rbs +30 -3
  47. data/sig/orb/models/credit_block_accounting_sync_failed_webhook_event.rbs +2 -1
  48. data/sig/orb/models/credit_block_accounting_sync_succeeded_webhook_event.rbs +2 -1
  49. data/sig/orb/models/credit_block_list_invoices_response.rbs +2 -1
  50. data/sig/orb/models/credit_block_retrieve_response.rbs +2 -1
  51. data/sig/orb/models/credit_block_update_response.rbs +2 -1
  52. data/sig/orb/models/customer_credit_ledger_incremented_webhook_event.rbs +2 -1
  53. data/sig/orb/models/metric_create_params.rbs +21 -1
  54. data/sig/orb/models/metric_list_params.rbs +2 -2
  55. data/sig/orb/models/metric_publish_params.rbs +23 -0
  56. data/sig/orb/models/metric_update_params.rbs +11 -1
  57. data/sig/orb/models/plan.rbs +8 -3
  58. data/sig/orb/models/plan_version_phase.rbs +8 -3
  59. data/sig/orb/models/webhooks/billable_metric_edited_standard_webhook_event.rbs +30 -3
  60. data/sig/orb/models/webhooks/credit_block_accounting_sync_failed_standard_webhook_event.rbs +2 -1
  61. data/sig/orb/models/webhooks/credit_block_accounting_sync_succeeded_standard_webhook_event.rbs +2 -1
  62. data/sig/orb/models/webhooks/customer_credit_ledger_incremented_standard_webhook_event.rbs +2 -1
  63. data/sig/orb/models.rbs +2 -0
  64. data/sig/orb/resources/metrics.rbs +8 -0
  65. metadata +4 -1
@@ -13,7 +13,7 @@ module Orb
13
13
  # string. See [SQL support](/extensibility/advanced-metrics#sql-support) for a
14
14
  # description of constructing SQL queries with examples.
15
15
  #
16
- # @overload create(description:, item_id:, name:, sql:, metadata: nil, request_options: {})
16
+ # @overload create(description:, item_id:, name:, sql:, metadata: nil, status: nil, request_options: {})
17
17
  #
18
18
  # @param description [String, nil] A description of the metric.
19
19
  #
@@ -25,6 +25,8 @@ module Orb
25
25
  #
26
26
  # @param metadata [Hash{Symbol=>String, nil}, nil] User-specified key/value pairs for the resource. Individual keys can be removed
27
27
  #
28
+ # @param status [Symbol, Orb::Models::MetricCreateParams::Status] The status of the metric to create (either active or draft). If not specified, t
29
+ #
28
30
  # @param request_options [Orb::RequestOptions, Hash{Symbol=>Object}, nil]
29
31
  #
30
32
  # @return [Orb::Models::BillableMetric]
@@ -49,16 +51,24 @@ module Orb
49
51
  # `name` cannot be empty. If you pass `null` for the metadata value, it will clear
50
52
  # any existing metadata for that metric.
51
53
  #
52
- # @overload update(metric_id, description: nil, metadata: nil, name: nil, request_options: {})
54
+ # While a metric is in `draft` status, its `sql` and `item_id` can also be
55
+ # changed. Use [publish metric](/api-reference/metric/publish-metric) to make a
56
+ # draft metric active.
57
+ #
58
+ # @overload update(metric_id, description: nil, item_id: nil, metadata: nil, name: nil, sql: nil, request_options: {})
53
59
  #
54
60
  # @param metric_id [String]
55
61
  #
56
62
  # @param description [String, nil] A description of the metric.
57
63
  #
64
+ # @param item_id [String, nil] The id of the item to associate the metric with. Can only be changed while the m
65
+ #
58
66
  # @param metadata [Hash{Symbol=>String, nil}, nil] User-specified key/value pairs for the resource. Individual keys can be removed
59
67
  #
60
68
  # @param name [String, nil] The name of the metric.
61
69
  #
70
+ # @param sql [String, nil] A new sql string defining the metric. Can only be changed while the metric is in
71
+ #
62
72
  # @param request_options [Orb::RequestOptions, Hash{Symbol=>Object}, nil]
63
73
  #
64
74
  # @return [Orb::Models::BillableMetric]
@@ -169,6 +179,28 @@ module Orb
169
179
  )
170
180
  end
171
181
 
182
+ # This endpoint publishes a [metric](/core-concepts#metric) in `draft` status,
183
+ # making it `active`. Only draft metrics can be published, and an active metric
184
+ # can't be moved back into `draft`, so its `sql` and `item_id` can no longer be
185
+ # changed.
186
+ #
187
+ # @overload publish(metric_id, request_options: {})
188
+ #
189
+ # @param metric_id [String]
190
+ # @param request_options [Orb::RequestOptions, Hash{Symbol=>Object}, nil]
191
+ #
192
+ # @return [Orb::Models::BillableMetric]
193
+ #
194
+ # @see Orb::Models::MetricPublishParams
195
+ def publish(metric_id, params = {})
196
+ @client.request(
197
+ method: :post,
198
+ path: ["metrics/%1$s/publish", metric_id],
199
+ model: Orb::BillableMetric,
200
+ options: params[:request_options]
201
+ )
202
+ end
203
+
172
204
  # This endpoint restores an archived [metric](/core-concepts#metric) to `active`,
173
205
  # so it can be chosen for new plans again. Only archived metrics can be
174
206
  # unarchived.
data/lib/orb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orb
4
- VERSION = "1.51.0"
4
+ VERSION = "1.53.0"
5
5
  end
data/lib/orb.rb CHANGED
@@ -315,6 +315,7 @@ require_relative "orb/models/metric_create_params"
315
315
  require_relative "orb/models/metric_events_dropped_by_watermark_webhook_event"
316
316
  require_relative "orb/models/metric_fetch_params"
317
317
  require_relative "orb/models/metric_list_params"
318
+ require_relative "orb/models/metric_publish_params"
318
319
  require_relative "orb/models/metric_unarchive_params"
319
320
  require_relative "orb/models/metric_update_params"
320
321
  require_relative "orb/models/minimum"
@@ -187,34 +187,107 @@ module Orb
187
187
  sig { returns(T.nilable(String)) }
188
188
  attr_accessor :description
189
189
 
190
+ sig { returns(T.nilable(String)) }
191
+ attr_accessor :item_id
192
+
190
193
  sig { returns(T.nilable(T::Hash[Symbol, String])) }
191
194
  attr_accessor :metadata
192
195
 
193
196
  sig { returns(T.nilable(String)) }
194
197
  attr_accessor :name
195
198
 
199
+ sig { returns(T.nilable(String)) }
200
+ attr_accessor :sql
201
+
202
+ sig do
203
+ returns(
204
+ T.nilable(
205
+ Orb::BillableMetricEditedWebhookEvent::Properties::PreviousAttributes::Status::TaggedSymbol
206
+ )
207
+ )
208
+ end
209
+ attr_accessor :status
210
+
196
211
  # metadata values are non-null on the wire, as on the price event.
197
212
  sig do
198
213
  params(
199
214
  description: T.nilable(String),
215
+ item_id: T.nilable(String),
200
216
  metadata: T.nilable(T::Hash[Symbol, String]),
201
- name: T.nilable(String)
217
+ name: T.nilable(String),
218
+ sql: T.nilable(String),
219
+ status:
220
+ T.nilable(
221
+ Orb::BillableMetricEditedWebhookEvent::Properties::PreviousAttributes::Status::OrSymbol
222
+ )
202
223
  ).returns(T.attached_class)
203
224
  end
204
- def self.new(description: nil, metadata: nil, name: nil)
225
+ def self.new(
226
+ description: nil,
227
+ item_id: nil,
228
+ metadata: nil,
229
+ name: nil,
230
+ sql: nil,
231
+ status: nil
232
+ )
205
233
  end
206
234
 
207
235
  sig do
208
236
  override.returns(
209
237
  {
210
238
  description: T.nilable(String),
239
+ item_id: T.nilable(String),
211
240
  metadata: T.nilable(T::Hash[Symbol, String]),
212
- name: T.nilable(String)
241
+ name: T.nilable(String),
242
+ sql: T.nilable(String),
243
+ status:
244
+ T.nilable(
245
+ Orb::BillableMetricEditedWebhookEvent::Properties::PreviousAttributes::Status::TaggedSymbol
246
+ )
213
247
  }
214
248
  )
215
249
  end
216
250
  def to_hash
217
251
  end
252
+
253
+ module Status
254
+ extend Orb::Internal::Type::Enum
255
+
256
+ TaggedSymbol =
257
+ T.type_alias do
258
+ T.all(
259
+ Symbol,
260
+ Orb::BillableMetricEditedWebhookEvent::Properties::PreviousAttributes::Status
261
+ )
262
+ end
263
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
264
+
265
+ ACTIVE =
266
+ T.let(
267
+ :active,
268
+ Orb::BillableMetricEditedWebhookEvent::Properties::PreviousAttributes::Status::TaggedSymbol
269
+ )
270
+ ARCHIVED =
271
+ T.let(
272
+ :archived,
273
+ Orb::BillableMetricEditedWebhookEvent::Properties::PreviousAttributes::Status::TaggedSymbol
274
+ )
275
+ DRAFT =
276
+ T.let(
277
+ :draft,
278
+ Orb::BillableMetricEditedWebhookEvent::Properties::PreviousAttributes::Status::TaggedSymbol
279
+ )
280
+
281
+ sig do
282
+ override.returns(
283
+ T::Array[
284
+ Orb::BillableMetricEditedWebhookEvent::Properties::PreviousAttributes::Status::TaggedSymbol
285
+ ]
286
+ )
287
+ end
288
+ def self.values
289
+ end
290
+ end
218
291
  end
219
292
  end
220
293
 
@@ -334,6 +334,8 @@ module Orb
334
334
  sig { returns(T.nilable(String)) }
335
335
  attr_accessor :per_unit_cost_basis
336
336
 
337
+ # `void` means the credit block was deleted. A voided block's `balance` is
338
+ # always 0.
337
339
  sig do
338
340
  returns(
339
341
  Orb::CreditBlockAccountingSyncFailedWebhookEvent::Block::Status::TaggedSymbol
@@ -430,6 +432,8 @@ module Orb
430
432
  # `null`.
431
433
  metadata:,
432
434
  per_unit_cost_basis:,
435
+ # `void` means the credit block was deleted. A voided block's `balance` is
436
+ # always 0.
433
437
  status:,
434
438
  # The credit allocation that funded a block. Extends the allocation resource
435
439
  # serialized on prices with the catalog-item attribution of the funding price.
@@ -669,6 +673,8 @@ module Orb
669
673
  end
670
674
  end
671
675
 
676
+ # `void` means the credit block was deleted. A voided block's `balance` is
677
+ # always 0.
672
678
  module Status
673
679
  extend Orb::Internal::Type::Enum
674
680
 
@@ -691,6 +697,11 @@ module Orb
691
697
  :pending_payment,
692
698
  Orb::CreditBlockAccountingSyncFailedWebhookEvent::Block::Status::TaggedSymbol
693
699
  )
700
+ VOID =
701
+ T.let(
702
+ :void,
703
+ Orb::CreditBlockAccountingSyncFailedWebhookEvent::Block::Status::TaggedSymbol
704
+ )
694
705
 
695
706
  sig do
696
707
  override.returns(
@@ -338,6 +338,8 @@ module Orb
338
338
  sig { returns(T.nilable(String)) }
339
339
  attr_accessor :per_unit_cost_basis
340
340
 
341
+ # `void` means the credit block was deleted. A voided block's `balance` is
342
+ # always 0.
341
343
  sig do
342
344
  returns(
343
345
  Orb::CreditBlockAccountingSyncSucceededWebhookEvent::Block::Status::TaggedSymbol
@@ -434,6 +436,8 @@ module Orb
434
436
  # `null`.
435
437
  metadata:,
436
438
  per_unit_cost_basis:,
439
+ # `void` means the credit block was deleted. A voided block's `balance` is
440
+ # always 0.
437
441
  status:,
438
442
  # The credit allocation that funded a block. Extends the allocation resource
439
443
  # serialized on prices with the catalog-item attribution of the funding price.
@@ -673,6 +677,8 @@ module Orb
673
677
  end
674
678
  end
675
679
 
680
+ # `void` means the credit block was deleted. A voided block's `balance` is
681
+ # always 0.
676
682
  module Status
677
683
  extend Orb::Internal::Type::Enum
678
684
 
@@ -695,6 +701,11 @@ module Orb
695
701
  :pending_payment,
696
702
  Orb::CreditBlockAccountingSyncSucceededWebhookEvent::Block::Status::TaggedSymbol
697
703
  )
704
+ VOID =
705
+ T.let(
706
+ :void,
707
+ Orb::CreditBlockAccountingSyncSucceededWebhookEvent::Block::Status::TaggedSymbol
708
+ )
698
709
 
699
710
  sig do
700
711
  override.returns(
@@ -110,6 +110,8 @@ module Orb
110
110
  sig { returns(T.nilable(String)) }
111
111
  attr_accessor :per_unit_cost_basis
112
112
 
113
+ # `void` means the credit block was deleted. A voided block's `balance` is
114
+ # always 0.
113
115
  sig do
114
116
  returns(
115
117
  Orb::Models::CreditBlockListInvoicesResponse::Block::Status::TaggedSymbol
@@ -206,6 +208,8 @@ module Orb
206
208
  # `null`.
207
209
  metadata:,
208
210
  per_unit_cost_basis:,
211
+ # `void` means the credit block was deleted. A voided block's `balance` is
212
+ # always 0.
209
213
  status:,
210
214
  # The credit allocation that funded a block. Extends the allocation resource
211
215
  # serialized on prices with the catalog-item attribution of the funding price.
@@ -445,6 +449,8 @@ module Orb
445
449
  end
446
450
  end
447
451
 
452
+ # `void` means the credit block was deleted. A voided block's `balance` is
453
+ # always 0.
448
454
  module Status
449
455
  extend Orb::Internal::Type::Enum
450
456
 
@@ -467,6 +473,11 @@ module Orb
467
473
  :pending_payment,
468
474
  Orb::Models::CreditBlockListInvoicesResponse::Block::Status::TaggedSymbol
469
475
  )
476
+ VOID =
477
+ T.let(
478
+ :void,
479
+ Orb::Models::CreditBlockListInvoicesResponse::Block::Status::TaggedSymbol
480
+ )
470
481
 
471
482
  sig do
472
483
  override.returns(
@@ -53,6 +53,8 @@ module Orb
53
53
  sig { returns(T.nilable(String)) }
54
54
  attr_accessor :per_unit_cost_basis
55
55
 
56
+ # `void` means the credit block was deleted. A voided block's `balance` is
57
+ # always 0.
56
58
  sig do
57
59
  returns(Orb::Models::CreditBlockRetrieveResponse::Status::TaggedSymbol)
58
60
  end
@@ -140,6 +142,8 @@ module Orb
140
142
  # `null`.
141
143
  metadata:,
142
144
  per_unit_cost_basis:,
145
+ # `void` means the credit block was deleted. A voided block's `balance` is
146
+ # always 0.
143
147
  status:,
144
148
  # The credit allocation that funded a block. Extends the allocation resource
145
149
  # serialized on prices with the catalog-item attribution of the funding price.
@@ -376,6 +380,8 @@ module Orb
376
380
  end
377
381
  end
378
382
 
383
+ # `void` means the credit block was deleted. A voided block's `balance` is
384
+ # always 0.
379
385
  module Status
380
386
  extend Orb::Internal::Type::Enum
381
387
 
@@ -395,6 +401,11 @@ module Orb
395
401
  :pending_payment,
396
402
  Orb::Models::CreditBlockRetrieveResponse::Status::TaggedSymbol
397
403
  )
404
+ VOID =
405
+ T.let(
406
+ :void,
407
+ Orb::Models::CreditBlockRetrieveResponse::Status::TaggedSymbol
408
+ )
398
409
 
399
410
  sig do
400
411
  override.returns(
@@ -48,6 +48,8 @@ module Orb
48
48
  sig { returns(T.nilable(String)) }
49
49
  attr_accessor :per_unit_cost_basis
50
50
 
51
+ # `void` means the credit block was deleted. A voided block's `balance` is
52
+ # always 0.
51
53
  sig do
52
54
  returns(Orb::Models::CreditBlockUpdateResponse::Status::TaggedSymbol)
53
55
  end
@@ -135,6 +137,8 @@ module Orb
135
137
  # `null`.
136
138
  metadata:,
137
139
  per_unit_cost_basis:,
140
+ # `void` means the credit block was deleted. A voided block's `balance` is
141
+ # always 0.
138
142
  status:,
139
143
  # The credit allocation that funded a block. Extends the allocation resource
140
144
  # serialized on prices with the catalog-item attribution of the funding price.
@@ -371,6 +375,8 @@ module Orb
371
375
  end
372
376
  end
373
377
 
378
+ # `void` means the credit block was deleted. A voided block's `balance` is
379
+ # always 0.
374
380
  module Status
375
381
  extend Orb::Internal::Type::Enum
376
382
 
@@ -390,6 +396,11 @@ module Orb
390
396
  :pending_payment,
391
397
  Orb::Models::CreditBlockUpdateResponse::Status::TaggedSymbol
392
398
  )
399
+ VOID =
400
+ T.let(
401
+ :void,
402
+ Orb::Models::CreditBlockUpdateResponse::Status::TaggedSymbol
403
+ )
393
404
 
394
405
  sig do
395
406
  override.returns(
@@ -298,6 +298,8 @@ module Orb
298
298
  sig { returns(T.nilable(String)) }
299
299
  attr_accessor :per_unit_cost_basis
300
300
 
301
+ # `void` means the credit block was deleted. A voided block's `balance` is
302
+ # always 0.
301
303
  sig do
302
304
  returns(
303
305
  Orb::CustomerCreditLedgerIncrementedWebhookEvent::Properties::Block::Status::TaggedSymbol
@@ -394,6 +396,8 @@ module Orb
394
396
  # `null`.
395
397
  metadata:,
396
398
  per_unit_cost_basis:,
399
+ # `void` means the credit block was deleted. A voided block's `balance` is
400
+ # always 0.
397
401
  status:,
398
402
  # The credit allocation that funded a block. Extends the allocation resource
399
403
  # serialized on prices with the catalog-item attribution of the funding price.
@@ -633,6 +637,8 @@ module Orb
633
637
  end
634
638
  end
635
639
 
640
+ # `void` means the credit block was deleted. A voided block's `balance` is
641
+ # always 0.
636
642
  module Status
637
643
  extend Orb::Internal::Type::Enum
638
644
 
@@ -655,6 +661,11 @@ module Orb
655
661
  :pending_payment,
656
662
  Orb::CustomerCreditLedgerIncrementedWebhookEvent::Properties::Block::Status::TaggedSymbol
657
663
  )
664
+ VOID =
665
+ T.let(
666
+ :void,
667
+ Orb::CustomerCreditLedgerIncrementedWebhookEvent::Properties::Block::Status::TaggedSymbol
668
+ )
658
669
 
659
670
  sig do
660
671
  override.returns(
@@ -31,6 +31,15 @@ module Orb
31
31
  sig { returns(T.nilable(T::Hash[Symbol, T.nilable(String)])) }
32
32
  attr_accessor :metadata
33
33
 
34
+ # The status of the metric to create (either active or draft). If not specified,
35
+ # this defaults to active. A draft metric's `sql` and `item_id` can be changed
36
+ # until it's published.
37
+ sig { returns(T.nilable(Orb::MetricCreateParams::Status::OrSymbol)) }
38
+ attr_reader :status
39
+
40
+ sig { params(status: Orb::MetricCreateParams::Status::OrSymbol).void }
41
+ attr_writer :status
42
+
34
43
  sig do
35
44
  params(
36
45
  description: T.nilable(String),
@@ -38,6 +47,7 @@ module Orb
38
47
  name: String,
39
48
  sql: String,
40
49
  metadata: T.nilable(T::Hash[Symbol, T.nilable(String)]),
50
+ status: Orb::MetricCreateParams::Status::OrSymbol,
41
51
  request_options: Orb::RequestOptions::OrHash
42
52
  ).returns(T.attached_class)
43
53
  end
@@ -54,6 +64,10 @@ module Orb
54
64
  # by setting the value to `null`, and the entire metadata mapping can be cleared
55
65
  # by setting `metadata` to `null`.
56
66
  metadata: nil,
67
+ # The status of the metric to create (either active or draft). If not specified,
68
+ # this defaults to active. A draft metric's `sql` and `item_id` can be changed
69
+ # until it's published.
70
+ status: nil,
57
71
  request_options: {}
58
72
  )
59
73
  end
@@ -66,12 +80,35 @@ module Orb
66
80
  name: String,
67
81
  sql: String,
68
82
  metadata: T.nilable(T::Hash[Symbol, T.nilable(String)]),
83
+ status: Orb::MetricCreateParams::Status::OrSymbol,
69
84
  request_options: Orb::RequestOptions
70
85
  }
71
86
  )
72
87
  end
73
88
  def to_hash
74
89
  end
90
+
91
+ # The status of the metric to create (either active or draft). If not specified,
92
+ # this defaults to active. A draft metric's `sql` and `item_id` can be changed
93
+ # until it's published.
94
+ module Status
95
+ extend Orb::Internal::Type::Enum
96
+
97
+ TaggedSymbol =
98
+ T.type_alias { T.all(Symbol, Orb::MetricCreateParams::Status) }
99
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
100
+
101
+ ACTIVE = T.let(:active, Orb::MetricCreateParams::Status::TaggedSymbol)
102
+ DRAFT = T.let(:draft, Orb::MetricCreateParams::Status::TaggedSymbol)
103
+
104
+ sig do
105
+ override.returns(
106
+ T::Array[Orb::MetricCreateParams::Status::TaggedSymbol]
107
+ )
108
+ end
109
+ def self.values
110
+ end
111
+ end
75
112
  end
76
113
  end
77
114
  end
@@ -91,8 +91,8 @@ module Orb
91
91
  OrSymbol = T.type_alias { T.any(Symbol, String) }
92
92
 
93
93
  ACTIVE = T.let(:active, Orb::MetricListParams::Status::TaggedSymbol)
94
- ARCHIVED = T.let(:archived, Orb::MetricListParams::Status::TaggedSymbol)
95
94
  DRAFT = T.let(:draft, Orb::MetricListParams::Status::TaggedSymbol)
95
+ ARCHIVED = T.let(:archived, Orb::MetricListParams::Status::TaggedSymbol)
96
96
 
97
97
  sig do
98
98
  override.returns(
@@ -0,0 +1,33 @@
1
+ # typed: strong
2
+
3
+ module Orb
4
+ module Models
5
+ class MetricPublishParams < Orb::Internal::Type::BaseModel
6
+ extend Orb::Internal::Type::RequestParameters::Converter
7
+ include Orb::Internal::Type::RequestParameters
8
+
9
+ OrHash =
10
+ T.type_alias { T.any(Orb::MetricPublishParams, Orb::Internal::AnyHash) }
11
+
12
+ sig { returns(String) }
13
+ attr_accessor :metric_id
14
+
15
+ sig do
16
+ params(
17
+ metric_id: String,
18
+ request_options: Orb::RequestOptions::OrHash
19
+ ).returns(T.attached_class)
20
+ end
21
+ def self.new(metric_id:, request_options: {})
22
+ end
23
+
24
+ sig do
25
+ override.returns(
26
+ { metric_id: String, request_options: Orb::RequestOptions }
27
+ )
28
+ end
29
+ def to_hash
30
+ end
31
+ end
32
+ end
33
+ end
@@ -16,6 +16,11 @@ module Orb
16
16
  sig { returns(T.nilable(String)) }
17
17
  attr_accessor :description
18
18
 
19
+ # The id of the item to associate the metric with. Can only be changed while the
20
+ # metric is in `draft` status.
21
+ sig { returns(T.nilable(String)) }
22
+ attr_accessor :item_id
23
+
19
24
  # User-specified key/value pairs for the resource. Individual keys can be removed
20
25
  # by setting the value to `null`, and the entire metadata mapping can be cleared
21
26
  # by setting `metadata` to `null`.
@@ -26,12 +31,20 @@ module Orb
26
31
  sig { returns(T.nilable(String)) }
27
32
  attr_accessor :name
28
33
 
34
+ # A new sql string defining the metric. Can only be changed while the metric is in
35
+ # `draft` status and no price uses it. If the metric has parameters, the new sql
36
+ # must use the same ones.
37
+ sig { returns(T.nilable(String)) }
38
+ attr_accessor :sql
39
+
29
40
  sig do
30
41
  params(
31
42
  metric_id: String,
32
43
  description: T.nilable(String),
44
+ item_id: T.nilable(String),
33
45
  metadata: T.nilable(T::Hash[Symbol, T.nilable(String)]),
34
46
  name: T.nilable(String),
47
+ sql: T.nilable(String),
35
48
  request_options: Orb::RequestOptions::OrHash
36
49
  ).returns(T.attached_class)
37
50
  end
@@ -39,12 +52,19 @@ module Orb
39
52
  metric_id:,
40
53
  # A description of the metric.
41
54
  description: nil,
55
+ # The id of the item to associate the metric with. Can only be changed while the
56
+ # metric is in `draft` status.
57
+ item_id: nil,
42
58
  # User-specified key/value pairs for the resource. Individual keys can be removed
43
59
  # by setting the value to `null`, and the entire metadata mapping can be cleared
44
60
  # by setting `metadata` to `null`.
45
61
  metadata: nil,
46
62
  # The name of the metric.
47
63
  name: nil,
64
+ # A new sql string defining the metric. Can only be changed while the metric is in
65
+ # `draft` status and no price uses it. If the metric has parameters, the new sql
66
+ # must use the same ones.
67
+ sql: nil,
48
68
  request_options: {}
49
69
  )
50
70
  end
@@ -54,8 +74,10 @@ module Orb
54
74
  {
55
75
  metric_id: String,
56
76
  description: T.nilable(String),
77
+ item_id: T.nilable(String),
57
78
  metadata: T.nilable(T::Hash[Symbol, T.nilable(String)]),
58
79
  name: T.nilable(String),
80
+ sql: T.nilable(String),
59
81
  request_options: Orb::RequestOptions
60
82
  }
61
83
  )
@@ -742,6 +742,10 @@ module Orb
742
742
  sig { returns(Integer) }
743
743
  attr_accessor :order
744
744
 
745
+ # The IDs of the prices active in this phase.
746
+ sig { returns(T::Array[String]) }
747
+ attr_accessor :price_ids
748
+
745
749
  sig do
746
750
  params(
747
751
  id: String,
@@ -764,7 +768,8 @@ module Orb
764
768
  minimum: T.nilable(Orb::Minimum::OrHash),
765
769
  minimum_amount: T.nilable(String),
766
770
  name: String,
767
- order: Integer
771
+ order: Integer,
772
+ price_ids: T::Array[String]
768
773
  ).returns(T.attached_class)
769
774
  end
770
775
  def self.new(
@@ -781,7 +786,9 @@ module Orb
781
786
  minimum_amount:,
782
787
  name:,
783
788
  # Determines the ordering of the phase in a plan's lifecycle. 1 = first phase.
784
- order:
789
+ order:,
790
+ # The IDs of the prices active in this phase.
791
+ price_ids:
785
792
  )
786
793
  end
787
794
 
@@ -799,7 +806,8 @@ module Orb
799
806
  minimum: T.nilable(Orb::Minimum),
800
807
  minimum_amount: T.nilable(String),
801
808
  name: String,
802
- order: Integer
809
+ order: Integer,
810
+ price_ids: T::Array[String]
803
811
  }
804
812
  )
805
813
  end