Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: add view to list database group request (#16243)

boojack7e71e5c070f8
diff --git a/backend/api/v1/database_group_service.go b/backend/api/v1/database_group_service.go
index c0c9a005bf..9197bf499a 100644
--- a/backend/api/v1/database_group_service.go
+++ b/backend/api/v1/database_group_service.go
@@ -222,7 +222,15 @@ func (s *DatabaseGroupService) ListDatabaseGroups(ctx context.Context, request *
var apiDatabaseGroups []*v1pb.DatabaseGroup
for _, databaseGroup := range databaseGroups {
- apiDatabaseGroups = append(apiDatabaseGroups, convertStoreToAPIDatabaseGroupBasic(databaseGroup, project.ResourceID))
+ if request.View == v1pb.DatabaseGroupView_DATABASE_GROUP_VIEW_BASIC || request.View == v1pb.DatabaseGroupView_DATABASE_GROUP_VIEW_UNSPECIFIED {
+ apiDatabaseGroups = append(apiDatabaseGroups, convertStoreToAPIDatabaseGroupBasic(databaseGroup, project.ResourceID))
+ } else {
+ fullDatabaseGroup, err := s.convertStoreToAPIDatabaseGroupFull(ctx, databaseGroup, projectResourceID)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to convert database group %q to full view, err: %v", databaseGroup.ResourceID, err)
+ }
+ apiDatabaseGroups = append(apiDatabaseGroups, fullDatabaseGroup)
+ }
}
return &v1pb.ListDatabaseGroupsResponse{
DatabaseGroups: apiDatabaseGroups,
diff --git a/frontend/src/types/proto/v1/database_group_service.ts b/frontend/src/types/proto/v1/database_group_service.ts
index 7df71e5200..983ee02ba7 100644
--- a/frontend/src/types/proto/v1/database_group_service.ts
+++ b/frontend/src/types/proto/v1/database_group_service.ts
@@ -95,6 +95,8 @@ export interface ListDatabaseGroupsRequest {
* the call that provided the page token.
*/
pageToken: string;
+ /** The view to return. Defaults to DATABASE_GROUP_VIEW_BASIC. */
+ view: DatabaseGroupView;
}
export interface ListDatabaseGroupsResponse {
@@ -200,7 +202,7 @@ export interface DatabaseGroup_Database {
}
function createBaseListDatabaseGroupsRequest(): ListDatabaseGroupsRequest {
- return { parent: "", pageSize: 0, pageToken: "" };
+ return { parent: "", pageSize: 0, pageToken: "", view: DatabaseGroupView.DATABASE_GROUP_VIEW_UNSPECIFIED };
}
export const ListDatabaseGroupsRequest: MessageFns<ListDatabaseGroupsRequest> = {
@@ -214,6 +216,9 @@ export const ListDatabaseGroupsRequest: MessageFns<ListDatabaseGroupsRequest> =
if (message.pageToken !== "") {
writer.uint32(26).string(message.pageToken);
}
+ if (message.view !== DatabaseGroupView.DATABASE_GROUP_VIEW_UNSPECIFIED) {
+ writer.uint32(32).int32(databaseGroupViewToNumber(message.view));
+ }
return writer;
},
@@ -248,6 +253,14 @@ export const ListDatabaseGroupsRequest: MessageFns<ListDatabaseGroupsRequest> =
message.pageToken = reader.string();
continue;
}
+ case 4: {
+ if (tag !== 32) {
+ break;
+ }
+
+ message.view = databaseGroupViewFromJSON(reader.int32());
+ continue;
+ }
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -262,6 +275,9 @@ export const ListDatabaseGroupsRequest: MessageFns<ListDatabaseGroupsRequest> =
parent: isSet(object.parent) ? globalThis.String(object.parent) : "",
pageSize: isSet(object.pageSize) ? globalThis.Number(object.pageSize) : 0,
pageToken: isSet(object.pageToken) ? globalThis.String(object.pageToken) : "",
+ view: isSet(object.view)
+ ? databaseGroupViewFromJSON(object.view)
+ : DatabaseGroupView.DATABASE_GROUP_VIEW_UNSPECIFIED,
};
},
@@ -276,6 +292,9 @@ export const ListDatabaseGroupsRequest: MessageFns<ListDatabaseGroupsRequest> =
if (message.pageToken !== "") {
obj.pageToken = message.pageToken;
}
+ if (message.view !== DatabaseGroupView.DATABASE_GROUP_VIEW_UNSPECIFIED) {
+ obj.view = databaseGroupViewToJSON(message.view);
+ }
return obj;
},
@@ -287,6 +306,7 @@ export const ListDatabaseGroupsRequest: MessageFns<ListDatabaseGroupsRequest> =
message.parent = object.parent ?? "";
message.pageSize = object.pageSize ?? 0;
message.pageToken = object.pageToken ?? "";
+ message.view = object.view ?? DatabaseGroupView.DATABASE_GROUP_VIEW_UNSPECIFIED;
return message;
},
};
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 83cd23368b..80236e55fe 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -3719,6 +3719,16 @@ paths:
the call that provided the page token.
schema:
type: string
+ - name: view
+ in: query
+ description: The view to return. Defaults to DATABASE_GROUP_VIEW_BASIC.
+ schema:
+ enum:
+ - DATABASE_GROUP_VIEW_UNSPECIFIED
+ - DATABASE_GROUP_VIEW_BASIC
+ - DATABASE_GROUP_VIEW_FULL
+ type: string
+ format: enum
responses:
"200":
description: OK
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index e0c4820881..0bcf4e5ea3 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -6129,6 +6129,7 @@ For example: resource.environment_name == &#34;test&#34; &amp;&amp; resource.dat
| page_token | [string](#string) | | Not used. A page token, received from a previous `ListDatabaseGroups` call. Provide this to retrieve the subsequent page.
When paginating, all other parameters provided to `ListDatabaseGroups` must match the call that provided the page token. |
+| view | [DatabaseGroupView](#bytebase-v1-DatabaseGroupView) | | The view to return. Defaults to DATABASE_GROUP_VIEW_BASIC. |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index bdb5c829d0..8017a279fc 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -17291,6 +17291,13 @@ When paginating, all other parameters provided to `ListDatabaseGroups` must matc
the call that provided the page token. </p></td>
</tr>
+ <tr>
+ <td>view</td>
+ <td><a href="#bytebase.v1.DatabaseGroupView">DatabaseGroupView</a></td>
+ <td></td>
+ <td><p>The view to return. Defaults to DATABASE_GROUP_VIEW_BASIC. </p></td>
+ </tr>
+
</tbody>
</table>
diff --git a/proto/generated-go/v1/database_group_service.pb.go b/proto/generated-go/v1/database_group_service.pb.go
index 098f748334..0ec2808315 100644
--- a/proto/generated-go/v1/database_group_service.pb.go
+++ b/proto/generated-go/v1/database_group_service.pb.go
@@ -95,7 +95,9 @@ type ListDatabaseGroupsRequest struct {
//
// When paginating, all other parameters provided to `ListDatabaseGroups` must match
// the call that provided the page token.
- PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"`
+ PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"`
+ // The view to return. Defaults to DATABASE_GROUP_VIEW_BASIC.
+ View DatabaseGroupView `protobuf:"varint,4,opt,name=view,proto3,enum=bytebase.v1.DatabaseGroupView" json:"view,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -151,6 +153,13 @@ func (x *ListDatabaseGroupsRequest) GetPageToken() string {
return ""
}
+func (x *ListDatabaseGroupsRequest) GetView() DatabaseGroupView {
+ if x != nil {
+ return x.View
+ }
+ return DatabaseGroupView_DATABASE_GROUP_VIEW_UNSPECIFIED
+}
+
type ListDatabaseGroupsResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
// database_groups is the list of database groups.
@@ -583,13 +592,14 @@ var File_v1_database_group_service_proto protoreflect.FileDescriptor
const file_v1_database_group_service_proto_rawDesc = "" +
"\n" +
- "\x1fv1/database_group_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x16google/type/expr.proto\x1a\x13v1/annotation.proto\"\x8e\x01\n" +
+ "\x1fv1/database_group_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x16google/type/expr.proto\x1a\x13v1/annotation.proto\"\xc2\x01\n" +
"\x19ListDatabaseGroupsRequest\x125\n" +
"\x06parent\x18\x01 \x01(\tB\x1d\xe2A\x01\x02\xfaA\x16\n" +
"\x14bytebase.com/ProjectR\x06parent\x12\x1b\n" +
"\tpage_size\x18\x02 \x01(\x05R\bpageSize\x12\x1d\n" +
"\n" +
- "page_token\x18\x03 \x01(\tR\tpageToken\"\x89\x01\n" +
+ "page_token\x18\x03 \x01(\tR\tpageToken\x122\n" +
+ "\x04view\x18\x04 \x01(\x0e2\x1e.bytebase.v1.DatabaseGroupViewR\x04view\"\x89\x01\n" +
"\x1aListDatabaseGroupsResponse\x12C\n" +
"\x0fdatabase_groups\x18\x01 \x03(\v2\x1a.bytebase.v1.DatabaseGroupR\x0edatabaseGroups\x12&\n" +
"\x0fnext_page_token\x18\x02 \x01(\tR\rnextPageToken\"\x86\x01\n" +
@@ -659,29 +669,30 @@ var file_v1_database_group_service_proto_goTypes = []any{
(*emptypb.Empty)(nil), // 11: google.protobuf.Empty
}
var file_v1_database_group_service_proto_depIdxs = []int32{
- 7, // 0: bytebase.v1.ListDatabaseGroupsResponse.database_groups:type_name -> bytebase.v1.DatabaseGroup
- 0, // 1: bytebase.v1.GetDatabaseGroupRequest.view:type_name -> bytebase.v1.DatabaseGroupView
- 7, // 2: bytebase.v1.CreateDatabaseGroupRequest.database_group:type_name -> bytebase.v1.DatabaseGroup
- 7, // 3: bytebase.v1.UpdateDatabaseGroupRequest.database_group:type_name -> bytebase.v1.DatabaseGroup
- 9, // 4: bytebase.v1.UpdateDatabaseGroupRequest.update_mask:type_name -> google.protobuf.FieldMask
- 10, // 5: bytebase.v1.DatabaseGroup.database_expr:type_name -> google.type.Expr
- 8, // 6: bytebase.v1.DatabaseGroup.matched_databases:type_name -> bytebase.v1.DatabaseGroup.Database
- 8, // 7: bytebase.v1.DatabaseGroup.unmatched_databases:type_name -> bytebase.v1.DatabaseGroup.Database
- 1, // 8: bytebase.v1.DatabaseGroupService.ListDatabaseGroups:input_type -> bytebase.v1.ListDatabaseGroupsRequest
- 3, // 9: bytebase.v1.DatabaseGroupService.GetDatabaseGroup:input_type -> bytebase.v1.GetDatabaseGroupRequest
- 4, // 10: bytebase.v1.DatabaseGroupService.CreateDatabaseGroup:input_type -> bytebase.v1.CreateDatabaseGroupRequest
- 5, // 11: bytebase.v1.DatabaseGroupService.UpdateDatabaseGroup:input_type -> bytebase.v1.UpdateDatabaseGroupRequest
- 6, // 12: bytebase.v1.DatabaseGroupService.DeleteDatabaseGroup:input_type -> bytebase.v1.DeleteDatabaseGroupRequest
- 2, // 13: bytebase.v1.DatabaseGroupService.ListDatabaseGroups:output_type -> bytebase.v1.ListDatabaseGroupsResponse
- 7, // 14: bytebase.v1.DatabaseGroupService.GetDatabaseGroup:output_type -> bytebase.v1.DatabaseGroup
- 7, // 15: bytebase.v1.DatabaseGroupService.CreateDatabaseGroup:output_type -> bytebase.v1.DatabaseGroup
- 7, // 16: bytebase.v1.DatabaseGroupService.UpdateDatabaseGroup:output_type -> bytebase.v1.DatabaseGroup
- 11, // 17: bytebase.v1.DatabaseGroupService.DeleteDatabaseGroup:output_type -> google.protobuf.Empty
- 13, // [13:18] is the sub-list for method output_type
- 8, // [8:13] is the sub-list for method input_type
- 8, // [8:8] is the sub-list for extension type_name
- 8, // [8:8] is the sub-list for extension extendee
- 0, // [0:8] is the sub-list for field type_name
+ 0, // 0: bytebase.v1.ListDatabaseGroupsRequest.view:type_name -> bytebase.v1.DatabaseGroupView
+ 7, // 1: bytebase.v1.ListDatabaseGroupsResponse.database_groups:type_name -> bytebase.v1.DatabaseGroup
+ 0, // 2: bytebase.v1.GetDatabaseGroupRequest.view:type_name -> bytebase.v1.DatabaseGroupView
+ 7, // 3: bytebase.v1.CreateDatabaseGroupRequest.database_group:type_name -> bytebase.v1.DatabaseGroup
+ 7, // 4: bytebase.v1.UpdateDatabaseGroupRequest.database_group:type_name -> bytebase.v1.DatabaseGroup
+ 9, // 5: bytebase.v1.UpdateDatabaseGroupRequest.update_mask:type_name -> google.protobuf.FieldMask
+ 10, // 6: bytebase.v1.DatabaseGroup.database_expr:type_name -> google.type.Expr
+ 8, // 7: bytebase.v1.DatabaseGroup.matched_databases:type_name -> bytebase.v1.DatabaseGroup.Database
+ 8, // 8: bytebase.v1.DatabaseGroup.unmatched_databases:type_name -> bytebase.v1.DatabaseGroup.Database
+ 1, // 9: bytebase.v1.DatabaseGroupService.ListDatabaseGroups:input_type -> bytebase.v1.ListDatabaseGroupsRequest
+ 3, // 10: bytebase.v1.DatabaseGroupService.GetDatabaseGroup:input_type -> bytebase.v1.GetDatabaseGroupRequest
+ 4, // 11: bytebase.v1.DatabaseGroupService.CreateDatabaseGroup:input_type -> bytebase.v1.CreateDatabaseGroupRequest
+ 5, // 12: bytebase.v1.DatabaseGroupService.UpdateDatabaseGroup:input_type -> bytebase.v1.UpdateDatabaseGroupRequest
+ 6, // 13: bytebase.v1.DatabaseGroupService.DeleteDatabaseGroup:input_type -> bytebase.v1.DeleteDatabaseGroupRequest
+ 2, // 14: bytebase.v1.DatabaseGroupService.ListDatabaseGroups:output_type -> bytebase.v1.ListDatabaseGroupsResponse
+ 7, // 15: bytebase.v1.DatabaseGroupService.GetDatabaseGroup:output_type -> bytebase.v1.DatabaseGroup
+ 7, // 16: bytebase.v1.DatabaseGroupService.CreateDatabaseGroup:output_type -> bytebase.v1.DatabaseGroup
+ 7, // 17: bytebase.v1.DatabaseGroupService.UpdateDatabaseGroup:output_type -> bytebase.v1.DatabaseGroup
+ 11, // 18: bytebase.v1.DatabaseGroupService.DeleteDatabaseGroup:output_type -> google.protobuf.Empty
+ 14, // [14:19] is the sub-list for method output_type
+ 9, // [9:14] is the sub-list for method input_type
+ 9, // [9:9] is the sub-list for extension type_name
+ 9, // [9:9] is the sub-list for extension extendee
+ 0, // [0:9] is the sub-list for field type_name
}
func init() { file_v1_database_group_service_proto_init() }
diff --git a/proto/v1/v1/database_group_service.proto b/proto/v1/v1/database_group_service.proto
index 00a315f520..018e4c6f24 100644
--- a/proto/v1/v1/database_group_service.proto
+++ b/proto/v1/v1/database_group_service.proto
@@ -81,6 +81,9 @@ message ListDatabaseGroupsRequest {
// When paginating, all other parameters provided to `ListDatabaseGroups` must match
// the call that provided the page token.
string page_token = 3;
+
+ // The view to return. Defaults to DATABASE_GROUP_VIEW_BASIC.
+ DatabaseGroupView view = 4;
}
message ListDatabaseGroupsResponse {