From 5e3b5d68f2906b0f7323e082535ccc288f2227d2 Mon Sep 17 00:00:00 2001 From: lberrymage Date: Wed, 30 Sep 2026 22:38:41 +0000 Subject: [PATCH] Replace `ListOrganizations` RPC with `GetMyOrganization` Our current domain model allows exactly one organization per user, so a list method for a user's organizations is unnecessary indirection. Instead, replace it with an RPC for getting the currently authenticated user's organization. --- .../v1/get_my_organization_request.proto | 14 ++++++++++ .../v1/get_my_organization_response.proto | 20 ++++++++++++++ .../v1/list_organizations_request.proto | 22 --------------- .../v1/list_organizations_response.proto | 27 ------------------- .../console/v1/organization_service.proto | 8 +++--- 5 files changed, 38 insertions(+), 53 deletions(-) create mode 100644 accrescent/console/v1/get_my_organization_request.proto create mode 100644 accrescent/console/v1/get_my_organization_response.proto delete mode 100644 accrescent/console/v1/list_organizations_request.proto delete mode 100644 accrescent/console/v1/list_organizations_response.proto diff --git a/accrescent/console/v1/get_my_organization_request.proto b/accrescent/console/v1/get_my_organization_request.proto new file mode 100644 index 0000000..8ea2ac8 --- /dev/null +++ b/accrescent/console/v1/get_my_organization_request.proto @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: © 2026 Logan Magee +// +// SPDX-License-Identifier: Apache-2.0 + +syntax = "proto3"; + +package accrescent.console.v1; + +option java_multiple_files = true; +option java_package = "app.accrescent.console.v1"; + +// Request defining parameters for getting the organization owned by the +// currently authenticated user. +message GetMyOrganizationRequest {} diff --git a/accrescent/console/v1/get_my_organization_response.proto b/accrescent/console/v1/get_my_organization_response.proto new file mode 100644 index 0000000..d166ec0 --- /dev/null +++ b/accrescent/console/v1/get_my_organization_response.proto @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: © 2026 Logan Magee +// +// SPDX-License-Identifier: Apache-2.0 + +syntax = "proto3"; + +package accrescent.console.v1; + +import "accrescent/console/v1/organization.proto"; +import "buf/validate/validate.proto"; + +option java_multiple_files = true; +option java_package = "app.accrescent.console.v1"; + +// Response to getting the organization owned by the currently authenticated +// user. +message GetMyOrganizationResponse { + // The organization owned by the currently authenticated user. + Organization organization = 1 [(buf.validate.field).required = true]; +} diff --git a/accrescent/console/v1/list_organizations_request.proto b/accrescent/console/v1/list_organizations_request.proto deleted file mode 100644 index 5801ff0..0000000 --- a/accrescent/console/v1/list_organizations_request.proto +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-FileCopyrightText: © 2025 Logan Magee -// -// SPDX-License-Identifier: Apache-2.0 - -syntax = "proto3"; - -package accrescent.console.v1; - -option java_multiple_files = true; -option java_package = "app.accrescent.console.v1"; - -// Request defining parameters for listing organizations. -message ListOrganizationsRequest { - // The maximum number of organizations to return in the response. If - // unspecified, defaults to 50. All requests with a higher page size will be - // capped to 50. - optional uint32 page_size = 1; - - // An opaque page continuation token returned in a previous - // ListOrganizationsResponse. If unspecified, the first page is returned. - optional string page_token = 2; -} diff --git a/accrescent/console/v1/list_organizations_response.proto b/accrescent/console/v1/list_organizations_response.proto deleted file mode 100644 index 09ad82d..0000000 --- a/accrescent/console/v1/list_organizations_response.proto +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: © 2025 Logan Magee -// -// SPDX-License-Identifier: Apache-2.0 - -syntax = "proto3"; - -package accrescent.console.v1; - -import "accrescent/console/v1/organization.proto"; -import "buf/validate/validate.proto"; - -option java_multiple_files = true; -option java_package = "app.accrescent.console.v1"; - -// Response to listing organizations. -message ListOrganizationsResponse { - // The organizations matching the request parameters. - repeated Organization organizations = 1 [(buf.validate.field).cel = { - id: "organizations.have_unique_ids" - message: "organizations must have unique IDs" - expression: "this.map(o, o.id).unique()" - }]; - - // An opaque token which, if passed to another invocation of - // ListOrganizations, will return the next page of organizations. - optional string next_page_token = 2; -} diff --git a/accrescent/console/v1/organization_service.proto b/accrescent/console/v1/organization_service.proto index 1e87e28..3ab03f7 100644 --- a/accrescent/console/v1/organization_service.proto +++ b/accrescent/console/v1/organization_service.proto @@ -6,10 +6,10 @@ syntax = "proto3"; package accrescent.console.v1; +import "accrescent/console/v1/get_my_organization_request.proto"; +import "accrescent/console/v1/get_my_organization_response.proto"; import "accrescent/console/v1/get_organization_request.proto"; import "accrescent/console/v1/get_organization_response.proto"; -import "accrescent/console/v1/list_organizations_request.proto"; -import "accrescent/console/v1/list_organizations_response.proto"; import "google/api/client.proto"; option java_multiple_files = true; @@ -24,8 +24,8 @@ service OrganizationService { option idempotency_level = NO_SIDE_EFFECTS; } - // Lists organizations. - rpc ListOrganizations(ListOrganizationsRequest) returns (ListOrganizationsResponse) { + // Gets the organization owned by the currently authenticated user. + rpc GetMyOrganization(GetMyOrganizationRequest) returns (GetMyOrganizationResponse) { option idempotency_level = NO_SIDE_EFFECTS; } }