Skip to content

Commit 51d99df

Browse files
Google APIscopybara-github
authored andcommitted
feat: Add Pub/Sub Lite Reservation APIs
PiperOrigin-RevId: 377060979
1 parent d826b30 commit 51d99df

3 files changed

Lines changed: 215 additions & 3 deletions

File tree

google/cloud/pubsublite/v1/admin.proto

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,56 @@ service AdminService {
138138
};
139139
option (google.api.method_signature) = "name";
140140
}
141+
142+
// Creates a new reservation.
143+
rpc CreateReservation(CreateReservationRequest) returns (Reservation) {
144+
option (google.api.http) = {
145+
post: "/v1/admin/{parent=projects/*/locations/*}/reservations"
146+
body: "reservation"
147+
};
148+
option (google.api.method_signature) = "parent,reservation,reservation_id";
149+
}
150+
151+
// Returns the reservation configuration.
152+
rpc GetReservation(GetReservationRequest) returns (Reservation) {
153+
option (google.api.http) = {
154+
get: "/v1/admin/{name=projects/*/locations/*/reservations/*}"
155+
};
156+
option (google.api.method_signature) = "name";
157+
}
158+
159+
// Returns the list of reservations for the given project.
160+
rpc ListReservations(ListReservationsRequest) returns (ListReservationsResponse) {
161+
option (google.api.http) = {
162+
get: "/v1/admin/{parent=projects/*/locations/*}/reservations"
163+
};
164+
option (google.api.method_signature) = "parent";
165+
}
166+
167+
// Updates properties of the specified reservation.
168+
rpc UpdateReservation(UpdateReservationRequest) returns (Reservation) {
169+
option (google.api.http) = {
170+
patch: "/v1/admin/{reservation.name=projects/*/locations/*/reservations/*}"
171+
body: "reservation"
172+
};
173+
option (google.api.method_signature) = "reservation,update_mask";
174+
}
175+
176+
// Deletes the specified reservation.
177+
rpc DeleteReservation(DeleteReservationRequest) returns (google.protobuf.Empty) {
178+
option (google.api.http) = {
179+
delete: "/v1/admin/{name=projects/*/locations/*/reservations/*}"
180+
};
181+
option (google.api.method_signature) = "name";
182+
}
183+
184+
// Lists the topics attached to the specified reservation.
185+
rpc ListReservationTopics(ListReservationTopicsRequest) returns (ListReservationTopicsResponse) {
186+
option (google.api.http) = {
187+
get: "/v1/admin/{name=projects/*/locations/*/reservations/*}/topics"
188+
};
189+
option (google.api.method_signature) = "name";
190+
}
141191
}
142192

143193
// Request for CreateTopic.
@@ -370,3 +420,130 @@ message DeleteSubscriptionRequest {
370420
}
371421
];
372422
}
423+
424+
// Request for CreateReservation.
425+
message CreateReservationRequest {
426+
// Required. The parent location in which to create the reservation.
427+
// Structured like `projects/{project_number}/locations/{location}`.
428+
string parent = 1 [
429+
(google.api.field_behavior) = REQUIRED,
430+
(google.api.resource_reference) = {
431+
type: "locations.googleapis.com/Location"
432+
}
433+
];
434+
435+
// Required. Configuration of the reservation to create. Its `name` field is ignored.
436+
Reservation reservation = 2 [(google.api.field_behavior) = REQUIRED];
437+
438+
// Required. The ID to use for the reservation, which will become the final component of
439+
// the reservation's name.
440+
//
441+
// This value is structured like: `my-reservation-name`.
442+
string reservation_id = 3 [(google.api.field_behavior) = REQUIRED];
443+
}
444+
445+
// Request for GetReservation.
446+
message GetReservationRequest {
447+
// Required. The name of the reservation whose configuration to return.
448+
// Structured like:
449+
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
450+
string name = 1 [
451+
(google.api.field_behavior) = REQUIRED,
452+
(google.api.resource_reference) = {
453+
type: "pubsublite.googleapis.com/Reservation"
454+
}
455+
];
456+
}
457+
458+
// Request for ListReservations.
459+
message ListReservationsRequest {
460+
// Required. The parent whose reservations are to be listed.
461+
// Structured like `projects/{project_number}/locations/{location}`.
462+
string parent = 1 [
463+
(google.api.field_behavior) = REQUIRED,
464+
(google.api.resource_reference) = {
465+
type: "locations.googleapis.com/Location"
466+
}
467+
];
468+
469+
// The maximum number of reservations to return. The service may return fewer
470+
// than this value. If unset or zero, all reservations for the parent will be
471+
// returned.
472+
int32 page_size = 2;
473+
474+
// A page token, received from a previous `ListReservations` call.
475+
// Provide this to retrieve the subsequent page.
476+
//
477+
// When paginating, all other parameters provided to `ListReservations` must
478+
// match the call that provided the page token.
479+
string page_token = 3;
480+
}
481+
482+
// Response for ListReservations.
483+
message ListReservationsResponse {
484+
// The list of reservation in the requested parent. The order of the
485+
// reservations is unspecified.
486+
repeated Reservation reservations = 1;
487+
488+
// A token that can be sent as `page_token` to retrieve the next page of
489+
// results. If this field is omitted, there are no more results.
490+
string next_page_token = 2;
491+
}
492+
493+
// Request for UpdateReservation.
494+
message UpdateReservationRequest {
495+
// Required. The reservation to update. Its `name` field must be populated.
496+
Reservation reservation = 1 [(google.api.field_behavior) = REQUIRED];
497+
498+
// Required. A mask specifying the reservation fields to change.
499+
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
500+
}
501+
502+
// Request for DeleteReservation.
503+
message DeleteReservationRequest {
504+
// Required. The name of the reservation to delete.
505+
// Structured like:
506+
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
507+
string name = 1 [
508+
(google.api.field_behavior) = REQUIRED,
509+
(google.api.resource_reference) = {
510+
type: "pubsublite.googleapis.com/Reservation"
511+
}
512+
];
513+
}
514+
515+
// Request for ListReservationTopics.
516+
message ListReservationTopicsRequest {
517+
// Required. The name of the reservation whose topics to list.
518+
// Structured like:
519+
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
520+
string name = 1 [
521+
(google.api.field_behavior) = REQUIRED,
522+
(google.api.resource_reference) = {
523+
type: "pubsublite.googleapis.com/Reservation"
524+
}
525+
];
526+
527+
// The maximum number of topics to return. The service may return fewer
528+
// than this value.
529+
// If unset or zero, all topics for the given reservation will be returned.
530+
int32 page_size = 2;
531+
532+
// A page token, received from a previous `ListReservationTopics` call.
533+
// Provide this to retrieve the subsequent page.
534+
//
535+
// When paginating, all other parameters provided to `ListReservationTopics`
536+
// must match the call that provided the page token.
537+
string page_token = 3;
538+
}
539+
540+
// Response for ListReservationTopics.
541+
message ListReservationTopicsResponse {
542+
// The names of topics attached to the reservation. The order of the
543+
// topics is unspecified.
544+
repeated string topics = 1;
545+
546+
// A token that can be sent as `page_token` to retrieve the next page of
547+
// results. If this field is omitted, there are no more results.
548+
string next_page_token = 2;
549+
}

google/cloud/pubsublite/v1/common.proto

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@ message SequencedMessage {
7575
int64 size_bytes = 4;
7676
}
7777

78+
// Metadata about a reservation resource.
79+
message Reservation {
80+
option (google.api.resource) = {
81+
type: "pubsublite.googleapis.com/Reservation"
82+
pattern: "projects/{project}/locations/{location}/reservations/{reservation}"
83+
};
84+
85+
// The name of the reservation.
86+
// Structured like:
87+
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
88+
string name = 1;
89+
90+
// The reserved throughput capacity. Every unit of throughput capacity is
91+
// equivalent to 1 MiB/s of published messages or 2 MiB/s of subscribed
92+
// messages.
93+
//
94+
// Any topics which are declared as using capacity from a Reservation will
95+
// consume resources from this reservation instead of being charged
96+
// individually.
97+
int64 throughput_capacity = 2;
98+
}
99+
78100
// Metadata about a topic resource.
79101
message Topic {
80102
option (google.api.resource) = {
@@ -134,6 +156,16 @@ message Topic {
134156
google.protobuf.Duration period = 2;
135157
}
136158

159+
// The settings for this topic's Reservation usage.
160+
message ReservationConfig {
161+
// The Reservation to use for this topic's throughput capacity.
162+
// Structured like:
163+
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
164+
string throughput_reservation = 1 [(google.api.resource_reference) = {
165+
type: "pubsublite.googleapis.com/Reservation"
166+
}];
167+
}
168+
137169
// The name of the topic.
138170
// Structured like:
139171
// projects/{project_number}/locations/{location}/topics/{topic_id}
@@ -144,6 +176,9 @@ message Topic {
144176

145177
// The settings for this topic's message retention.
146178
RetentionConfig retention_config = 3;
179+
180+
// The settings for this topic's Reservation usage.
181+
ReservationConfig reservation_config = 4;
147182
}
148183

149184
// Metadata about a subscription resource.

google/cloud/pubsublite/v1/subscriber.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ message InitialSubscribeRequest {
6767
// so `partition` must be in the range [0, topic.num_partitions).
6868
int64 partition = 2;
6969

70-
// Optional. Initial target location within the message backlog. If not set,
71-
// messages will be delivered from the commit cursor for the given
72-
// subscription and partition.
70+
// Optional. Initial target location within the message backlog. If not set, messages
71+
// will be delivered from the commit cursor for the given subscription and
72+
// partition.
7373
SeekRequest initial_location = 4 [(google.api.field_behavior) = OPTIONAL];
7474
}
7575

0 commit comments

Comments
 (0)