xai-sdk 0.10.0

Lightweight SDK for xAI's gRPC APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
// This file is @generated by prost-build.
/// Request to set the billing information on the team.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetBillingInfoReq {
    /// Team ID of the team.
    #[prost(string, tag = "1")]
    pub team_id: ::prost::alloc::string::String,
    /// Billing information for the team to set.
    #[prost(message, optional, tag = "10")]
    pub billing_info: ::core::option::Option<super::prod_charger::BillingInfo>,
}
/// Response of setting the billing information on the team.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetBillingInfoResp {}
/// Request for getting billing information.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetBillingInfoReq {
    /// Team ID of the team.
    #[prost(string, tag = "1")]
    pub team_id: ::prost::alloc::string::String,
}
/// Response containing the billing information of the team.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetBillingInfoResp {
    /// Billing information of the team.
    #[prost(message, optional, tag = "10")]
    pub billing_info: ::core::option::Option<super::prod_charger::BillingInfo>,
}
/// List payment methods that belong to the team.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListPaymentMethodsReq {
    /// Team ID of the team.
    #[prost(string, tag = "10")]
    pub team_id: ::prost::alloc::string::String,
}
/// Represents an incomplete attempt to add a payment method.
/// Might resolve into a payment method.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PendingPaymentMethod {
    /// Verification URL for ACH micro deposits that verifies the account.
    #[prost(string, tag = "10")]
    pub ach_microdeposit_hosted_verification_url: ::prost::alloc::string::String,
}
/// Response containing a list of payment methods for the team.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListPaymentMethodsResp {
    /// Payment methods on file.
    #[prost(message, repeated, tag = "10")]
    pub payment_methods: ::prost::alloc::vec::Vec<super::prod_charger::PaymentMethod>,
    /// Pending payment method.
    #[prost(message, optional, tag = "21")]
    pub pending_payment_method: ::core::option::Option<PendingPaymentMethod>,
}
/// Request to set default payment method on a team.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetDefaultPaymentMethodReq {
    /// Team ID of the team.
    #[prost(string, tag = "10")]
    pub team_id: ::prost::alloc::string::String,
    /// ID of the payment method that you want to set as default.
    #[prost(string, tag = "20")]
    pub payment_method_id: ::prost::alloc::string::String,
}
/// Response to setting default payment method.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetDefaultPaymentMethodResp {}
/// Each line on the invoice.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Line {
    /// The cluster on which the resource is consumed.
    #[prost(string, tag = "1")]
    pub cluster_name: ::prost::alloc::string::String,
    /// The description of the line item.
    #[prost(string, tag = "2")]
    pub description: ::prost::alloc::string::String,
    /// The unit in which the price is measured.
    #[prost(string, tag = "3")]
    pub unit_type: ::prost::alloc::string::String,
    /// The price per unit (1/1_000_000 USD cents).
    #[prost(int64, tag = "4")]
    pub unit_price: i64,
    /// The number of units.
    #[prost(int64, tag = "5")]
    pub num_units: i64,
    /// Total amount of the line item (USD cents).
    #[prost(int64, tag = "6")]
    pub amount: i64,
}
/// The invoice object.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CoreInvoice {
    /// Line items on the invoice.
    #[prost(message, repeated, tag = "1")]
    pub lines: ::prost::alloc::vec::Vec<Line>,
    /// Amount before VAT (USD cents).
    #[prost(int64, tag = "2")]
    pub amount_before_vat: i64,
    /// VAT (USD cents).
    #[prost(int64, tag = "3")]
    pub vat_cost: i64,
    /// Total amount after VAT (USD cents).
    #[prost(int64, tag = "4")]
    pub amount_after_vat: i64,
    /// Automatically issued credits (USD cents).
    #[prost(int64, tag = "5")]
    pub auto_credits_issued: i64,
    /// Default credit issued (USD cents).
    #[prost(int64, tag = "6")]
    pub default_credits_issued: i64,
    /// Total amount (USD cents).
    #[prost(message, optional, tag = "9")]
    pub total_with_corr: ::core::option::Option<super::prod_charger::Cent>,
    /// Total prepaid credits in the team before the invoice.
    #[prost(message, optional, tag = "8")]
    pub prepaid_credits: ::core::option::Option<super::prod_charger::Cent>,
    /// Prepaid credits used to pay for the invoice.
    #[prost(message, optional, tag = "7")]
    pub prepaid_credits_used: ::core::option::Option<super::prod_charger::Cent>,
}
/// Request to get the payment amount of current month's monthly invoice.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetAmountToPayReq {
    /// Team ID of the team.
    #[prost(string, tag = "10")]
    pub team_id: ::prost::alloc::string::String,
}
/// Response of the payment amount of current month's monthly invoice.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetAmountToPayResp {
    /// The current partial invoice.
    #[prost(message, optional, tag = "1")]
    pub core_invoice: ::core::option::Option<CoreInvoice>,
    /// The effective current spending limit in USD cents.
    #[prost(int64, tag = "2")]
    pub effective_spending_limit: i64,
    /// The current default credits in USD cents.
    #[prost(int64, tag = "3")]
    pub default_credits: i64,
    /// The current billing cycle whose invoice data is reported here.
    #[prost(message, optional, tag = "4")]
    pub billing_cycle: ::core::option::Option<BillingCycle>,
}
/// Request to get historical API usage.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AnalyzeBillingItemsRequest {
    /// The actual analysis request.
    #[prost(message, optional, tag = "1")]
    pub analytics_request: ::core::option::Option<
        super::prod::clickhouse_analytics::AnalyticsRequest,
    >,
    /// The team whose billing records to analyze.
    #[prost(string, tag = "2")]
    pub team_id: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BillingCycle {
    #[prost(int32, tag = "1")]
    pub year: i32,
    #[prost(int32, tag = "2")]
    pub month: i32,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ChargerAttempt {
    #[prost(int32, tag = "10")]
    pub ticket: i32,
    #[prost(bool, tag = "20")]
    pub successful: bool,
    /// The payment method that was tried in this attempt.
    #[prost(string, tag = "30")]
    pub payment_method_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MonthlyInvoiceBundle {
    /// The billing cycle the invoice applies to.
    #[prost(message, optional, tag = "10")]
    pub billing_cycle: ::core::option::Option<BillingCycle>,
    /// Default credits applied to the invoice.
    #[prost(message, optional, tag = "20")]
    pub default_credits_issued: ::core::option::Option<super::prod_charger::Cent>,
    /// Automatically issued credits.
    #[prost(message, optional, tag = "30")]
    pub auto_credits_issued: ::core::option::Option<super::prod_charger::Cent>,
    /// Prepaid token on file to be spent.
    #[prost(message, optional, tag = "35")]
    pub prepaid_tokens_to_spend: ::core::option::Option<super::prod_charger::Cent>,
    /// The billing items csv file suffix, used by xAI processes.
    #[prost(string, optional, tag = "40")]
    pub billing_items_csv_asset_key_suffix: ::core::option::Option<
        ::prost::alloc::string::String,
    >,
    /// The billing items corrections csv file suffix, used by xAI processes.
    #[prost(string, optional, tag = "50")]
    pub corrections_csv_asset_key_suffix: ::core::option::Option<
        ::prost::alloc::string::String,
    >,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PrepaidInvoiceBundle {}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SubscriptionsInvoiceBundle {}
/// Invoice item.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InvoiceBundle {
    /// The Team ID.
    #[prost(string, tag = "10")]
    pub team_id: ::prost::alloc::string::String,
    /// The Invoice ID.
    #[prost(string, tag = "20")]
    pub invoice_id: ::prost::alloc::string::String,
    /// The Invoice number.
    #[prost(string, tag = "21")]
    pub invoice_number: ::prost::alloc::string::String,
    /// The creation time of the invoice.
    #[prost(message, optional, tag = "31")]
    pub create_time: ::core::option::Option<::prost_types::Timestamp>,
    /// The status of the invoice.
    #[prost(enumeration = "invoice_bundle::Status", tag = "40")]
    pub invoice_status: i32,
    /// When customer is expected to be charged.
    #[prost(message, optional, tag = "50")]
    pub first_desired_next_cycle_ts: ::core::option::Option<::prost_types::Timestamp>,
    #[prost(message, repeated, tag = "60")]
    pub charger_attempts: ::prost::alloc::vec::Vec<ChargerAttempt>,
    /// List of items composing the invoice.
    #[prost(message, repeated, tag = "70")]
    pub lines: ::prost::alloc::vec::Vec<Line>,
    /// Sub-total of the invoice containing all the cost
    #[prost(int64, tag = "80")]
    pub subtotal: i64,
    /// without taxes in USD cents.
    #[prost(int64, tag = "90")]
    pub tax: i64,
    /// Total due for the invoice taxes included in USD cents.
    #[prost(int64, tag = "100")]
    pub total: i64,
    /// The invoice pdf suffix.
    #[prost(string, tag = "110")]
    pub invoice_pdf_asset_key_suffix: ::prost::alloc::string::String,
    /// Type of the invoice.
    #[prost(oneof = "invoice_bundle::Flavour", tags = "120, 130, 140")]
    pub flavour: ::core::option::Option<invoice_bundle::Flavour>,
}
/// Nested message and enum types in `InvoiceBundle`.
pub mod invoice_bundle {
    /// Charging status of the invoice.
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Status {
        Invalid = 0,
        Pending = 1,
        Paid = 2,
        WillNeverBeCharged = 3,
        Failed = 4,
    }
    impl Status {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Invalid => "INVALID",
                Self::Pending => "PENDING",
                Self::Paid => "PAID",
                Self::WillNeverBeCharged => "WILL_NEVER_BE_CHARGED",
                Self::Failed => "FAILED",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "INVALID" => Some(Self::Invalid),
                "PENDING" => Some(Self::Pending),
                "PAID" => Some(Self::Paid),
                "WILL_NEVER_BE_CHARGED" => Some(Self::WillNeverBeCharged),
                "FAILED" => Some(Self::Failed),
                _ => None,
            }
        }
    }
    /// Type of the invoice.
    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
    pub enum Flavour {
        #[prost(message, tag = "120")]
        Monthly(super::MonthlyInvoiceBundle),
        #[prost(message, tag = "130")]
        Prepaid(super::PrepaidInvoiceBundle),
        #[prost(message, tag = "140")]
        Subscriptions(super::SubscriptionsInvoiceBundle),
    }
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct InvoiceIds {
    #[prost(string, repeated, tag = "10")]
    pub invoice_ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
/// Request to list invoices.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListInvoicesReq {
    /// Team ID of the team.
    #[prost(string, tag = "10")]
    pub team_id: ::prost::alloc::string::String,
    #[prost(oneof = "list_invoices_req::Filter", tags = "20, 30, 40")]
    pub filter: ::core::option::Option<list_invoices_req::Filter>,
}
/// Nested message and enum types in `ListInvoicesReq`.
pub mod list_invoices_req {
    #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
    pub enum Filter {
        /// Specific billing cycle to retrieve.
        #[prost(message, tag = "20")]
        BillingCycle(super::BillingCycle),
        /// Specify since which billing cycle to retrieve.
        #[prost(message, tag = "30")]
        Since(super::BillingCycle),
        /// List invoices by ids
        #[prost(message, tag = "40")]
        InvoiceIds(super::InvoiceIds),
    }
}
/// Response containing invoices.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListInvoicesResp {
    /// Invoices.
    #[prost(message, repeated, tag = "1")]
    pub invoices: ::prost::alloc::vec::Vec<InvoiceBundle>,
}
/// Change item on the prepaid credit balance.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct PrepaidBalanceChange {
    /// The team ID.
    #[prost(string, tag = "10")]
    pub team_id: ::prost::alloc::string::String,
    /// The reason for the change
    #[prost(enumeration = "prepaid_balance_change::ChangeOrigin", tag = "20")]
    pub change_origin: i32,
    /// Status of the top up.
    #[prost(enumeration = "prepaid_balance_change::TopUpStatus", optional, tag = "30")]
    pub topup_status: ::core::option::Option<i32>,
    /// Amount in USD cents.
    #[prost(message, optional, tag = "40")]
    pub amount: ::core::option::Option<super::prod_charger::Cent>,
    /// Invoice ID.
    #[prost(string, optional, tag = "50")]
    pub invoice_id: ::core::option::Option<::prost::alloc::string::String>,
    /// Invoice number.
    #[prost(string, optional, tag = "51")]
    pub invoice_number: ::core::option::Option<::prost::alloc::string::String>,
    /// Creation time of the invoice.
    #[prost(message, optional, tag = "60")]
    pub create_time: ::core::option::Option<::prost_types::Timestamp>,
    /// Calendar year the purchase is made in.
    #[prost(int32, optional, tag = "70")]
    pub spend_bp_key_year: ::core::option::Option<i32>,
    /// Calendar month the purchase is made in.
    #[prost(int32, optional, tag = "80")]
    pub spend_bp_key_month: ::core::option::Option<i32>,
    /// Creation timestamp.
    #[prost(message, optional, tag = "85")]
    pub create_ts: ::core::option::Option<::prost_types::Timestamp>,
}
/// Nested message and enum types in `PrepaidBalanceChange`.
pub mod prepaid_balance_change {
    /// The reason for the change.
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum ChangeOrigin {
        InvalidOrigin = 0,
        /// Purchase by user. `amount` field will be negative.
        Purchase = 10,
        /// Spending by user. `amount` field will be positive.
        Spend = 20,
        /// A refund issued to user. `amount` field will be negative.
        Refund = 30,
        /// Can be either positive or negative, performed by xAI staff.
        Manual = 40,
    }
    impl ChangeOrigin {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::InvalidOrigin => "INVALID_ORIGIN",
                Self::Purchase => "PURCHASE",
                Self::Spend => "SPEND",
                Self::Refund => "REFUND",
                Self::Manual => "MANUAL",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "INVALID_ORIGIN" => Some(Self::InvalidOrigin),
                "PURCHASE" => Some(Self::Purchase),
                "SPEND" => Some(Self::Spend),
                "REFUND" => Some(Self::Refund),
                "MANUAL" => Some(Self::Manual),
                _ => None,
            }
        }
    }
    /// Status of the top up.
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum TopUpStatus {
        InvalidStatus = 0,
        ToGenerateInvoice = 10,
        FailedToGenerateInvoice = 20,
        ToCharge = 30,
        FailedToCharge = 40,
        Succeeded = 50,
    }
    impl TopUpStatus {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::InvalidStatus => "INVALID_STATUS",
                Self::ToGenerateInvoice => "TO_GENERATE_INVOICE",
                Self::FailedToGenerateInvoice => "FAILED_TO_GENERATE_INVOICE",
                Self::ToCharge => "TO_CHARGE",
                Self::FailedToCharge => "FAILED_TO_CHARGE",
                Self::Succeeded => "SUCCEEDED",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "INVALID_STATUS" => Some(Self::InvalidStatus),
                "TO_GENERATE_INVOICE" => Some(Self::ToGenerateInvoice),
                "FAILED_TO_GENERATE_INVOICE" => Some(Self::FailedToGenerateInvoice),
                "TO_CHARGE" => Some(Self::ToCharge),
                "FAILED_TO_CHARGE" => Some(Self::FailedToCharge),
                "SUCCEEDED" => Some(Self::Succeeded),
                _ => None,
            }
        }
    }
}
/// Request to list prepaid credit balance.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ListPrepaidBalanceChangesReq {
    /// The team ID of the team.
    #[prost(string, tag = "10")]
    pub team_id: ::prost::alloc::string::String,
}
/// Response for prepaid credit balance.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListPrepaidBalanceChangesResp {
    /// The changes of the prepaid credit balance.
    #[prost(message, repeated, tag = "10")]
    pub changes: ::prost::alloc::vec::Vec<PrepaidBalanceChange>,
    /// The team's currently available prepaid credits (excluding pending
    /// charges).
    #[prost(message, optional, tag = "20")]
    pub total: ::core::option::Option<super::prod_charger::Cent>,
}
/// Top up prepaid credit request.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TopUpOrGetExistingPendingChangeReq {
    /// Team ID of the team to top up for.
    #[prost(string, tag = "10")]
    pub team_id: ::prost::alloc::string::String,
    /// Amount of prepaid credit to top up. Can be any integer and we will disregard the sign.
    #[prost(message, optional, tag = "20")]
    pub amount: ::core::option::Option<super::prod_charger::Cent>,
}
/// Response for prepaid credit top up.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TopUpOrGetExistingPendingChangeResp {
    #[prost(message, optional, tag = "10")]
    pub change: ::core::option::Option<PrepaidBalanceChange>,
}
/// Request to get postpaid monthly spending limit.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetSpendingLimitsReq {
    #[prost(string, tag = "1")]
    pub team_id: ::prost::alloc::string::String,
}
/// Postpaid monthly spending limit.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SpendingLimits {
    /// Optional spending limit override set by xAI staff.
    #[prost(message, optional, tag = "1")]
    pub hard_sl_override: ::core::option::Option<super::prod_charger::Cent>,
    /// Automatically calculated hard spending limit (the maximum monthly invoiced spending limit that can be set by the
    /// user).
    #[prost(message, optional, tag = "2")]
    pub hard_sl_auto: ::core::option::Option<super::prod_charger::Cent>,
    /// Effective hard spending limit. Takes into account `hard_sl_override` and `hard_sl_auto`. User can set a soft
    /// spending limit lower than this.
    #[prost(message, optional, tag = "5")]
    pub effective_hard_sl: ::core::option::Option<super::prod_charger::Cent>,
    /// The soft spending limit previously set by customer. Zero if it has not been set.
    #[prost(message, optional, tag = "3")]
    pub soft_sl: ::core::option::Option<super::prod_charger::Cent>,
    /// Final monthly invoiced spending limit that xAI API will enforce.
    #[prost(message, optional, tag = "4")]
    pub effective_sl: ::core::option::Option<super::prod_charger::Cent>,
}
/// Response for postpaid monthly spending limit.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetSpendingLimitsResp {
    #[prost(message, optional, tag = "1")]
    pub spending_limits: ::core::option::Option<SpendingLimits>,
}
/// Request by user to set a new postpaid monthly spending limit.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetSoftSpendingLimitReq {
    /// Team ID.
    #[prost(string, tag = "1")]
    pub team_id: ::prost::alloc::string::String,
    /// Desired spending limit in USD cents.
    #[prost(message, optional, tag = "2")]
    pub desired_soft_spending_limit: ::core::option::Option<super::prod_charger::Cent>,
}
/// Response of setting a new postpaid monthly spending limit.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SetSoftSpendingLimitResp {
    /// The new spending limit in USD cents.
    #[prost(message, optional, tag = "1")]
    pub this_bp_soft_spending_limit: ::core::option::Option<super::prod_charger::Cent>,
}
/// Generated client implementations.
pub mod ui_svc_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value,
    )]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// gRPC API service to interact with the xAI billing system.
    #[derive(Debug, Clone)]
    pub struct UiSvcClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl UiSvcClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> UiSvcClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> UiSvcClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::Body>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::Body>,
            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            UiSvcClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// Set billing information of a team.
        pub async fn set_billing_info(
            &mut self,
            request: impl tonic::IntoRequest<super::SetBillingInfoReq>,
        ) -> std::result::Result<
            tonic::Response<super::SetBillingInfoResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/SetBillingInfo",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("prod_mc_billing.UISvc", "SetBillingInfo"));
            self.inner.unary(req, path, codec).await
        }
        /// Get billing information of the team with given team ID.
        pub async fn get_billing_info(
            &mut self,
            request: impl tonic::IntoRequest<super::GetBillingInfoReq>,
        ) -> std::result::Result<
            tonic::Response<super::GetBillingInfoResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/GetBillingInfo",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("prod_mc_billing.UISvc", "GetBillingInfo"));
            self.inner.unary(req, path, codec).await
        }
        /// List payment methods of a team. You can add or delete the payment methods on https://console.x.ai.
        pub async fn list_payment_methods(
            &mut self,
            request: impl tonic::IntoRequest<super::ListPaymentMethodsReq>,
        ) -> std::result::Result<
            tonic::Response<super::ListPaymentMethodsResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/ListPaymentMethods",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("prod_mc_billing.UISvc", "ListPaymentMethods"));
            self.inner.unary(req, path, codec).await
        }
        /// Set default payment method to an existing payment method on file.
        pub async fn set_default_payment_method(
            &mut self,
            request: impl tonic::IntoRequest<super::SetDefaultPaymentMethodReq>,
        ) -> std::result::Result<
            tonic::Response<super::SetDefaultPaymentMethodResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/SetDefaultPaymentMethod",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new("prod_mc_billing.UISvc", "SetDefaultPaymentMethod"),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Preview the amount to pay for postpaid usage in the current billing period.
        pub async fn get_amount_to_pay(
            &mut self,
            request: impl tonic::IntoRequest<super::GetAmountToPayReq>,
        ) -> std::result::Result<
            tonic::Response<super::GetAmountToPayResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/GetAmountToPay",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("prod_mc_billing.UISvc", "GetAmountToPay"));
            self.inner.unary(req, path, codec).await
        }
        /// Get historical usage of the API over a time period, aggregated by fields.
        pub async fn analyze_billing_items(
            &mut self,
            request: impl tonic::IntoRequest<super::AnalyzeBillingItemsRequest>,
        ) -> std::result::Result<
            tonic::Response<super::super::prod::clickhouse_analytics::AnalyticsResponse>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/AnalyzeBillingItems",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("prod_mc_billing.UISvc", "AnalyzeBillingItems"));
            self.inner.unary(req, path, codec).await
        }
        /// List invoices that belong to a team.
        pub async fn list_invoices(
            &mut self,
            request: impl tonic::IntoRequest<super::ListInvoicesReq>,
        ) -> std::result::Result<
            tonic::Response<super::ListInvoicesResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/ListInvoices",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("prod_mc_billing.UISvc", "ListInvoices"));
            self.inner.unary(req, path, codec).await
        }
        /// List the prepaid credit balance and balance changes of a team.
        pub async fn list_prepaid_balance_changes(
            &mut self,
            request: impl tonic::IntoRequest<super::ListPrepaidBalanceChangesReq>,
        ) -> std::result::Result<
            tonic::Response<super::ListPrepaidBalanceChangesResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/ListPrepaidBalanceChanges",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new("prod_mc_billing.UISvc", "ListPrepaidBalanceChanges"),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Top up prepaid credit using the default payment method.
        pub async fn top_up_or_get_existing_pending_change(
            &mut self,
            request: impl tonic::IntoRequest<super::TopUpOrGetExistingPendingChangeReq>,
        ) -> std::result::Result<
            tonic::Response<super::TopUpOrGetExistingPendingChangeResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/TopUpOrGetExistingPendingChange",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "prod_mc_billing.UISvc",
                        "TopUpOrGetExistingPendingChange",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
        /// Get the postpaid monthly spending limits. The API will stop functioning once the team has consumed all of the
        /// prepaid credits, and the postpaid usage amount has reached the user-set soft spending limit.
        pub async fn get_spending_limits(
            &mut self,
            request: impl tonic::IntoRequest<super::GetSpendingLimitsReq>,
        ) -> std::result::Result<
            tonic::Response<super::GetSpendingLimitsResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/GetSpendingLimits",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(GrpcMethod::new("prod_mc_billing.UISvc", "GetSpendingLimits"));
            self.inner.unary(req, path, codec).await
        }
        /// Set the postpaid monthly spending limit of a team. This can be used to restrict the maximum amount of postpaid API
        /// usage. Note this will not limit the amount of prepaid credit usage, and prepaid credits will always be consumed
        /// before accruing postpaid usage. To use only prepaid credits, you can set this limit to 0.
        pub async fn set_soft_spending_limit(
            &mut self,
            request: impl tonic::IntoRequest<super::SetSoftSpendingLimitReq>,
        ) -> std::result::Result<
            tonic::Response<super::SetSoftSpendingLimitResp>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::unknown(
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/prod_mc_billing.UISvc/SetSoftSpendingLimit",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new("prod_mc_billing.UISvc", "SetSoftSpendingLimit"),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}