From 58983b96d4bf2a07299df37210a8aef8fb94d139 Mon Sep 17 00:00:00 2001 From: Alberto Leal Date: Tue, 1 Dec 2026 06:58:18 -0500 Subject: [PATCH] feat(billing): Add GetContractIdsWithUsageSnapshot to the contract usage snapshot service The endpoint takes contract ids and returns the ids that have a usage snapshot. It reads no snapshot, so a caller can check many contracts in one call. It has the same shape as GetOrganizationsAwaitingPayment. getsentry needs it to find, for a page of receipts, which closed contracts have a usage snapshot, with protobuf input and output. The Rust bindings and the Cargo.lock version line come from `make build-rust`. --- Cargo.lock | 2 +- ...t_get_contract_ids_with_usage_snapshot.proto | 17 +++++++++++++++++ ...ng.v1.services.contract_usage_snapshot.v1.rs | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 proto/sentry_protos/billing/v1/services/contract_usage_snapshot/v1/endpoint_get_contract_ids_with_usage_snapshot.proto diff --git a/Cargo.lock b/Cargo.lock index c5ac8903..1be87b53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -717,7 +717,7 @@ checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "sentry_protos" -version = "0.130.0" +version = "0.132.0" dependencies = [ "prost", "prost-types", diff --git a/proto/sentry_protos/billing/v1/services/contract_usage_snapshot/v1/endpoint_get_contract_ids_with_usage_snapshot.proto b/proto/sentry_protos/billing/v1/services/contract_usage_snapshot/v1/endpoint_get_contract_ids_with_usage_snapshot.proto new file mode 100644 index 00000000..fc922aa1 --- /dev/null +++ b/proto/sentry_protos/billing/v1/services/contract_usage_snapshot/v1/endpoint_get_contract_ids_with_usage_snapshot.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package sentry_protos.billing.v1.services.contract_usage_snapshot.v1; + +// Filters contracts down to those that have a usage snapshot. It reads no +// snapshot, so a caller can check many contracts in one call. The caller is +// responsible for passing only ids it has the right to see; this endpoint does +// not filter by organization. +message GetContractIdsWithUsageSnapshotRequest { + repeated uint64 contract_ids = 1; +} + +message GetContractIdsWithUsageSnapshotResponse { + // The subset of the requested contract_ids that have a usage snapshot, in no + // particular order. Empty when the request has no ids or none has a snapshot. + repeated uint64 contract_ids = 1; +} diff --git a/rust/src/sentry_protos.billing.v1.services.contract_usage_snapshot.v1.rs b/rust/src/sentry_protos.billing.v1.services.contract_usage_snapshot.v1.rs index feeae90e..60b83afe 100644 --- a/rust/src/sentry_protos.billing.v1.services.contract_usage_snapshot.v1.rs +++ b/rust/src/sentry_protos.billing.v1.services.contract_usage_snapshot.v1.rs @@ -54,6 +54,22 @@ pub struct CreateUsageSnapshotResponse { #[prost(message, optional, tag = "1")] pub snapshot: ::core::option::Option, } +/// Filters contracts down to those that have a usage snapshot. It reads no +/// snapshot, so a caller can check many contracts in one call. The caller is +/// responsible for passing only ids it has the right to see; this endpoint does +/// not filter by organization. +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetContractIdsWithUsageSnapshotRequest { + #[prost(uint64, repeated, tag = "1")] + pub contract_ids: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct GetContractIdsWithUsageSnapshotResponse { + /// The subset of the requested contract_ids that have a usage snapshot, in no + /// particular order. Empty when the request has no ids or none has a snapshot. + #[prost(uint64, repeated, tag = "1")] + pub contract_ids: ::prost::alloc::vec::Vec, +} #[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] pub struct GetUsageSnapshotRequest { #[prost(oneof = "get_usage_snapshot_request::Query", tags = "1, 2")]