Skip to content

Commit

Permalink
feat: Add Pub/Sub Lite Reservation APIs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 377060979
  • Loading branch information
Google APIs authored and Copybara-Service committed Jun 2, 2021
1 parent d826b30 commit 51d99df
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 3 deletions.
177 changes: 177 additions & 0 deletions google/cloud/pubsublite/v1/admin.proto
Expand Up @@ -138,6 +138,56 @@ service AdminService {
};
option (google.api.method_signature) = "name";
}

// Creates a new reservation.
rpc CreateReservation(CreateReservationRequest) returns (Reservation) {
option (google.api.http) = {
post: "/v1/admin/{parent=projects/*/locations/*}/reservations"
body: "reservation"
};
option (google.api.method_signature) = "parent,reservation,reservation_id";
}

// Returns the reservation configuration.
rpc GetReservation(GetReservationRequest) returns (Reservation) {
option (google.api.http) = {
get: "/v1/admin/{name=projects/*/locations/*/reservations/*}"
};
option (google.api.method_signature) = "name";
}

// Returns the list of reservations for the given project.
rpc ListReservations(ListReservationsRequest) returns (ListReservationsResponse) {
option (google.api.http) = {
get: "/v1/admin/{parent=projects/*/locations/*}/reservations"
};
option (google.api.method_signature) = "parent";
}

// Updates properties of the specified reservation.
rpc UpdateReservation(UpdateReservationRequest) returns (Reservation) {
option (google.api.http) = {
patch: "/v1/admin/{reservation.name=projects/*/locations/*/reservations/*}"
body: "reservation"
};
option (google.api.method_signature) = "reservation,update_mask";
}

// Deletes the specified reservation.
rpc DeleteReservation(DeleteReservationRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1/admin/{name=projects/*/locations/*/reservations/*}"
};
option (google.api.method_signature) = "name";
}

// Lists the topics attached to the specified reservation.
rpc ListReservationTopics(ListReservationTopicsRequest) returns (ListReservationTopicsResponse) {
option (google.api.http) = {
get: "/v1/admin/{name=projects/*/locations/*/reservations/*}/topics"
};
option (google.api.method_signature) = "name";
}
}

// Request for CreateTopic.
Expand Down Expand Up @@ -370,3 +420,130 @@ message DeleteSubscriptionRequest {
}
];
}

// Request for CreateReservation.
message CreateReservationRequest {
// Required. The parent location in which to create the reservation.
// Structured like `projects/{project_number}/locations/{location}`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "locations.googleapis.com/Location"
}
];

// Required. Configuration of the reservation to create. Its `name` field is ignored.
Reservation reservation = 2 [(google.api.field_behavior) = REQUIRED];

// Required. The ID to use for the reservation, which will become the final component of
// the reservation's name.
//
// This value is structured like: `my-reservation-name`.
string reservation_id = 3 [(google.api.field_behavior) = REQUIRED];
}

// Request for GetReservation.
message GetReservationRequest {
// Required. The name of the reservation whose configuration to return.
// Structured like:
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "pubsublite.googleapis.com/Reservation"
}
];
}

// Request for ListReservations.
message ListReservationsRequest {
// Required. The parent whose reservations are to be listed.
// Structured like `projects/{project_number}/locations/{location}`.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "locations.googleapis.com/Location"
}
];

// The maximum number of reservations to return. The service may return fewer
// than this value. If unset or zero, all reservations for the parent will be
// returned.
int32 page_size = 2;

// A page token, received from a previous `ListReservations` call.
// Provide this to retrieve the subsequent page.
//
// When paginating, all other parameters provided to `ListReservations` must
// match the call that provided the page token.
string page_token = 3;
}

// Response for ListReservations.
message ListReservationsResponse {
// The list of reservation in the requested parent. The order of the
// reservations is unspecified.
repeated Reservation reservations = 1;

// A token that can be sent as `page_token` to retrieve the next page of
// results. If this field is omitted, there are no more results.
string next_page_token = 2;
}

// Request for UpdateReservation.
message UpdateReservationRequest {
// Required. The reservation to update. Its `name` field must be populated.
Reservation reservation = 1 [(google.api.field_behavior) = REQUIRED];

// Required. A mask specifying the reservation fields to change.
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
}

// Request for DeleteReservation.
message DeleteReservationRequest {
// Required. The name of the reservation to delete.
// Structured like:
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "pubsublite.googleapis.com/Reservation"
}
];
}

// Request for ListReservationTopics.
message ListReservationTopicsRequest {
// Required. The name of the reservation whose topics to list.
// Structured like:
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "pubsublite.googleapis.com/Reservation"
}
];

// The maximum number of topics to return. The service may return fewer
// than this value.
// If unset or zero, all topics for the given reservation will be returned.
int32 page_size = 2;

// A page token, received from a previous `ListReservationTopics` call.
// Provide this to retrieve the subsequent page.
//
// When paginating, all other parameters provided to `ListReservationTopics`
// must match the call that provided the page token.
string page_token = 3;
}

// Response for ListReservationTopics.
message ListReservationTopicsResponse {
// The names of topics attached to the reservation. The order of the
// topics is unspecified.
repeated string topics = 1;

// A token that can be sent as `page_token` to retrieve the next page of
// results. If this field is omitted, there are no more results.
string next_page_token = 2;
}
35 changes: 35 additions & 0 deletions google/cloud/pubsublite/v1/common.proto
Expand Up @@ -75,6 +75,28 @@ message SequencedMessage {
int64 size_bytes = 4;
}

// Metadata about a reservation resource.
message Reservation {
option (google.api.resource) = {
type: "pubsublite.googleapis.com/Reservation"
pattern: "projects/{project}/locations/{location}/reservations/{reservation}"
};

// The name of the reservation.
// Structured like:
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
string name = 1;

// The reserved throughput capacity. Every unit of throughput capacity is
// equivalent to 1 MiB/s of published messages or 2 MiB/s of subscribed
// messages.
//
// Any topics which are declared as using capacity from a Reservation will
// consume resources from this reservation instead of being charged
// individually.
int64 throughput_capacity = 2;
}

// Metadata about a topic resource.
message Topic {
option (google.api.resource) = {
Expand Down Expand Up @@ -134,6 +156,16 @@ message Topic {
google.protobuf.Duration period = 2;
}

// The settings for this topic's Reservation usage.
message ReservationConfig {
// The Reservation to use for this topic's throughput capacity.
// Structured like:
// projects/{project_number}/locations/{location}/reservations/{reservation_id}
string throughput_reservation = 1 [(google.api.resource_reference) = {
type: "pubsublite.googleapis.com/Reservation"
}];
}

// The name of the topic.
// Structured like:
// projects/{project_number}/locations/{location}/topics/{topic_id}
Expand All @@ -144,6 +176,9 @@ message Topic {

// The settings for this topic's message retention.
RetentionConfig retention_config = 3;

// The settings for this topic's Reservation usage.
ReservationConfig reservation_config = 4;
}

// Metadata about a subscription resource.
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/pubsublite/v1/subscriber.proto
Expand Up @@ -67,9 +67,9 @@ message InitialSubscribeRequest {
// so `partition` must be in the range [0, topic.num_partitions).
int64 partition = 2;

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

Expand Down

0 comments on commit 51d99df

Please sign in to comment.