Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ awaited, a `Page` that dereferences to the body (`page.field`) and lists `page.i
`next_page()`; `.items()` streams every item across pages and `.pages()` every page. Models are
in [`src/models`](src/models), and the options structs next to their resource.

[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Budgets](#budgets) · [Checkout sessions](#checkout-sessions) · [Checks](#checks) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Credit units](#credit-units) · [Credit units prices](#credit-units-prices) · [Credits](#credits) · [Credits grants](#credits-grants) · [Credits wallets](#credits-wallets) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Licenses](#licenses) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Usage customer](#usage-customer) · [Usage costs](#usage-costs) · [Usage costs customer](#usage-costs-customer) · [Usage costs subscription](#usage-costs-subscription) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints)
[Add ons](#add-ons) · [Add ons entitlements](#add-ons-entitlements) · [Batch jobs](#batch-jobs) · [Budgets](#budgets) · [Checkout sessions](#checkout-sessions) · [Checks](#checks) · [Connect](#connect) · [Coupons](#coupons) · [Credit notes](#credit-notes) · [Credit units](#credit-units) · [Credit units prices](#credit-units-prices) · [Credits](#credits) · [Credits grants](#credits-grants) · [Credits wallets](#credits-wallets) · [Custom properties](#custom-properties) · [Customers](#customers) · [Entitlements](#entitlements) · [Events](#events) · [Features](#features) · [Invoices](#invoices) · [Invoices payments](#invoices-payments) · [Licenses](#licenses) · [Metrics](#metrics) · [Oauth](#oauth) · [Oauth apps](#oauth-apps) · [Plans](#plans) · [Plans versions](#plans-versions) · [Product families](#product-families) · [Products](#products) · [Products entitlements](#products-entitlements) · [Subscriptions](#subscriptions) · [Usage](#usage) · [Usage customer](#usage-customer) · [Usage costs](#usage-costs) · [Usage costs customer](#usage-costs-customer) · [Usage costs subscription](#usage-costs-subscription) · [Webhook endpoints](#webhook-endpoints) · [Webhook endpoints endpoints](#webhook-endpoints-endpoints)

## Add ons

Expand Down Expand Up @@ -230,9 +230,20 @@ in [`src/models`](src/models), and the options structs next to their resource.
| `client.invoices().retrieve(invoice_id: &str) -> Call<Invoice>` | `GET /api/v1/invoices/{invoice_id}` | [`Invoice`](src/models/invoice.rs) |
| `client.invoices().update_custom_properties(invoice_id: &str, invoice_custom_properties_request: InvoiceCustomPropertiesRequest) -> Call<Invoice>` | `PATCH /api/v1/invoices/{invoice_id}/custom-properties` | [`Invoice`](src/models/invoice.rs) |
| `client.invoices().download(invoice_id: &str) -> Call<Bytes>` | `GET /api/v1/invoices/{invoice_id}/download` | bytes |
| `client.invoices().mark_paid(invoice_id: &str, record_invoice_payment_request: RecordInvoicePaymentRequest, options: InvoicesMarkPaidOptions) -> Call<Transaction>` | `POST /api/v1/invoices/{invoice_id}/mark-paid` | [`Transaction`](src/models/transaction.rs) |
| `client.invoices().mark_uncollectible(invoice_id: &str, options: InvoicesMarkUncollectibleOptions) -> Call<()>` | `POST /api/v1/invoices/{invoice_id}/mark-uncollectible` | nothing |
| `client.invoices().refresh(invoice_id: &str) -> Call<Invoice>` | `POST /api/v1/invoices/{invoice_id}/refresh` | [`Invoice`](src/models/invoice.rs) |
| `client.invoices().download_xml(invoice_id: &str) -> Call<Bytes>` | `GET /api/v1/invoices/{invoice_id}/xml` | bytes |

### Invoices payments

[`client.invoices().payments()`](src/api/invoices_payments.rs)

| Method | Request | Returns |
| --- | --- | --- |
| `client.invoices().payments().create(invoice_id: &str, record_invoice_payment_request: RecordInvoicePaymentRequest, options: InvoicesPaymentsCreateOptions) -> Call<Transaction>` | `POST /api/v1/invoices/{invoice_id}/payments` | [`Transaction`](src/models/transaction.rs) |
| `client.invoices().payments().reverse(invoice_id: &str, transaction_id: &str, reverse_invoice_payment_request: ReverseInvoicePaymentRequest, options: InvoicesPaymentsReverseOptions) -> Call<Transaction>` | `POST /api/v1/invoices/{invoice_id}/payments/{transaction_id}/reverse` | [`Transaction`](src/models/transaction.rs) |

## Licenses

[`client.licenses()`](src/api/licenses.rs)
Expand Down
105 changes: 105 additions & 0 deletions src/api/invoices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,44 @@ impl InvoicesListOptions {
}
}

/// Query and header parameters of [`Invoices::mark_paid`], built
/// with the required ones by [`new`](Self::new).
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct InvoicesMarkPaidOptions {
/// The `Idempotency-Key` header parameter.
pub idempotency_key: String,
}

impl InvoicesMarkPaidOptions {
/// Options with the required parameters set.
#[must_use]
pub fn new(idempotency_key: impl Into<String>) -> Self {
Self {
idempotency_key: idempotency_key.into(),
}
}
}

/// Query and header parameters of [`Invoices::mark_uncollectible`], built
/// with the required ones by [`new`](Self::new).
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct InvoicesMarkUncollectibleOptions {
/// The `Idempotency-Key` header parameter.
pub idempotency_key: String,
}

impl InvoicesMarkUncollectibleOptions {
/// Options with the required parameters set.
#[must_use]
pub fn new(idempotency_key: impl Into<String>) -> Self {
Self {
idempotency_key: idempotency_key.into(),
}
}
}

/// The invoices API, from the client's
/// [`invoices`](crate::api::Meteroid::invoices).
#[derive(Clone)]
Expand Down Expand Up @@ -171,6 +209,12 @@ impl Invoices {
self
}

/// The payments API, with the options of this one.
#[must_use]
pub fn payments(&self) -> super::InvoicesPayments {
super::InvoicesPayments::new(self.cfg.clone()).with_options(self.options.clone())
}

fn list_request(
&self,
options: impl Into<Option<InvoicesListOptions>>,
Expand Down Expand Up @@ -301,6 +345,67 @@ impl Invoices {
.binary(&self.cfg)
}

/// Mark an invoice as paid
///
/// Record an external payment for the entire remaining balance of a finalized invoice. The amount
/// must match the remaining balance.
///
/// `POST /api/v1/invoices/{invoice_id}/mark-paid`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429, 500).
pub fn mark_paid(
&self,
invoice_id: impl Into<crate::models::InvoiceId>,
record_invoice_payment_request: crate::models::RecordInvoicePaymentRequest,
options: InvoicesMarkPaidOptions,
) -> crate::api::Call<crate::models::Transaction> {
let InvoicesMarkPaidOptions { idempotency_key } = options;

crate::request::Request::new(
http::Method::POST,
"/api/v1/invoices/{invoice_id}/mark-paid",
)
.with_path_param(
"invoice_id",
Into::<crate::models::InvoiceId>::into(invoice_id),
)
.with_header_param("Idempotency-Key", &idempotency_key)
.with_body_param(record_invoice_payment_request)
.with_options(&self.options)
.json(&self.cfg)
}

/// Mark an invoice as uncollectible
///
/// Transition a finalized invoice to uncollectible and stop its payment reminders.
///
/// `POST /api/v1/invoices/{invoice_id}/mark-uncollectible`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429, 500).
pub fn mark_uncollectible(
&self,
invoice_id: impl Into<crate::models::InvoiceId>,
options: InvoicesMarkUncollectibleOptions,
) -> crate::api::Call<()> {
let InvoicesMarkUncollectibleOptions { idempotency_key } = options;

crate::request::Request::new(
http::Method::POST,
"/api/v1/invoices/{invoice_id}/mark-uncollectible",
)
.with_path_param(
"invoice_id",
Into::<crate::models::InvoiceId>::into(invoice_id),
)
.with_header_param("Idempotency-Key", &idempotency_key)
.with_options(&self.options)
.empty(&self.cfg)
}

/// Refresh invoice
///
/// Recompute a draft invoice against current usage, credits, coupons and tax, and return it.
Expand Down
141 changes: 141 additions & 0 deletions src/api/invoices_payments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// this file is @generated
#![allow(clippy::doc_markdown, clippy::default_trait_access)]

#[allow(unused_imports, clippy::wildcard_imports)]
use crate::{error::Result, models::*, Configuration};

/// Query and header parameters of [`InvoicesPayments::create`], built
/// with the required ones by [`new`](Self::new).
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct InvoicesPaymentsCreateOptions {
/// The `Idempotency-Key` header parameter.
pub idempotency_key: String,
}

impl InvoicesPaymentsCreateOptions {
/// Options with the required parameters set.
#[must_use]
pub fn new(idempotency_key: impl Into<String>) -> Self {
Self {
idempotency_key: idempotency_key.into(),
}
}
}

/// Query and header parameters of [`InvoicesPayments::reverse`], built
/// with the required ones by [`new`](Self::new).
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct InvoicesPaymentsReverseOptions {
/// The `Idempotency-Key` header parameter.
pub idempotency_key: String,
}

impl InvoicesPaymentsReverseOptions {
/// Options with the required parameters set.
#[must_use]
pub fn new(idempotency_key: impl Into<String>) -> Self {
Self {
idempotency_key: idempotency_key.into(),
}
}
}

/// The invoices payments API, from
/// [`Invoices::payments`](crate::api::Invoices::payments).
#[derive(Clone)]
pub struct InvoicesPayments {
cfg: std::sync::Arc<Configuration>,
options: crate::api::RequestOptions,
}

impl std::fmt::Debug for InvoicesPayments {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("InvoicesPayments")
.field("options", &self.options)
.finish_non_exhaustive()
}
}

impl InvoicesPayments {
pub(super) fn new(cfg: std::sync::Arc<Configuration>) -> Self {
Self {
cfg,
options: crate::api::RequestOptions::default(),
}
}

/// Applies `options` (headers, timeout, retries, idempotency key) to the calls made
/// through the returned value.
#[must_use]
pub fn with_options(mut self, options: crate::api::RequestOptions) -> Self {
self.options = options;
self
}

/// Record an invoice payment
///
/// Record a partial or full payment received outside Meteroid against a finalized invoice.
/// Paying the remaining balance marks the invoice paid.
///
/// `POST /api/v1/invoices/{invoice_id}/payments`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429, 500).
pub fn create(
&self,
invoice_id: impl Into<crate::models::InvoiceId>,
record_invoice_payment_request: crate::models::RecordInvoicePaymentRequest,
options: InvoicesPaymentsCreateOptions,
) -> crate::api::Call<crate::models::Transaction> {
let InvoicesPaymentsCreateOptions { idempotency_key } = options;

crate::request::Request::new(http::Method::POST, "/api/v1/invoices/{invoice_id}/payments")
.with_path_param(
"invoice_id",
Into::<crate::models::InvoiceId>::into(invoice_id),
)
.with_header_param("Idempotency-Key", &idempotency_key)
.with_body_param(record_invoice_payment_request)
.with_options(&self.options)
.json(&self.cfg)
}

/// Reverse an invoice payment
///
/// Record the full reversal of a settled manual payment.
///
/// `POST /api/v1/invoices/{invoice_id}/payments/{transaction_id}/reverse`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429, 500).
pub fn reverse(
&self,
invoice_id: impl Into<crate::models::InvoiceId>,
transaction_id: impl Into<crate::models::PaymentTransactionId>,
reverse_invoice_payment_request: crate::models::ReverseInvoicePaymentRequest,
options: InvoicesPaymentsReverseOptions,
) -> crate::api::Call<crate::models::Transaction> {
let InvoicesPaymentsReverseOptions { idempotency_key } = options;

crate::request::Request::new(
http::Method::POST,
"/api/v1/invoices/{invoice_id}/payments/{transaction_id}/reverse",
)
.with_path_param(
"invoice_id",
Into::<crate::models::InvoiceId>::into(invoice_id),
)
.with_path_param(
"transaction_id",
Into::<crate::models::PaymentTransactionId>::into(transaction_id),
)
.with_header_param("Idempotency-Key", &idempotency_key)
.with_body_param(reverse_invoice_payment_request)
.with_options(&self.options)
.json(&self.cfg)
}
}
4 changes: 2 additions & 2 deletions src/api/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl Metrics {
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 429).
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 429).
pub fn create(
&self,
create_metric_request: crate::models::CreateMetricRequest,
Expand Down Expand Up @@ -233,7 +233,7 @@ impl Metrics {
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 404, 429).
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 429).
pub fn update(
&self,
metric_id: impl Into<crate::models::BillableMetricId>,
Expand Down
8 changes: 7 additions & 1 deletion src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ mod entitlements;
mod events;
mod features;
mod invoices;
mod invoices_payments;
mod licenses;
mod metrics;
mod oauth;
Expand Down Expand Up @@ -95,7 +96,12 @@ pub use self::{
entitlements::Entitlements,
events::Events,
features::{Features, FeaturesListOptions},
invoices::{Invoices, InvoicesListOptions},
invoices::{
Invoices, InvoicesListOptions, InvoicesMarkPaidOptions, InvoicesMarkUncollectibleOptions,
},
invoices_payments::{
InvoicesPayments, InvoicesPaymentsCreateOptions, InvoicesPaymentsReverseOptions,
},
licenses::{Licenses, LicensesListOptions},
metrics::{Metrics, MetricsListOptions},
oauth::Oauth,
Expand Down
15 changes: 15 additions & 0 deletions src/models/create_metric_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ pub struct CreateMetricRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub unit_singular: Option<String>,

/// Event property, e.g. `project_id`, that breaks each invoice line down by value. The line is
/// still priced on its total usage, and each value shows its quantity and share of the amount.
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_breakdown_key: Option<String>,

/// Event property, e.g. `cluster_id`, whose values are billed as separate invoice lines, each
/// priced on its own usage.
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_group_key: Option<String>,

Expand Down Expand Up @@ -77,6 +84,7 @@ impl CreateMetricRequest {
unit_conversion: None,
unit_plural: None,
unit_singular: None,
usage_breakdown_key: None,
usage_group_key: None,
extra: serde_json::Map::new(),
}
Expand Down Expand Up @@ -141,6 +149,13 @@ impl CreateMetricRequest {
self
}

/// Sets `usage_breakdown_key`.
#[must_use]
pub fn usage_breakdown_key(mut self, usage_breakdown_key: impl Into<String>) -> Self {
self.usage_breakdown_key = Some(usage_breakdown_key.into());
self
}

/// Sets `usage_group_key`.
#[must_use]
pub fn usage_group_key(mut self, usage_group_key: impl Into<String>) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion src/models/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Event {
pub properties: Option<std::collections::HashMap<String, String>>,

/// RFC 3339 timestamp. Defaults to ingestion time if omitted.
/// Must be between 24 hours ago and 1 hour from now. Set `allow_backfilling` to remove the past limit.
/// Must be between 24 hours ago and 1 hour from now. Set `allow_backfilling` to accept timestamps up to 13 months in the past.
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<chrono::DateTime<chrono::Utc>>,

Expand Down
2 changes: 1 addition & 1 deletion src/models/ingest_events_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::event::Event;

#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct IngestEventsRequest {
/// Allow events with timestamps more than 1 day in the past. Defaults to `false`.
/// Allow events with timestamps more than 1 day in the past, up to 13 months. Defaults to `false`.
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_backfilling: Option<bool>,

Expand Down
Loading