Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: migrate database role API to gRPC (#4147)
ecmadao6d01bcfb25cf
diff --git a/frontend/src/types/proto/v1/database_role.ts b/frontend/src/types/proto/v1/database_role.tsdeleted file mode 100644index 333310852e..0000000000--- a/frontend/src/types/proto/v1/database_role.ts+++ /dev/null@@ -1,416 +0,0 @@-/* eslint-disable */-import _m0 from "protobufjs/minimal";--export const protobufPackage = "bytebase.v1";--/** RoleAttribute is the attribute for role. Docs: https://www.postgresql.org/docs/current/role-attributes.html */-export interface DatabaseRoleAttribute {- /** A database superuser bypasses all permission checks, except the right to log in. */- superUser: boolean;- /** A role is given permission to inherit the privileges of roles it is a member of. To create a role without the permission, use "noInherit = true" */- noInherit: boolean;- /** A role must be explicitly given permission to create more roles (except for superusers, since those bypass all permission checks). */- createRole: boolean;- /** A role must be explicitly given permission to create databases (except for superusers, since those bypass all permission checks). */- createDb: boolean;- /** Only roles that have the LOGIN attribute can be used as the initial role name for a database connection. */- canLogin: boolean;- /** A role must explicitly be given permission to initiate streaming replication (except for superusers, since those bypass all permission checks). */- replication: boolean;- /** A role must be explicitly given permission to bypass every row-level security (RLS) policy (except for superusers, since those bypass all permission checks). */- bypassRls: boolean;-}--/** DatabaseRole is the API message for database role. */-export interface DatabaseRole {- /** The role unique name. */- name: string;- /** The Bytebase instance id for this role. */- instanceId: number;- /** The connection count limit for this role. */- connectionLimit: number;- /** The expiration for the role's password. */- validUntil?:- | string- | undefined;- /** The role attribute. */- attribute?: DatabaseRoleAttribute;-}--/** ListDatabaseRoleResponse is the API message for role list. */-export interface ListDatabaseRoleResponse {- roles: DatabaseRole[];-}--/** DatabaseRoleUpsert is the API message for upserting a database role. */-export interface DatabaseRoleUpsert {- /** The role unique name. */- name: string;- /** A password is only significant if the client authentication method requires the user to supply a password when connecting to the database. */- password?:- | string- | undefined;- /** Connection limit can specify how many concurrent connections a role can make. -1 (the default) means no limit. */- connectionLimit?:- | number- | undefined;- /** The VALID UNTIL clause sets a date and time after which the role's password is no longer valid. If this clause is omitted the password will be valid for all time. */- validUntil?:- | string- | undefined;- /** The role attribute. */- attribute?: DatabaseRoleAttribute | undefined;-}--function createBaseDatabaseRoleAttribute(): DatabaseRoleAttribute {- return {- superUser: false,- noInherit: false,- createRole: false,- createDb: false,- canLogin: false,- replication: false,- bypassRls: false,- };-}--export const DatabaseRoleAttribute = {- encode(message: DatabaseRoleAttribute, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {- if (message.superUser === true) {- writer.uint32(8).bool(message.superUser);- }- if (message.noInherit === true) {- writer.uint32(16).bool(message.noInherit);- }- if (message.createRole === true) {- writer.uint32(24).bool(message.createRole);- }- if (message.createDb === true) {- writer.uint32(32).bool(message.createDb);- }- if (message.canLogin === true) {- writer.uint32(40).bool(message.canLogin);- }- if (message.replication === true) {- writer.uint32(48).bool(message.replication);- }- if (message.bypassRls === true) {- writer.uint32(56).bool(message.bypassRls);- }- return writer;- },-- decode(input: _m0.Reader | Uint8Array, length?: number): DatabaseRoleAttribute {- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);- let end = length === undefined ? reader.len : reader.pos + length;- const message = createBaseDatabaseRoleAttribute();- while (reader.pos < end) {- const tag = reader.uint32();- switch (tag >>> 3) {- case 1:- message.superUser = reader.bool();- break;- case 2:- message.noInherit = reader.bool();- break;- case 3:- message.createRole = reader.bool();- break;- case 4:- message.createDb = reader.bool();- break;- case 5:- message.canLogin = reader.bool();- break;- case 6:- message.replication = reader.bool();- break;- case 7:- message.bypassRls = reader.bool();- break;- default:- reader.skipType(tag & 7);- break;- }- }- return message;- },-- fromJSON(object: any): DatabaseRoleAttribute {- return {- superUser: isSet(object.superUser) ? Boolean(object.superUser) : false,- noInherit: isSet(object.noInherit) ? Boolean(object.noInherit) : false,- createRole: isSet(object.createRole) ? Boolean(object.createRole) : false,- createDb: isSet(object.createDb) ? Boolean(object.createDb) : false,- canLogin: isSet(object.canLogin) ? Boolean(object.canLogin) : false,- replication: isSet(object.replication) ? Boolean(object.replication) : false,- bypassRls: isSet(object.bypassRls) ? Boolean(object.bypassRls) : false,- };- },-- toJSON(message: DatabaseRoleAttribute): unknown {- const obj: any = {};- message.superUser !== undefined && (obj.superUser = message.superUser);- message.noInherit !== undefined && (obj.noInherit = message.noInherit);- message.createRole !== undefined && (obj.createRole = message.createRole);- message.createDb !== undefined && (obj.createDb = message.createDb);- message.canLogin !== undefined && (obj.canLogin = message.canLogin);- message.replication !== undefined && (obj.replication = message.replication);- message.bypassRls !== undefined && (obj.bypassRls = message.bypassRls);- return obj;- },-- fromPartial<I extends Exact<DeepPartial<DatabaseRoleAttribute>, I>>(object: I): DatabaseRoleAttribute {- const message = createBaseDatabaseRoleAttribute();- message.superUser = object.superUser ?? false;- message.noInherit = object.noInherit ?? false;- message.createRole = object.createRole ?? false;- message.createDb = object.createDb ?? false;- message.canLogin = object.canLogin ?? false;- message.replication = object.replication ?? false;- message.bypassRls = object.bypassRls ?? false;- return message;- },-};--function createBaseDatabaseRole(): DatabaseRole {- return { name: "", instanceId: 0, connectionLimit: 0, validUntil: undefined, attribute: undefined };-}--export const DatabaseRole = {- encode(message: DatabaseRole, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {- if (message.name !== "") {- writer.uint32(10).string(message.name);- }- if (message.instanceId !== 0) {- writer.uint32(16).int32(message.instanceId);- }- if (message.connectionLimit !== 0) {- writer.uint32(24).int32(message.connectionLimit);- }- if (message.validUntil !== undefined) {- writer.uint32(34).string(message.validUntil);- }- if (message.attribute !== undefined) {- DatabaseRoleAttribute.encode(message.attribute, writer.uint32(42).fork()).ldelim();- }- return writer;- },-- decode(input: _m0.Reader | Uint8Array, length?: number): DatabaseRole {- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);- let end = length === undefined ? reader.len : reader.pos + length;- const message = createBaseDatabaseRole();- while (reader.pos < end) {- const tag = reader.uint32();- switch (tag >>> 3) {- case 1:- message.name = reader.string();- break;- case 2:- message.instanceId = reader.int32();- break;- case 3:- message.connectionLimit = reader.int32();- break;- case 4:- message.validUntil = reader.string();- break;- case 5:- message.attribute = DatabaseRoleAttribute.decode(reader, reader.uint32());- break;- default:- reader.skipType(tag & 7);- break;- }- }- return message;- },-- fromJSON(object: any): DatabaseRole {- return {- name: isSet(object.name) ? String(object.name) : "",- instanceId: isSet(object.instanceId) ? Number(object.instanceId) : 0,- connectionLimit: isSet(object.connectionLimit) ? Number(object.connectionLimit) : 0,- validUntil: isSet(object.validUntil) ? String(object.validUntil) : undefined,- attribute: isSet(object.attribute) ? DatabaseRoleAttribute.fromJSON(object.attribute) : undefined,- };- },-- toJSON(message: DatabaseRole): unknown {- const obj: any = {};- message.name !== undefined && (obj.name = message.name);- message.instanceId !== undefined && (obj.instanceId = Math.round(message.instanceId));- message.connectionLimit !== undefined && (obj.connectionLimit = Math.round(message.connectionLimit));- message.validUntil !== undefined && (obj.validUntil = message.validUntil);- message.attribute !== undefined &&- (obj.attribute = message.attribute ? DatabaseRoleAttribute.toJSON(message.attribute) : undefined);- return obj;- },-- fromPartial<I extends Exact<DeepPartial<DatabaseRole>, I>>(object: I): DatabaseRole {- const message = createBaseDatabaseRole();- message.name = object.name ?? "";- message.instanceId = object.instanceId ?? 0;- message.connectionLimit = object.connectionLimit ?? 0;- message.validUntil = object.validUntil ?? undefined;- message.attribute = (object.attribute !== undefined && object.attribute !== null)- ? DatabaseRoleAttribute.fromPartial(object.attribute)- : undefined;- return message;- },-};--function createBaseListDatabaseRoleResponse(): ListDatabaseRoleResponse {- return { roles: [] };-}--export const ListDatabaseRoleResponse = {- encode(message: ListDatabaseRoleResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {- for (const v of message.roles) {- DatabaseRole.encode(v!, writer.uint32(10).fork()).ldelim();- }- return writer;- },-- decode(input: _m0.Reader | Uint8Array, length?: number): ListDatabaseRoleResponse {- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);- let end = length === undefined ? reader.len : reader.pos + length;- const message = createBaseListDatabaseRoleResponse();- while (reader.pos < end) {- const tag = reader.uint32();- switch (tag >>> 3) {- case 1:- message.roles.push(DatabaseRole.decode(reader, reader.uint32()));- break;- default:- reader.skipType(tag & 7);- break;- }- }- return message;- },-- fromJSON(object: any): ListDatabaseRoleResponse {- return { roles: Array.isArray(object?.roles) ? object.roles.map((e: any) => DatabaseRole.fromJSON(e)) : [] };- },-- toJSON(message: ListDatabaseRoleResponse): unknown {- const obj: any = {};- if (message.roles) {- obj.roles = message.roles.map((e) => e ? DatabaseRole.toJSON(e) : undefined);- } else {- obj.roles = [];- }- return obj;- },-- fromPartial<I extends Exact<DeepPartial<ListDatabaseRoleResponse>, I>>(object: I): ListDatabaseRoleResponse {- const message = createBaseListDatabaseRoleResponse();- message.roles = object.roles?.map((e) => DatabaseRole.fromPartial(e)) || [];- return message;- },-};--function createBaseDatabaseRoleUpsert(): DatabaseRoleUpsert {- return { name: "", password: undefined, connectionLimit: undefined, validUntil: undefined, attribute: undefined };-}--export const DatabaseRoleUpsert = {- encode(message: DatabaseRoleUpsert, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {- if (message.name !== "") {- writer.uint32(10).string(message.name);- }- if (message.password !== undefined) {- writer.uint32(18).string(message.password);- }- if (message.connectionLimit !== undefined) {- writer.uint32(24).int32(message.connectionLimit);- }- if (message.validUntil !== undefined) {- writer.uint32(34).string(message.validUntil);- }- if (message.attribute !== undefined) {- DatabaseRoleAttribute.encode(message.attribute, writer.uint32(42).fork()).ldelim();- }- return writer;- },-- decode(input: _m0.Reader | Uint8Array, length?: number): DatabaseRoleUpsert {- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);- let end = length === undefined ? reader.len : reader.pos + length;- const message = createBaseDatabaseRoleUpsert();- while (reader.pos < end) {- const tag = reader.uint32();- switch (tag >>> 3) {- case 1:- message.name = reader.string();- break;- case 2:- message.password = reader.string();- break;- case 3:- message.connectionLimit = reader.int32();- break;- case 4:- message.validUntil = reader.string();- break;- case 5:- message.attribute = DatabaseRoleAttribute.decode(reader, reader.uint32());- break;- default:- reader.skipType(tag & 7);- break;- }- }- return message;- },-- fromJSON(object: any): DatabaseRoleUpsert {- return {- name: isSet(object.name) ? String(object.name) : "",- password: isSet(object.password) ? String(object.password) : undefined,- connectionLimit: isSet(object.connectionLimit) ? Number(object.connectionLimit) : undefined,- validUntil: isSet(object.validUntil) ? String(object.validUntil) : undefined,- attribute: isSet(object.attribute) ? DatabaseRoleAttribute.fromJSON(object.attribute) : undefined,- };- },-- toJSON(message: DatabaseRoleUpsert): unknown {- const obj: any = {};- message.name !== undefined && (obj.name = message.name);- message.password !== undefined && (obj.password = message.password);- message.connectionLimit !== undefined && (obj.connectionLimit = Math.round(message.connectionLimit));- message.validUntil !== undefined && (obj.validUntil = message.validUntil);- message.attribute !== undefined &&- (obj.attribute = message.attribute ? DatabaseRoleAttribute.toJSON(message.attribute) : undefined);- return obj;- },-- fromPartial<I extends Exact<DeepPartial<DatabaseRoleUpsert>, I>>(object: I): DatabaseRoleUpsert {- const message = createBaseDatabaseRoleUpsert();- message.name = object.name ?? "";- message.password = object.password ?? undefined;- message.connectionLimit = object.connectionLimit ?? undefined;- message.validUntil = object.validUntil ?? undefined;- message.attribute = (object.attribute !== undefined && object.attribute !== null)- ? DatabaseRoleAttribute.fromPartial(object.attribute)- : undefined;- return message;- },-};--type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;--export type DeepPartial<T> = T extends Builtin ? T- : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>- : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }- : Partial<T>;--type KeysOfUnion<T> = T extends T ? keyof T : never;-export type Exact<P, I extends P> = P extends Builtin ? P- : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };--function isSet(value: any): boolean {- return value !== null && value !== undefined;-}diff --git a/frontend/src/types/proto/v1/instance_role_service.ts b/frontend/src/types/proto/v1/instance_role_service.tsnew file mode 100644index 0000000000..fb0ed2e9b6--- /dev/null+++ b/frontend/src/types/proto/v1/instance_role_service.ts@@ -0,0 +1,813 @@+/* eslint-disable */+import _m0 from "protobufjs/minimal";+import { Empty } from "../google/protobuf/empty";+import { FieldMask } from "../google/protobuf/field_mask";++export const protobufPackage = "bytebase.v1";++export interface GetRoleRequest {+ /**+ * The name of the role to retrieve.+ * Format: environments/{environment}/instances/{instance}/roles/{role name}+ * The role name is the unique name for the role.+ */+ name: string;+}++export interface ListRolesRequest {+ /**+ * The parent, which owns this collection of roles.+ * Format: environments/{environment}/instances/{instance}+ */+ parent: string;+ /**+ * The maximum number of roles to return. The service may return fewer than+ * this value.+ * If unspecified, at most 50 roles will be returned.+ * The maximum value is 1000; values above 1000 will be coerced to 1000.+ */+ pageSize: number;+ /**+ * A page token, received from a previous `ListRoles` call.+ * Provide this to retrieve the subsequent page.+ *+ * When paginating, all other parameters provided to `ListRoles` must match+ * the call that provided the page token.+ */+ pageToken: string;+}++export interface ListRolesResponse {+ /** The roles from the specified request. */+ roles: DatabaseRole[];+ /**+ * A token, which can be sent as `page_token` to retrieve the next page.+ * If this field is omitted, there are no subsequent pages.+ */+ nextPageToken: string;+}++export interface CreateRoleRequest {+ /**+ * The parent resource where this role will be created.+ * Format: environments/{environment}/instances/{instance}+ */+ parent: string;+ /** The role to create. */+ role?: DatabaseRole;+}++export interface UpdateRoleRequest {+ /**+ * The role to update.+ *+ * The role's `name`, `environment` and `instance` field is used to identify the role to update.+ * Format: environments/{environment}/instances/{instance}/roles/{role name}+ */+ role?: DatabaseRole;+ /** The list of fields to update. */+ updateMask?: string[];+}++export interface DeleteRoleRequest {+ /**+ * The name of the role to delete.+ * Format: environments/{environment}/instances/{instance}/roles/{role name}+ */+ name: string;+}++export interface UndeleteRoleRequest {+ /**+ * The name of the deleted role.+ * Format: environments/{environment}/instances/{instance}/roles/{role name}+ */+ name: string;+}++/** RoleAttribute is the attribute for role. Docs: https://www.postgresql.org/docs/current/role-attributes.html */+export interface DatabaseRoleAttribute {+ /** A database superuser bypasses all permission checks, except the right to log in. */+ superUser: boolean;+ /** A role is given permission to inherit the privileges of roles it is a member of. To create a role without the permission, use "noInherit = true" */+ noInherit: boolean;+ /** A role must be explicitly given permission to create more roles (except for superusers, since those bypass all permission checks). */+ createRole: boolean;+ /** A role must be explicitly given permission to create databases (except for superusers, since those bypass all permission checks). */+ createDb: boolean;+ /** Only roles that have the LOGIN attribute can be used as the initial role name for a database connection. */+ canLogin: boolean;+ /** A role must explicitly be given permission to initiate streaming replication (except for superusers, since those bypass all permission checks). */+ replication: boolean;+ /** A role must be explicitly given permission to bypass every row-level security (RLS) policy (except for superusers, since those bypass all permission checks). */+ bypassRls: boolean;+}++/** DatabaseRole is the API message for database role. */+export interface DatabaseRole {+ /**+ * The name of the role.+ * Format: environments/{environment}/instances/{instance}/roles/{role name}+ * The role name is the unique name for the role.+ */+ name: string;+ /** The role unique name. */+ title: string;+ /** The role password. */+ password?:+ | string+ | undefined;+ /** The connection count limit for this role. */+ connectionLimit?:+ | number+ | undefined;+ /** The expiration for the role's password. */+ validUntil?:+ | string+ | undefined;+ /** The role attribute. */+ attribute?: DatabaseRoleAttribute;+}++function createBaseGetRoleRequest(): GetRoleRequest {+ return { name: "" };+}++export const GetRoleRequest = {+ encode(message: GetRoleRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.name !== "") {+ writer.uint32(10).string(message.name);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): GetRoleRequest {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseGetRoleRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.name = reader.string();+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): GetRoleRequest {+ return { name: isSet(object.name) ? String(object.name) : "" };+ },++ toJSON(message: GetRoleRequest): unknown {+ const obj: any = {};+ message.name !== undefined && (obj.name = message.name);+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<GetRoleRequest>, I>>(object: I): GetRoleRequest {+ const message = createBaseGetRoleRequest();+ message.name = object.name ?? "";+ return message;+ },+};++function createBaseListRolesRequest(): ListRolesRequest {+ return { parent: "", pageSize: 0, pageToken: "" };+}++export const ListRolesRequest = {+ encode(message: ListRolesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.parent !== "") {+ writer.uint32(10).string(message.parent);+ }+ if (message.pageSize !== 0) {+ writer.uint32(16).int32(message.pageSize);+ }+ if (message.pageToken !== "") {+ writer.uint32(26).string(message.pageToken);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): ListRolesRequest {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseListRolesRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.parent = reader.string();+ break;+ case 2:+ message.pageSize = reader.int32();+ break;+ case 3:+ message.pageToken = reader.string();+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): ListRolesRequest {+ return {+ parent: isSet(object.parent) ? String(object.parent) : "",+ pageSize: isSet(object.pageSize) ? Number(object.pageSize) : 0,+ pageToken: isSet(object.pageToken) ? String(object.pageToken) : "",+ };+ },++ toJSON(message: ListRolesRequest): unknown {+ const obj: any = {};+ message.parent !== undefined && (obj.parent = message.parent);+ message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize));+ message.pageToken !== undefined && (obj.pageToken = message.pageToken);+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<ListRolesRequest>, I>>(object: I): ListRolesRequest {+ const message = createBaseListRolesRequest();+ message.parent = object.parent ?? "";+ message.pageSize = object.pageSize ?? 0;+ message.pageToken = object.pageToken ?? "";+ return message;+ },+};++function createBaseListRolesResponse(): ListRolesResponse {+ return { roles: [], nextPageToken: "" };+}++export const ListRolesResponse = {+ encode(message: ListRolesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ for (const v of message.roles) {+ DatabaseRole.encode(v!, writer.uint32(10).fork()).ldelim();+ }+ if (message.nextPageToken !== "") {+ writer.uint32(18).string(message.nextPageToken);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): ListRolesResponse {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseListRolesResponse();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.roles.push(DatabaseRole.decode(reader, reader.uint32()));+ break;+ case 2:+ message.nextPageToken = reader.string();+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): ListRolesResponse {+ return {+ roles: Array.isArray(object?.roles) ? object.roles.map((e: any) => DatabaseRole.fromJSON(e)) : [],+ nextPageToken: isSet(object.nextPageToken) ? String(object.nextPageToken) : "",+ };+ },++ toJSON(message: ListRolesResponse): unknown {+ const obj: any = {};+ if (message.roles) {+ obj.roles = message.roles.map((e) => e ? DatabaseRole.toJSON(e) : undefined);+ } else {+ obj.roles = [];+ }+ message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<ListRolesResponse>, I>>(object: I): ListRolesResponse {+ const message = createBaseListRolesResponse();+ message.roles = object.roles?.map((e) => DatabaseRole.fromPartial(e)) || [];+ message.nextPageToken = object.nextPageToken ?? "";+ return message;+ },+};++function createBaseCreateRoleRequest(): CreateRoleRequest {+ return { parent: "", role: undefined };+}++export const CreateRoleRequest = {+ encode(message: CreateRoleRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.parent !== "") {+ writer.uint32(10).string(message.parent);+ }+ if (message.role !== undefined) {+ DatabaseRole.encode(message.role, writer.uint32(18).fork()).ldelim();+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): CreateRoleRequest {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseCreateRoleRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.parent = reader.string();+ break;+ case 2:+ message.role = DatabaseRole.decode(reader, reader.uint32());+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): CreateRoleRequest {+ return {+ parent: isSet(object.parent) ? String(object.parent) : "",+ role: isSet(object.role) ? DatabaseRole.fromJSON(object.role) : undefined,+ };+ },++ toJSON(message: CreateRoleRequest): unknown {+ const obj: any = {};+ message.parent !== undefined && (obj.parent = message.parent);+ message.role !== undefined && (obj.role = message.role ? DatabaseRole.toJSON(message.role) : undefined);+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<CreateRoleRequest>, I>>(object: I): CreateRoleRequest {+ const message = createBaseCreateRoleRequest();+ message.parent = object.parent ?? "";+ message.role = (object.role !== undefined && object.role !== null)+ ? DatabaseRole.fromPartial(object.role)+ : undefined;+ return message;+ },+};++function createBaseUpdateRoleRequest(): UpdateRoleRequest {+ return { role: undefined, updateMask: undefined };+}++export const UpdateRoleRequest = {+ encode(message: UpdateRoleRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.role !== undefined) {+ DatabaseRole.encode(message.role, writer.uint32(10).fork()).ldelim();+ }+ if (message.updateMask !== undefined) {+ FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(18).fork()).ldelim();+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): UpdateRoleRequest {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseUpdateRoleRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.role = DatabaseRole.decode(reader, reader.uint32());+ break;+ case 2:+ message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): UpdateRoleRequest {+ return {+ role: isSet(object.role) ? DatabaseRole.fromJSON(object.role) : undefined,+ updateMask: isSet(object.updateMask) ? FieldMask.unwrap(FieldMask.fromJSON(object.updateMask)) : undefined,+ };+ },++ toJSON(message: UpdateRoleRequest): unknown {+ const obj: any = {};+ message.role !== undefined && (obj.role = message.role ? DatabaseRole.toJSON(message.role) : undefined);+ message.updateMask !== undefined && (obj.updateMask = FieldMask.toJSON(FieldMask.wrap(message.updateMask)));+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<UpdateRoleRequest>, I>>(object: I): UpdateRoleRequest {+ const message = createBaseUpdateRoleRequest();+ message.role = (object.role !== undefined && object.role !== null)+ ? DatabaseRole.fromPartial(object.role)+ : undefined;+ message.updateMask = object.updateMask ?? undefined;+ return message;+ },+};++function createBaseDeleteRoleRequest(): DeleteRoleRequest {+ return { name: "" };+}++export const DeleteRoleRequest = {+ encode(message: DeleteRoleRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.name !== "") {+ writer.uint32(10).string(message.name);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): DeleteRoleRequest {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseDeleteRoleRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.name = reader.string();+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): DeleteRoleRequest {+ return { name: isSet(object.name) ? String(object.name) : "" };+ },++ toJSON(message: DeleteRoleRequest): unknown {+ const obj: any = {};+ message.name !== undefined && (obj.name = message.name);+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<DeleteRoleRequest>, I>>(object: I): DeleteRoleRequest {+ const message = createBaseDeleteRoleRequest();+ message.name = object.name ?? "";+ return message;+ },+};++function createBaseUndeleteRoleRequest(): UndeleteRoleRequest {+ return { name: "" };+}++export const UndeleteRoleRequest = {+ encode(message: UndeleteRoleRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.name !== "") {+ writer.uint32(10).string(message.name);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): UndeleteRoleRequest {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseUndeleteRoleRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.name = reader.string();+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): UndeleteRoleRequest {+ return { name: isSet(object.name) ? String(object.name) : "" };+ },++ toJSON(message: UndeleteRoleRequest): unknown {+ const obj: any = {};+ message.name !== undefined && (obj.name = message.name);+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<UndeleteRoleRequest>, I>>(object: I): UndeleteRoleRequest {+ const message = createBaseUndeleteRoleRequest();+ message.name = object.name ?? "";+ return message;+ },+};++function createBaseDatabaseRoleAttribute(): DatabaseRoleAttribute {+ return {+ superUser: false,+ noInherit: false,+ createRole: false,+ createDb: false,+ canLogin: false,+ replication: false,+ bypassRls: false,+ };+}++export const DatabaseRoleAttribute = {+ encode(message: DatabaseRoleAttribute, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.superUser === true) {+ writer.uint32(8).bool(message.superUser);+ }+ if (message.noInherit === true) {+ writer.uint32(16).bool(message.noInherit);+ }+ if (message.createRole === true) {+ writer.uint32(24).bool(message.createRole);+ }+ if (message.createDb === true) {+ writer.uint32(32).bool(message.createDb);+ }+ if (message.canLogin === true) {+ writer.uint32(40).bool(message.canLogin);+ }+ if (message.replication === true) {+ writer.uint32(48).bool(message.replication);+ }+ if (message.bypassRls === true) {+ writer.uint32(56).bool(message.bypassRls);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): DatabaseRoleAttribute {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseDatabaseRoleAttribute();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.superUser = reader.bool();+ break;+ case 2:+ message.noInherit = reader.bool();+ break;+ case 3:+ message.createRole = reader.bool();+ break;+ case 4:+ message.createDb = reader.bool();+ break;+ case 5:+ message.canLogin = reader.bool();+ break;+ case 6:+ message.replication = reader.bool();+ break;+ case 7:+ message.bypassRls = reader.bool();+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): DatabaseRoleAttribute {+ return {+ superUser: isSet(object.superUser) ? Boolean(object.superUser) : false,+ noInherit: isSet(object.noInherit) ? Boolean(object.noInherit) : false,+ createRole: isSet(object.createRole) ? Boolean(object.createRole) : false,+ createDb: isSet(object.createDb) ? Boolean(object.createDb) : false,+ canLogin: isSet(object.canLogin) ? Boolean(object.canLogin) : false,+ replication: isSet(object.replication) ? Boolean(object.replication) : false,+ bypassRls: isSet(object.bypassRls) ? Boolean(object.bypassRls) : false,+ };+ },++ toJSON(message: DatabaseRoleAttribute): unknown {+ const obj: any = {};+ message.superUser !== undefined && (obj.superUser = message.superUser);+ message.noInherit !== undefined && (obj.noInherit = message.noInherit);+ message.createRole !== undefined && (obj.createRole = message.createRole);+ message.createDb !== undefined && (obj.createDb = message.createDb);+ message.canLogin !== undefined && (obj.canLogin = message.canLogin);+ message.replication !== undefined && (obj.replication = message.replication);+ message.bypassRls !== undefined && (obj.bypassRls = message.bypassRls);+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<DatabaseRoleAttribute>, I>>(object: I): DatabaseRoleAttribute {+ const message = createBaseDatabaseRoleAttribute();+ message.superUser = object.superUser ?? false;+ message.noInherit = object.noInherit ?? false;+ message.createRole = object.createRole ?? false;+ message.createDb = object.createDb ?? false;+ message.canLogin = object.canLogin ?? false;+ message.replication = object.replication ?? false;+ message.bypassRls = object.bypassRls ?? false;+ return message;+ },+};++function createBaseDatabaseRole(): DatabaseRole {+ return {+ name: "",+ title: "",+ password: undefined,+ connectionLimit: undefined,+ validUntil: undefined,+ attribute: undefined,+ };+}++export const DatabaseRole = {+ encode(message: DatabaseRole, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.name !== "") {+ writer.uint32(10).string(message.name);+ }+ if (message.title !== "") {+ writer.uint32(18).string(message.title);+ }+ if (message.password !== undefined) {+ writer.uint32(26).string(message.password);+ }+ if (message.connectionLimit !== undefined) {+ writer.uint32(32).int32(message.connectionLimit);+ }+ if (message.validUntil !== undefined) {+ writer.uint32(42).string(message.validUntil);+ }+ if (message.attribute !== undefined) {+ DatabaseRoleAttribute.encode(message.attribute, writer.uint32(50).fork()).ldelim();+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): DatabaseRole {+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseDatabaseRole();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ message.name = reader.string();+ break;+ case 2:+ message.title = reader.string();+ break;+ case 3:+ message.password = reader.string();+ break;+ case 4:+ message.connectionLimit = reader.int32();+ break;+ case 5:+ message.validUntil = reader.string();+ break;+ case 6:+ message.attribute = DatabaseRoleAttribute.decode(reader, reader.uint32());+ break;+ default:+ reader.skipType(tag & 7);+ break;+ }+ }+ return message;+ },++ fromJSON(object: any): DatabaseRole {+ return {+ name: isSet(object.name) ? String(object.name) : "",+ title: isSet(object.title) ? String(object.title) : "",+ password: isSet(object.password) ? String(object.password) : undefined,+ connectionLimit: isSet(object.connectionLimit) ? Number(object.connectionLimit) : undefined,+ validUntil: isSet(object.validUntil) ? String(object.validUntil) : undefined,+ attribute: isSet(object.attribute) ? DatabaseRoleAttribute.fromJSON(object.attribute) : undefined,+ };+ },++ toJSON(message: DatabaseRole): unknown {+ const obj: any = {};+ message.name !== undefined && (obj.name = message.name);+ message.title !== undefined && (obj.title = message.title);+ message.password !== undefined && (obj.password = message.password);+ message.connectionLimit !== undefined && (obj.connectionLimit = Math.round(message.connectionLimit));+ message.validUntil !== undefined && (obj.validUntil = message.validUntil);+ message.attribute !== undefined &&+ (obj.attribute = message.attribute ? DatabaseRoleAttribute.toJSON(message.attribute) : undefined);+ return obj;+ },++ fromPartial<I extends Exact<DeepPartial<DatabaseRole>, I>>(object: I): DatabaseRole {+ const message = createBaseDatabaseRole();+ message.name = object.name ?? "";+ message.title = object.title ?? "";+ message.password = object.password ?? undefined;+ message.connectionLimit = object.connectionLimit ?? undefined;+ message.validUntil = object.validUntil ?? undefined;+ message.attribute = (object.attribute !== undefined && object.attribute !== null)+ ? DatabaseRoleAttribute.fromPartial(object.attribute)+ : undefined;+ return message;+ },+};++export interface InstanceRoleService {+ GetRole(request: GetRoleRequest): Promise<DatabaseRole>;+ ListRoles(request: ListRolesRequest): Promise<ListRolesResponse>;+ CreateRole(request: CreateRoleRequest): Promise<DatabaseRole>;+ UpdateRole(request: UpdateRoleRequest): Promise<DatabaseRole>;+ DeleteRole(request: DeleteRoleRequest): Promise<Empty>;+ UndeleteRole(request: UndeleteRoleRequest): Promise<DatabaseRole>;+}++export class InstanceRoleServiceClientImpl implements InstanceRoleService {+ private readonly rpc: Rpc;+ private readonly service: string;+ constructor(rpc: Rpc, opts?: { service?: string }) {+ this.service = opts?.service || "bytebase.v1.InstanceRoleService";+ this.rpc = rpc;+ this.GetRole = this.GetRole.bind(this);+ this.ListRoles = this.ListRoles.bind(this);+ this.CreateRole = this.CreateRole.bind(this);+ this.UpdateRole = this.UpdateRole.bind(this);+ this.DeleteRole = this.DeleteRole.bind(this);+ this.UndeleteRole = this.UndeleteRole.bind(this);+ }+ GetRole(request: GetRoleRequest): Promise<DatabaseRole> {+ const data = GetRoleRequest.encode(request).finish();+ const promise = this.rpc.request(this.service, "GetRole", data);+ return promise.then((data) => DatabaseRole.decode(new _m0.Reader(data)));+ }++ ListRoles(request: ListRolesRequest): Promise<ListRolesResponse> {+ const data = ListRolesRequest.encode(request).finish();+ const promise = this.rpc.request(this.service, "ListRoles", data);+ return promise.then((data) => ListRolesResponse.decode(new _m0.Reader(data)));+ }++ CreateRole(request: CreateRoleRequest): Promise<DatabaseRole> {+ const data = CreateRoleRequest.encode(request).finish();+ const promise = this.rpc.request(this.service, "CreateRole", data);+ return promise.then((data) => DatabaseRole.decode(new _m0.Reader(data)));+ }++ UpdateRole(request: UpdateRoleRequest): Promise<DatabaseRole> {+ const data = UpdateRoleRequest.encode(request).finish();+ const promise = this.rpc.request(this.service, "UpdateRole", data);+ return promise.then((data) => DatabaseRole.decode(new _m0.Reader(data)));+ }++ DeleteRole(request: DeleteRoleRequest): Promise<Empty> {+ const data = DeleteRoleRequest.encode(request).finish();+ const promise = this.rpc.request(this.service, "DeleteRole", data);+ return promise.then((data) => Empty.decode(new _m0.Reader(data)));+ }++ UndeleteRole(request: UndeleteRoleRequest): Promise<DatabaseRole> {+ const data = UndeleteRoleRequest.encode(request).finish();+ const promise = this.rpc.request(this.service, "UndeleteRole", data);+ return promise.then((data) => DatabaseRole.decode(new _m0.Reader(data)));+ }+}++interface Rpc {+ request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;+}++type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;++export type DeepPartial<T> = T extends Builtin ? T+ : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }+ : Partial<T>;++type KeysOfUnion<T> = T extends T ? keyof T : never;+export type Exact<P, I extends P> = P extends Builtin ? P+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };++function isSet(value: any): boolean {+ return value !== null && value !== undefined;+}diff --git a/plugin/advisor/utils_for_tests.go b/plugin/advisor/utils_for_tests.goindex 1eef7b328c..72a1064c8d 100644--- a/plugin/advisor/utils_for_tests.go+++ b/plugin/advisor/utils_for_tests.go@@ -20,7 +20,6 @@ import ("github.com/bytebase/bytebase/plugin/advisor/db"database "github.com/bytebase/bytebase/plugin/db"storepb "github.com/bytebase/bytebase/proto/generated-go/store"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")var (@@ -324,22 +323,22 @@ func (*MockDriver) Restore(_ context.Context, _ io.Reader) error {}// CreateRole creates the role.-func (*MockDriver) CreateRole(_ context.Context, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*MockDriver) CreateRole(_ context.Context, _ *database.DatabaseRoleUpsertMessage) (*database.DatabaseRoleMessage, error) {return nil, nil}// UpdateRole updates the role.-func (*MockDriver) UpdateRole(_ context.Context, _ string, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*MockDriver) UpdateRole(_ context.Context, _ string, _ *database.DatabaseRoleUpsertMessage) (*database.DatabaseRoleMessage, error) {return nil, nil}// FindRole finds the role by name.-func (*MockDriver) FindRole(_ context.Context, _ string) (*v1pb.DatabaseRole, error) {+func (*MockDriver) FindRole(_ context.Context, _ string) (*database.DatabaseRoleMessage, error) {return nil, nil}// ListRole lists the role.-func (*MockDriver) ListRole(_ context.Context) ([]*v1pb.DatabaseRole, error) {+func (*MockDriver) ListRole(_ context.Context) ([]*database.DatabaseRoleMessage, error) {return nil, nil}diff --git a/plugin/db/clickhouse/role.go b/plugin/db/clickhouse/role.goindex bed731f225..180835c84b 100644--- a/plugin/db/clickhouse/role.go+++ b/plugin/db/clickhouse/role.go@@ -5,26 +5,26 @@ import ("github.com/pkg/errors"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+ "github.com/bytebase/bytebase/plugin/db")// CreateRole creates the role.-func (*Driver) CreateRole(_ context.Context, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) CreateRole(_ context.Context, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("create role for ClickHouse is not implemented yet")}// UpdateRole updates the role.-func (*Driver) UpdateRole(_ context.Context, _ string, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) UpdateRole(_ context.Context, _ string, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("update role for ClickHouse is not implemented yet")}// FindRole finds the role by name.-func (*Driver) FindRole(_ context.Context, _ string) (*v1pb.DatabaseRole, error) {+func (*Driver) FindRole(_ context.Context, _ string) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("find role for ClickHouse is not implemented yet")}// ListRole lists the role.-func (*Driver) ListRole(_ context.Context) ([]*v1pb.DatabaseRole, error) {+func (*Driver) ListRole(_ context.Context) ([]*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("list role for ClickHouse is not implemented yet")}diff --git a/plugin/db/driver.go b/plugin/db/driver.goindex 579857767b..83827e9e53 100644--- a/plugin/db/driver.go+++ b/plugin/db/driver.go@@ -15,7 +15,6 @@ import ("github.com/bytebase/bytebase/plugin/vcs"storepb "github.com/bytebase/bytebase/proto/generated-go/store"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")// Type is the type of a database.@@ -385,6 +384,50 @@ type QueryContext struct {CurrentDatabase string}+// DatabaseRoleAttributeMessage is the attribute for role. Docs: https://www.postgresql.org/docs/current/role-attributes.html+type DatabaseRoleAttributeMessage struct {+ // A database superuser bypasses all permission checks, except the right to log in.+ SuperUser bool+ // A role is given permission to inherit the privileges of roles it is a member of. To create a role without the permission, use "noInherit = true"+ NoInherit bool+ // A role must be explicitly given permission to create more roles (except for superusers, since those bypass all permission checks).+ CreateRole bool+ // A role must be explicitly given permission to create databases (except for superusers, since those bypass all permission checks).+ CreateDb bool+ // Only roles that have the LOGIN attribute can be used as the initial role name for a database connection.+ CanLogin bool+ // A role must explicitly be given permission to initiate streaming replication (except for superusers, since those bypass all permission checks).+ Replication bool+ // A role must be explicitly given permission to bypass every row-level security (RLS) policy (except for superusers, since those bypass all permission checks).+ BypassRls bool+}++// DatabaseRoleMessage is the API message for database role.+type DatabaseRoleMessage struct {+ // The role unique name.+ Name string+ // The connection count limit for this role.+ ConnectionLimit int32+ // The expiration for the role's password.+ ValidUntil *string+ // The role attribute.+ Attribute *DatabaseRoleAttributeMessage+}++// DatabaseRoleUpsertMessage is the API message for upserting a database role.+type DatabaseRoleUpsertMessage struct {+ // The role unique name.+ Name string+ // A password is only significant if the client authentication method requires the user to supply a password when connecting to the database.+ Password *string+ // Connection limit can specify how many concurrent connections a role can make. -1 (the default) means no limit.+ ConnectionLimit *int32+ // The VALID UNTIL clause sets a date and time after which the role's password is no longer valid. If this clause is omitted the password will be valid for all time.+ ValidUntil *string+ // The role attribute.+ Attribute *DatabaseRoleAttributeMessage+}+// Driver is the interface for database driver.type Driver interface {// General execution@@ -410,13 +453,13 @@ type Driver interface {// Role// CreateRole creates the role.- CreateRole(ctx context.Context, upsert *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error)+ CreateRole(ctx context.Context, upsert *DatabaseRoleUpsertMessage) (*DatabaseRoleMessage, error)// UpdateRole updates the role.- UpdateRole(ctx context.Context, roleName string, upsert *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error)+ UpdateRole(ctx context.Context, roleName string, upsert *DatabaseRoleUpsertMessage) (*DatabaseRoleMessage, error)// FindRole finds the role by name.- FindRole(ctx context.Context, roleName string) (*v1pb.DatabaseRole, error)+ FindRole(ctx context.Context, roleName string) (*DatabaseRoleMessage, error)// ListRole lists the role.- ListRole(ctx context.Context) ([]*v1pb.DatabaseRole, error)+ ListRole(ctx context.Context) ([]*DatabaseRoleMessage, error)// DeleteRole deletes the role by name.DeleteRole(ctx context.Context, roleName string) errordiff --git a/plugin/db/mongodb/role.go b/plugin/db/mongodb/role.goindex 27d0f47f4e..548e7ab0f5 100644--- a/plugin/db/mongodb/role.go+++ b/plugin/db/mongodb/role.go@@ -5,26 +5,26 @@ import ("github.com/pkg/errors"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+ "github.com/bytebase/bytebase/plugin/db")// CreateRole creates the role.-func (*Driver) CreateRole(_ context.Context, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) CreateRole(_ context.Context, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("create role for MongoDB is not implemented yet")}// UpdateRole updates the role.-func (*Driver) UpdateRole(_ context.Context, _ string, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) UpdateRole(_ context.Context, _ string, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("update role for MongoDB is not implemented yet")}// FindRole finds the role by name.-func (*Driver) FindRole(_ context.Context, _ string) (*v1pb.DatabaseRole, error) {+func (*Driver) FindRole(_ context.Context, _ string) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("find role for MongoDB is not implemented yet")}// ListRole lists the role.-func (*Driver) ListRole(_ context.Context) ([]*v1pb.DatabaseRole, error) {+func (*Driver) ListRole(_ context.Context) ([]*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("list role for MongoDB is not implemented yet")}diff --git a/plugin/db/mysql/role.go b/plugin/db/mysql/role.goindex 63283879da..7a5a540ea1 100644--- a/plugin/db/mysql/role.go+++ b/plugin/db/mysql/role.go@@ -5,26 +5,26 @@ import ("github.com/pkg/errors"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+ "github.com/bytebase/bytebase/plugin/db")// CreateRole creates the role.-func (*Driver) CreateRole(_ context.Context, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) CreateRole(_ context.Context, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("create role for MySQL is not implemented yet")}// UpdateRole updates the role.-func (*Driver) UpdateRole(_ context.Context, _ string, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) UpdateRole(_ context.Context, _ string, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("update role for MySQL is not implemented yet")}// FindRole finds the role by name.-func (*Driver) FindRole(_ context.Context, _ string) (*v1pb.DatabaseRole, error) {+func (*Driver) FindRole(_ context.Context, _ string) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("find role for MySQL is not implemented yet")}// ListRole lists the role.-func (*Driver) ListRole(_ context.Context) ([]*v1pb.DatabaseRole, error) {+func (*Driver) ListRole(_ context.Context) ([]*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("list role for MySQL is not implemented yet")}diff --git a/plugin/db/pg/role.go b/plugin/db/pg/role.goindex be043192d6..7e64b9a1e0 100644--- a/plugin/db/pg/role.go+++ b/plugin/db/pg/role.go@@ -7,8 +7,8 @@ import ("strings""github.com/bytebase/bytebase/common"+ "github.com/bytebase/bytebase/plugin/db""github.com/bytebase/bytebase/plugin/db/util"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")// RoleAttribute is the attribute string for role.@@ -55,7 +55,7 @@ type roleFind struct {}// CreateRole will create the PG role.-func (driver *Driver) CreateRole(ctx context.Context, upsert *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (driver *Driver) CreateRole(ctx context.Context, upsert *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {txn, err := driver.db.BeginTx(ctx, nil)if err != nil {return nil, err@@ -84,7 +84,7 @@ func (driver *Driver) CreateRole(ctx context.Context, upsert *v1pb.DatabaseRoleU}// UpdateRole will alter the PG role.-func (driver *Driver) UpdateRole(ctx context.Context, roleName string, upsert *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (driver *Driver) UpdateRole(ctx context.Context, roleName string, upsert *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {txn, err := driver.db.BeginTx(ctx, nil)if err != nil {return nil, err@@ -113,7 +113,7 @@ func (driver *Driver) UpdateRole(ctx context.Context, roleName string, upsert *v}// FindRole will find the PG role by name.-func (driver *Driver) FindRole(ctx context.Context, roleName string) (*v1pb.DatabaseRole, error) {+func (driver *Driver) FindRole(ctx context.Context, roleName string) (*db.DatabaseRoleMessage, error) {txn, err := driver.db.BeginTx(ctx, nil)if err != nil {return nil, err@@ -138,7 +138,7 @@ func (driver *Driver) FindRole(ctx context.Context, roleName string) (*v1pb.Data}// ListRole lists the role.-func (driver *Driver) ListRole(ctx context.Context) ([]*v1pb.DatabaseRole, error) {+func (driver *Driver) ListRole(ctx context.Context) ([]*db.DatabaseRoleMessage, error) {txn, err := driver.db.BeginTx(ctx, nil)if err != nil {return nil, err@@ -167,7 +167,7 @@ func (driver *Driver) DeleteRole(ctx context.Context, roleName string) error {return nil}-func findRoleImpl(ctx context.Context, txn *sql.Tx, find *roleFind) ([]*v1pb.DatabaseRole, error) {+func findRoleImpl(ctx context.Context, txn *sql.Tx, find *roleFind) ([]*db.DatabaseRoleMessage, error) {where := []string{}if v := find.Name; v != nil {where = append(where, fmt.Sprintf("r.rolname = '%s'", *v))@@ -198,12 +198,12 @@ func findRoleImpl(ctx context.Context, txn *sql.Tx, find *roleFind) ([]*v1pb.Dat}defer rows.Close()- var roleList []*v1pb.DatabaseRole+ var roleList []*db.DatabaseRoleMessagefor rows.Next() {inherit := false- role := &v1pb.DatabaseRole{- Attribute: &v1pb.DatabaseRoleAttribute{},+ role := &db.DatabaseRoleMessage{+ Attribute: &db.DatabaseRoleAttributeMessage{},}if err := rows.Scan(@@ -231,7 +231,7 @@ func findRoleImpl(ctx context.Context, txn *sql.Tx, find *roleFind) ([]*v1pb.Datreturn roleList, nil}-func createRoleImpl(ctx context.Context, txn *sql.Tx, upsert *v1pb.DatabaseRoleUpsert) error {+func createRoleImpl(ctx context.Context, txn *sql.Tx, upsert *db.DatabaseRoleUpsertMessage) error {statement := fmt.Sprintf(`CREATE ROLE "%s" %s;`, upsert.Name, convertToAttributeStatement(upsert))if _, err := txn.ExecContext(ctx, statement); err != nil {return util.FormatErrorWithQuery(err, statement)@@ -240,7 +240,7 @@ func createRoleImpl(ctx context.Context, txn *sql.Tx, upsert *v1pb.DatabaseRoleUreturn nil}-func alterRoleImpl(ctx context.Context, txn *sql.Tx, roleName string, upsert *v1pb.DatabaseRoleUpsert) error {+func alterRoleImpl(ctx context.Context, txn *sql.Tx, roleName string, upsert *db.DatabaseRoleUpsertMessage) error {if roleName != upsert.Name {renameStatement := fmt.Sprintf(`ALTER ROLE "%s" RENAME TO "%s";`, roleName, upsert.Name)if _, err := txn.ExecContext(ctx, renameStatement); err != nil {@@ -261,7 +261,7 @@ func alterRoleImpl(ctx context.Context, txn *sql.Tx, roleName string, upsert *v1return nil}-func convertToAttributeStatement(r *v1pb.DatabaseRoleUpsert) string {+func convertToAttributeStatement(r *db.DatabaseRoleUpsertMessage) string {attributeList := []string{}if r.Attribute != nil {diff --git a/plugin/db/snowflake/role.go b/plugin/db/snowflake/role.goindex 73a967ee09..03978f5d51 100644--- a/plugin/db/snowflake/role.go+++ b/plugin/db/snowflake/role.go@@ -5,26 +5,26 @@ import ("github.com/pkg/errors"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+ "github.com/bytebase/bytebase/plugin/db")// CreateRole creates the role.-func (*Driver) CreateRole(_ context.Context, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) CreateRole(_ context.Context, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("create role for Snowflake is not implemented yet")}// UpdateRole updates the role.-func (*Driver) UpdateRole(_ context.Context, _ string, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) UpdateRole(_ context.Context, _ string, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("update role for Snowflake is not implemented yet")}// FindRole finds the role by name.-func (*Driver) FindRole(_ context.Context, _ string) (*v1pb.DatabaseRole, error) {+func (*Driver) FindRole(_ context.Context, _ string) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("find role for Snowflake is not implemented yet")}// ListRole lists the role.-func (*Driver) ListRole(_ context.Context) ([]*v1pb.DatabaseRole, error) {+func (*Driver) ListRole(_ context.Context) ([]*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("list role for Snowflake is not implemented yet")}diff --git a/plugin/db/spanner/role.go b/plugin/db/spanner/role.goindex 2cdd330965..2395488b04 100644--- a/plugin/db/spanner/role.go+++ b/plugin/db/spanner/role.go@@ -3,30 +3,32 @@ package spannerimport ("context"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+ "github.com/pkg/errors"++ "github.com/bytebase/bytebase/plugin/db")-// CreateRole creates a role.-func (*Driver) CreateRole(_ context.Context, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {- panic("not implemented")+// CreateRole creates the role.+func (*Driver) CreateRole(_ context.Context, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {+ return nil, errors.Errorf("create role for spanner is not implemented yet")}-// UpdateRole updates a role.-func (*Driver) UpdateRole(_ context.Context, _ string, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {- panic("not implemented")+// UpdateRole updates the role.+func (*Driver) UpdateRole(_ context.Context, _ string, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {+ return nil, errors.Errorf("update role for spanner is not implemented yet")}-// FindRole finds the role.-func (*Driver) FindRole(_ context.Context, _ string) (*v1pb.DatabaseRole, error) {- panic("not implemented")+// FindRole finds the role by name.+func (*Driver) FindRole(_ context.Context, _ string) (*db.DatabaseRoleMessage, error) {+ return nil, errors.Errorf("find role for spanner is not implemented yet")}-// ListRole lists the roles.-func (*Driver) ListRole(_ context.Context) ([]*v1pb.DatabaseRole, error) {- panic("not implemented")+// ListRole lists the role.+func (*Driver) ListRole(_ context.Context) ([]*db.DatabaseRoleMessage, error) {+ return nil, errors.Errorf("list role for spanner is not implemented yet")}-// DeleteRole deletes the role.+// DeleteRole deletes the role by name.func (*Driver) DeleteRole(_ context.Context, _ string) error {- panic("not implemented")+ return errors.Errorf("delete role for spanner is not implemented yet")}diff --git a/plugin/db/sqlite/role.go b/plugin/db/sqlite/role.goindex 36f20bb5e1..6716e982e1 100644--- a/plugin/db/sqlite/role.go+++ b/plugin/db/sqlite/role.go@@ -5,26 +5,26 @@ import ("github.com/pkg/errors"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+ "github.com/bytebase/bytebase/plugin/db")// CreateRole creates the role.-func (*Driver) CreateRole(_ context.Context, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) CreateRole(_ context.Context, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("create role for SQLite is not implemented yet")}// UpdateRole updates the role.-func (*Driver) UpdateRole(_ context.Context, _ string, _ *v1pb.DatabaseRoleUpsert) (*v1pb.DatabaseRole, error) {+func (*Driver) UpdateRole(_ context.Context, _ string, _ *db.DatabaseRoleUpsertMessage) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("update role for SQLite is not implemented yet")}// FindRole finds the role by name.-func (*Driver) FindRole(_ context.Context, _ string) (*v1pb.DatabaseRole, error) {+func (*Driver) FindRole(_ context.Context, _ string) (*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("find role for SQLite is not implemented yet")}// ListRole lists the role.-func (*Driver) ListRole(_ context.Context) ([]*v1pb.DatabaseRole, error) {+func (*Driver) ListRole(_ context.Context) ([]*db.DatabaseRoleMessage, error) {return nil, errors.Errorf("list role for SQLite is not implemented yet")}diff --git a/proto/generated-go/v1/database_role.pb.go b/proto/generated-go/v1/database_role.pb.godeleted file mode 100644index ffcee7cca9..0000000000--- a/proto/generated-go/v1/database_role.pb.go+++ /dev/null@@ -1,512 +0,0 @@-// Code generated by protoc-gen-go. DO NOT EDIT.-// versions:-// protoc-gen-go v1.28.1-// protoc (unknown)-// source: v1/database_role.proto--package v1--import (- protoreflect "google.golang.org/protobuf/reflect/protoreflect"- protoimpl "google.golang.org/protobuf/runtime/protoimpl"- reflect "reflect"- sync "sync"-)--const (- // Verify that this generated code is sufficiently up-to-date.- _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)- // Verify that runtime/protoimpl is sufficiently up-to-date.- _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)-)--// RoleAttribute is the attribute for role. Docs: https://www.postgresql.org/docs/current/role-attributes.html-type DatabaseRoleAttribute struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- // A database superuser bypasses all permission checks, except the right to log in.- SuperUser bool `protobuf:"varint,1,opt,name=super_user,json=superUser,proto3" json:"super_user,omitempty"`- // A role is given permission to inherit the privileges of roles it is a member of. To create a role without the permission, use "noInherit = true"- NoInherit bool `protobuf:"varint,2,opt,name=no_inherit,json=noInherit,proto3" json:"no_inherit,omitempty"`- // A role must be explicitly given permission to create more roles (except for superusers, since those bypass all permission checks).- CreateRole bool `protobuf:"varint,3,opt,name=create_role,json=createRole,proto3" json:"create_role,omitempty"`- // A role must be explicitly given permission to create databases (except for superusers, since those bypass all permission checks).- CreateDb bool `protobuf:"varint,4,opt,name=create_db,json=createDb,proto3" json:"create_db,omitempty"`- // Only roles that have the LOGIN attribute can be used as the initial role name for a database connection.- CanLogin bool `protobuf:"varint,5,opt,name=can_login,json=canLogin,proto3" json:"can_login,omitempty"`- // A role must explicitly be given permission to initiate streaming replication (except for superusers, since those bypass all permission checks).- Replication bool `protobuf:"varint,6,opt,name=replication,proto3" json:"replication,omitempty"`- // A role must be explicitly given permission to bypass every row-level security (RLS) policy (except for superusers, since those bypass all permission checks).- BypassRls bool `protobuf:"varint,7,opt,name=bypass_rls,json=bypassRls,proto3" json:"bypass_rls,omitempty"`-}--func (x *DatabaseRoleAttribute) Reset() {- *x = DatabaseRoleAttribute{}- if protoimpl.UnsafeEnabled {- mi := &file_v1_database_role_proto_msgTypes[0]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)- }-}--func (x *DatabaseRoleAttribute) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DatabaseRoleAttribute) ProtoMessage() {}--func (x *DatabaseRoleAttribute) ProtoReflect() protoreflect.Message {- mi := &file_v1_database_role_proto_msgTypes[0]- if protoimpl.UnsafeEnabled && x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DatabaseRoleAttribute.ProtoReflect.Descriptor instead.-func (*DatabaseRoleAttribute) Descriptor() ([]byte, []int) {- return file_v1_database_role_proto_rawDescGZIP(), []int{0}-}--func (x *DatabaseRoleAttribute) GetSuperUser() bool {- if x != nil {- return x.SuperUser- }- return false-}--func (x *DatabaseRoleAttribute) GetNoInherit() bool {- if x != nil {- return x.NoInherit- }- return false-}--func (x *DatabaseRoleAttribute) GetCreateRole() bool {- if x != nil {- return x.CreateRole- }- return false-}--func (x *DatabaseRoleAttribute) GetCreateDb() bool {- if x != nil {- return x.CreateDb- }- return false-}--func (x *DatabaseRoleAttribute) GetCanLogin() bool {- if x != nil {- return x.CanLogin- }- return false-}--func (x *DatabaseRoleAttribute) GetReplication() bool {- if x != nil {- return x.Replication- }- return false-}--func (x *DatabaseRoleAttribute) GetBypassRls() bool {- if x != nil {- return x.BypassRls- }- return false-}--// DatabaseRole is the API message for database role.-type DatabaseRole struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- // The role unique name.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // The Bytebase instance id for this role.- InstanceId int32 `protobuf:"varint,2,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`- // The connection count limit for this role.- ConnectionLimit int32 `protobuf:"varint,3,opt,name=connection_limit,json=connectionLimit,proto3" json:"connection_limit,omitempty"`- // The expiration for the role's password.- ValidUntil *string `protobuf:"bytes,4,opt,name=valid_until,json=validUntil,proto3,oneof" json:"valid_until,omitempty"`- // The role attribute.- Attribute *DatabaseRoleAttribute `protobuf:"bytes,5,opt,name=attribute,proto3" json:"attribute,omitempty"`-}--func (x *DatabaseRole) Reset() {- *x = DatabaseRole{}- if protoimpl.UnsafeEnabled {- mi := &file_v1_database_role_proto_msgTypes[1]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)- }-}--func (x *DatabaseRole) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DatabaseRole) ProtoMessage() {}--func (x *DatabaseRole) ProtoReflect() protoreflect.Message {- mi := &file_v1_database_role_proto_msgTypes[1]- if protoimpl.UnsafeEnabled && x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DatabaseRole.ProtoReflect.Descriptor instead.-func (*DatabaseRole) Descriptor() ([]byte, []int) {- return file_v1_database_role_proto_rawDescGZIP(), []int{1}-}--func (x *DatabaseRole) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *DatabaseRole) GetInstanceId() int32 {- if x != nil {- return x.InstanceId- }- return 0-}--func (x *DatabaseRole) GetConnectionLimit() int32 {- if x != nil {- return x.ConnectionLimit- }- return 0-}--func (x *DatabaseRole) GetValidUntil() string {- if x != nil && x.ValidUntil != nil {- return *x.ValidUntil- }- return ""-}--func (x *DatabaseRole) GetAttribute() *DatabaseRoleAttribute {- if x != nil {- return x.Attribute- }- return nil-}--// ListDatabaseRoleResponse is the API message for role list.-type ListDatabaseRoleResponse struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- Roles []*DatabaseRole `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"`-}--func (x *ListDatabaseRoleResponse) Reset() {- *x = ListDatabaseRoleResponse{}- if protoimpl.UnsafeEnabled {- mi := &file_v1_database_role_proto_msgTypes[2]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)- }-}--func (x *ListDatabaseRoleResponse) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*ListDatabaseRoleResponse) ProtoMessage() {}--func (x *ListDatabaseRoleResponse) ProtoReflect() protoreflect.Message {- mi := &file_v1_database_role_proto_msgTypes[2]- if protoimpl.UnsafeEnabled && x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use ListDatabaseRoleResponse.ProtoReflect.Descriptor instead.-func (*ListDatabaseRoleResponse) Descriptor() ([]byte, []int) {- return file_v1_database_role_proto_rawDescGZIP(), []int{2}-}--func (x *ListDatabaseRoleResponse) GetRoles() []*DatabaseRole {- if x != nil {- return x.Roles- }- return nil-}--// DatabaseRoleUpsert is the API message for upserting a database role.-type DatabaseRoleUpsert struct {- state protoimpl.MessageState- sizeCache protoimpl.SizeCache- unknownFields protoimpl.UnknownFields-- // The role unique name.- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`- // A password is only significant if the client authentication method requires the user to supply a password when connecting to the database.- Password *string `protobuf:"bytes,2,opt,name=password,proto3,oneof" json:"password,omitempty"`- // Connection limit can specify how many concurrent connections a role can make. -1 (the default) means no limit.- ConnectionLimit *int32 `protobuf:"varint,3,opt,name=connection_limit,json=connectionLimit,proto3,oneof" json:"connection_limit,omitempty"`- // The VALID UNTIL clause sets a date and time after which the role's password is no longer valid. If this clause is omitted the password will be valid for all time.- ValidUntil *string `protobuf:"bytes,4,opt,name=valid_until,json=validUntil,proto3,oneof" json:"valid_until,omitempty"`- // The role attribute.- Attribute *DatabaseRoleAttribute `protobuf:"bytes,5,opt,name=attribute,proto3,oneof" json:"attribute,omitempty"`-}--func (x *DatabaseRoleUpsert) Reset() {- *x = DatabaseRoleUpsert{}- if protoimpl.UnsafeEnabled {- mi := &file_v1_database_role_proto_msgTypes[3]- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- ms.StoreMessageInfo(mi)- }-}--func (x *DatabaseRoleUpsert) String() string {- return protoimpl.X.MessageStringOf(x)-}--func (*DatabaseRoleUpsert) ProtoMessage() {}--func (x *DatabaseRoleUpsert) ProtoReflect() protoreflect.Message {- mi := &file_v1_database_role_proto_msgTypes[3]- if protoimpl.UnsafeEnabled && x != nil {- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))- if ms.LoadMessageInfo() == nil {- ms.StoreMessageInfo(mi)- }- return ms- }- return mi.MessageOf(x)-}--// Deprecated: Use DatabaseRoleUpsert.ProtoReflect.Descriptor instead.-func (*DatabaseRoleUpsert) Descriptor() ([]byte, []int) {- return file_v1_database_role_proto_rawDescGZIP(), []int{3}-}--func (x *DatabaseRoleUpsert) GetName() string {- if x != nil {- return x.Name- }- return ""-}--func (x *DatabaseRoleUpsert) GetPassword() string {- if x != nil && x.Password != nil {- return *x.Password- }- return ""-}--func (x *DatabaseRoleUpsert) GetConnectionLimit() int32 {- if x != nil && x.ConnectionLimit != nil {- return *x.ConnectionLimit- }- return 0-}--func (x *DatabaseRoleUpsert) GetValidUntil() string {- if x != nil && x.ValidUntil != nil {- return *x.ValidUntil- }- return ""-}--func (x *DatabaseRoleUpsert) GetAttribute() *DatabaseRoleAttribute {- if x != nil {- return x.Attribute- }- return nil-}--var File_v1_database_role_proto protoreflect.FileDescriptor--var file_v1_database_role_proto_rawDesc = []byte{- 0x0a, 0x16, 0x76, 0x31, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x6f,- 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,- 0x73, 0x65, 0x2e, 0x76, 0x31, 0x22, 0xf1, 0x01, 0x0a, 0x15, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61,- 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x12,- 0x1d, 0x0a, 0x0a, 0x73, 0x75, 0x70, 0x65, 0x72, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20,- 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x75, 0x70, 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1d,- 0x0a, 0x0a, 0x6e, 0x6f, 0x5f, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01,- 0x28, 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x49, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x12, 0x1f, 0x0a,- 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01,- 0x28, 0x08, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x1b,- 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x64, 0x62, 0x18, 0x04, 0x20, 0x01, 0x28,- 0x08, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x62, 0x12, 0x1b, 0x0a, 0x09, 0x63,- 0x61, 0x6e, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08,- 0x63, 0x61, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x70, 0x6c,- 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x72,- 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x79,- 0x70, 0x61, 0x73, 0x73, 0x5f, 0x72, 0x6c, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09,- 0x62, 0x79, 0x70, 0x61, 0x73, 0x73, 0x52, 0x6c, 0x73, 0x22, 0xe6, 0x01, 0x0a, 0x0c, 0x44, 0x61,- 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,- 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f,- 0x0a, 0x0b, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20,- 0x01, 0x28, 0x05, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12,- 0x29, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x69,- 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65,- 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x24, 0x0a, 0x0b, 0x76, 0x61,- 0x6c, 0x69, 0x64, 0x5f, 0x75, 0x6e, 0x74, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48,- 0x00, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x55, 0x6e, 0x74, 0x69, 0x6c, 0x88, 0x01, 0x01,- 0x12, 0x40, 0x0a, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x18, 0x05, 0x20,- 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,- 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x41, 0x74,- 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x52, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75,- 0x74, 0x65, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x75, 0x6e, 0x74,- 0x69, 0x6c, 0x22, 0x4b, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61,- 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f,- 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e,- 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61,- 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22,- 0xa6, 0x02, 0x0a, 0x12, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65,- 0x55, 0x70, 0x73, 0x65, 0x72, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,- 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x08, 0x70, 0x61,- 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08,- 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x88, 0x01, 0x01, 0x12, 0x2e, 0x0a, 0x10, 0x63,- 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18,- 0x03, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,- 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x88, 0x01, 0x01, 0x12, 0x24, 0x0a, 0x0b, 0x76,- 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x75, 0x6e, 0x74, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,- 0x48, 0x02, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x55, 0x6e, 0x74, 0x69, 0x6c, 0x88, 0x01,- 0x01, 0x12, 0x45, 0x0a, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x18, 0x05,- 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,- 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x41,- 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x48, 0x03, 0x52, 0x09, 0x61, 0x74, 0x74, 0x72,- 0x69, 0x62, 0x75, 0x74, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x70, 0x61, 0x73,- 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,- 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x76,- 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x75, 0x6e, 0x74, 0x69, 0x6c, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x61,- 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x42, 0x11, 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65,- 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f,- 0x74, 0x6f, 0x33,-}--var (- file_v1_database_role_proto_rawDescOnce sync.Once- file_v1_database_role_proto_rawDescData = file_v1_database_role_proto_rawDesc-)--func file_v1_database_role_proto_rawDescGZIP() []byte {- file_v1_database_role_proto_rawDescOnce.Do(func() {- file_v1_database_role_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_database_role_proto_rawDescData)- })- return file_v1_database_role_proto_rawDescData-}--var file_v1_database_role_proto_msgTypes = make([]protoimpl.MessageInfo, 4)-var file_v1_database_role_proto_goTypes = []interface{}{- (*DatabaseRoleAttribute)(nil), // 0: bytebase.v1.DatabaseRoleAttribute- (*DatabaseRole)(nil), // 1: bytebase.v1.DatabaseRole- (*ListDatabaseRoleResponse)(nil), // 2: bytebase.v1.ListDatabaseRoleResponse- (*DatabaseRoleUpsert)(nil), // 3: bytebase.v1.DatabaseRoleUpsert-}-var file_v1_database_role_proto_depIdxs = []int32{- 0, // 0: bytebase.v1.DatabaseRole.attribute:type_name -> bytebase.v1.DatabaseRoleAttribute- 1, // 1: bytebase.v1.ListDatabaseRoleResponse.roles:type_name -> bytebase.v1.DatabaseRole- 0, // 2: bytebase.v1.DatabaseRoleUpsert.attribute:type_name -> bytebase.v1.DatabaseRoleAttribute- 3, // [3:3] is the sub-list for method output_type- 3, // [3:3] is the sub-list for method input_type- 3, // [3:3] is the sub-list for extension type_name- 3, // [3:3] is the sub-list for extension extendee- 0, // [0:3] is the sub-list for field type_name-}--func init() { file_v1_database_role_proto_init() }-func file_v1_database_role_proto_init() {- if File_v1_database_role_proto != nil {- return- }- if !protoimpl.UnsafeEnabled {- file_v1_database_role_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*DatabaseRoleAttribute); i {- case 0:- return &v.state- case 1:- return &v.sizeCache- case 2:- return &v.unknownFields- default:- return nil- }- }- file_v1_database_role_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*DatabaseRole); i {- case 0:- return &v.state- case 1:- return &v.sizeCache- case 2:- return &v.unknownFields- default:- return nil- }- }- file_v1_database_role_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*ListDatabaseRoleResponse); i {- case 0:- return &v.state- case 1:- return &v.sizeCache- case 2:- return &v.unknownFields- default:- return nil- }- }- file_v1_database_role_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {- switch v := v.(*DatabaseRoleUpsert); i {- case 0:- return &v.state- case 1:- return &v.sizeCache- case 2:- return &v.unknownFields- default:- return nil- }- }- }- file_v1_database_role_proto_msgTypes[1].OneofWrappers = []interface{}{}- file_v1_database_role_proto_msgTypes[3].OneofWrappers = []interface{}{}- type x struct{}- out := protoimpl.TypeBuilder{- File: protoimpl.DescBuilder{- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),- RawDescriptor: file_v1_database_role_proto_rawDesc,- NumEnums: 0,- NumMessages: 4,- NumExtensions: 0,- NumServices: 0,- },- GoTypes: file_v1_database_role_proto_goTypes,- DependencyIndexes: file_v1_database_role_proto_depIdxs,- MessageInfos: file_v1_database_role_proto_msgTypes,- }.Build()- File_v1_database_role_proto = out.File- file_v1_database_role_proto_rawDesc = nil- file_v1_database_role_proto_goTypes = nil- file_v1_database_role_proto_depIdxs = nil-}diff --git a/proto/generated-go/v1/instance_role_service.pb.go b/proto/generated-go/v1/instance_role_service.pb.gonew file mode 100644index 0000000000..b4a0953010--- /dev/null+++ b/proto/generated-go/v1/instance_role_service.pb.go@@ -0,0 +1,956 @@+// Code generated by protoc-gen-go. DO NOT EDIT.+// versions:+// protoc-gen-go v1.28.1+// protoc (unknown)+// source: v1/instance_role_service.proto++package v1++import (+ _ "google.golang.org/genproto/googleapis/api/annotations"+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"+ emptypb "google.golang.org/protobuf/types/known/emptypb"+ fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"+ reflect "reflect"+ sync "sync"+)++const (+ // Verify that this generated code is sufficiently up-to-date.+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)+ // Verify that runtime/protoimpl is sufficiently up-to-date.+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)+)++type GetRoleRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The name of the role to retrieve.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ // The role name is the unique name for the role.+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+}++func (x *GetRoleRequest) Reset() {+ *x = GetRoleRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[0]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *GetRoleRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*GetRoleRequest) ProtoMessage() {}++func (x *GetRoleRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[0]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use GetRoleRequest.ProtoReflect.Descriptor instead.+func (*GetRoleRequest) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{0}+}++func (x *GetRoleRequest) GetName() string {+ if x != nil {+ return x.Name+ }+ return ""+}++type ListRolesRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The parent, which owns this collection of roles.+ // Format: environments/{environment}/instances/{instance}+ Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`+ // The maximum number of roles to return. The service may return fewer than+ // this value.+ // If unspecified, at most 50 roles will be returned.+ // The maximum value is 1000; values above 1000 will be coerced to 1000.+ PageSize int32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`+ // A page token, received from a previous `ListRoles` call.+ // Provide this to retrieve the subsequent page.+ //+ // When paginating, all other parameters provided to `ListRoles` 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"`+}++func (x *ListRolesRequest) Reset() {+ *x = ListRolesRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[1]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *ListRolesRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*ListRolesRequest) ProtoMessage() {}++func (x *ListRolesRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[1]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use ListRolesRequest.ProtoReflect.Descriptor instead.+func (*ListRolesRequest) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{1}+}++func (x *ListRolesRequest) GetParent() string {+ if x != nil {+ return x.Parent+ }+ return ""+}++func (x *ListRolesRequest) GetPageSize() int32 {+ if x != nil {+ return x.PageSize+ }+ return 0+}++func (x *ListRolesRequest) GetPageToken() string {+ if x != nil {+ return x.PageToken+ }+ return ""+}++type ListRolesResponse struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The roles from the specified request.+ Roles []*DatabaseRole `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"`+ // A token, which can be sent as `page_token` to retrieve the next page.+ // If this field is omitted, there are no subsequent pages.+ NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"`+}++func (x *ListRolesResponse) Reset() {+ *x = ListRolesResponse{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[2]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *ListRolesResponse) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*ListRolesResponse) ProtoMessage() {}++func (x *ListRolesResponse) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[2]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use ListRolesResponse.ProtoReflect.Descriptor instead.+func (*ListRolesResponse) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{2}+}++func (x *ListRolesResponse) GetRoles() []*DatabaseRole {+ if x != nil {+ return x.Roles+ }+ return nil+}++func (x *ListRolesResponse) GetNextPageToken() string {+ if x != nil {+ return x.NextPageToken+ }+ return ""+}++type CreateRoleRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The parent resource where this role will be created.+ // Format: environments/{environment}/instances/{instance}+ Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`+ // The role to create.+ Role *DatabaseRole `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"`+}++func (x *CreateRoleRequest) Reset() {+ *x = CreateRoleRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[3]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *CreateRoleRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*CreateRoleRequest) ProtoMessage() {}++func (x *CreateRoleRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[3]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use CreateRoleRequest.ProtoReflect.Descriptor instead.+func (*CreateRoleRequest) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{3}+}++func (x *CreateRoleRequest) GetParent() string {+ if x != nil {+ return x.Parent+ }+ return ""+}++func (x *CreateRoleRequest) GetRole() *DatabaseRole {+ if x != nil {+ return x.Role+ }+ return nil+}++type UpdateRoleRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The role to update.+ //+ // The role's `name`, `environment` and `instance` field is used to identify the role to update.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ Role *DatabaseRole `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`+ // The list of fields to update.+ UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`+}++func (x *UpdateRoleRequest) Reset() {+ *x = UpdateRoleRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[4]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *UpdateRoleRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*UpdateRoleRequest) ProtoMessage() {}++func (x *UpdateRoleRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[4]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use UpdateRoleRequest.ProtoReflect.Descriptor instead.+func (*UpdateRoleRequest) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{4}+}++func (x *UpdateRoleRequest) GetRole() *DatabaseRole {+ if x != nil {+ return x.Role+ }+ return nil+}++func (x *UpdateRoleRequest) GetUpdateMask() *fieldmaskpb.FieldMask {+ if x != nil {+ return x.UpdateMask+ }+ return nil+}++type DeleteRoleRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The name of the role to delete.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+}++func (x *DeleteRoleRequest) Reset() {+ *x = DeleteRoleRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[5]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *DeleteRoleRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*DeleteRoleRequest) ProtoMessage() {}++func (x *DeleteRoleRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[5]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use DeleteRoleRequest.ProtoReflect.Descriptor instead.+func (*DeleteRoleRequest) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{5}+}++func (x *DeleteRoleRequest) GetName() string {+ if x != nil {+ return x.Name+ }+ return ""+}++type UndeleteRoleRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The name of the deleted role.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+}++func (x *UndeleteRoleRequest) Reset() {+ *x = UndeleteRoleRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[6]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *UndeleteRoleRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*UndeleteRoleRequest) ProtoMessage() {}++func (x *UndeleteRoleRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[6]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use UndeleteRoleRequest.ProtoReflect.Descriptor instead.+func (*UndeleteRoleRequest) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{6}+}++func (x *UndeleteRoleRequest) GetName() string {+ if x != nil {+ return x.Name+ }+ return ""+}++// RoleAttribute is the attribute for role. Docs: https://www.postgresql.org/docs/current/role-attributes.html+type DatabaseRoleAttribute struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // A database superuser bypasses all permission checks, except the right to log in.+ SuperUser bool `protobuf:"varint,1,opt,name=super_user,json=superUser,proto3" json:"super_user,omitempty"`+ // A role is given permission to inherit the privileges of roles it is a member of. To create a role without the permission, use "noInherit = true"+ NoInherit bool `protobuf:"varint,2,opt,name=no_inherit,json=noInherit,proto3" json:"no_inherit,omitempty"`+ // A role must be explicitly given permission to create more roles (except for superusers, since those bypass all permission checks).+ CreateRole bool `protobuf:"varint,3,opt,name=create_role,json=createRole,proto3" json:"create_role,omitempty"`+ // A role must be explicitly given permission to create databases (except for superusers, since those bypass all permission checks).+ CreateDb bool `protobuf:"varint,4,opt,name=create_db,json=createDb,proto3" json:"create_db,omitempty"`+ // Only roles that have the LOGIN attribute can be used as the initial role name for a database connection.+ CanLogin bool `protobuf:"varint,5,opt,name=can_login,json=canLogin,proto3" json:"can_login,omitempty"`+ // A role must explicitly be given permission to initiate streaming replication (except for superusers, since those bypass all permission checks).+ Replication bool `protobuf:"varint,6,opt,name=replication,proto3" json:"replication,omitempty"`+ // A role must be explicitly given permission to bypass every row-level security (RLS) policy (except for superusers, since those bypass all permission checks).+ BypassRls bool `protobuf:"varint,7,opt,name=bypass_rls,json=bypassRls,proto3" json:"bypass_rls,omitempty"`+}++func (x *DatabaseRoleAttribute) Reset() {+ *x = DatabaseRoleAttribute{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[7]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *DatabaseRoleAttribute) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*DatabaseRoleAttribute) ProtoMessage() {}++func (x *DatabaseRoleAttribute) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[7]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use DatabaseRoleAttribute.ProtoReflect.Descriptor instead.+func (*DatabaseRoleAttribute) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{7}+}++func (x *DatabaseRoleAttribute) GetSuperUser() bool {+ if x != nil {+ return x.SuperUser+ }+ return false+}++func (x *DatabaseRoleAttribute) GetNoInherit() bool {+ if x != nil {+ return x.NoInherit+ }+ return false+}++func (x *DatabaseRoleAttribute) GetCreateRole() bool {+ if x != nil {+ return x.CreateRole+ }+ return false+}++func (x *DatabaseRoleAttribute) GetCreateDb() bool {+ if x != nil {+ return x.CreateDb+ }+ return false+}++func (x *DatabaseRoleAttribute) GetCanLogin() bool {+ if x != nil {+ return x.CanLogin+ }+ return false+}++func (x *DatabaseRoleAttribute) GetReplication() bool {+ if x != nil {+ return x.Replication+ }+ return false+}++func (x *DatabaseRoleAttribute) GetBypassRls() bool {+ if x != nil {+ return x.BypassRls+ }+ return false+}++// DatabaseRole is the API message for database role.+type DatabaseRole struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The name of the role.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ // The role name is the unique name for the role.+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+ // The role unique name.+ Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`+ // The role password.+ Password *string `protobuf:"bytes,3,opt,name=password,proto3,oneof" json:"password,omitempty"`+ // The connection count limit for this role.+ ConnectionLimit *int32 `protobuf:"varint,4,opt,name=connection_limit,json=connectionLimit,proto3,oneof" json:"connection_limit,omitempty"`+ // The expiration for the role's password.+ ValidUntil *string `protobuf:"bytes,5,opt,name=valid_until,json=validUntil,proto3,oneof" json:"valid_until,omitempty"`+ // The role attribute.+ Attribute *DatabaseRoleAttribute `protobuf:"bytes,6,opt,name=attribute,proto3" json:"attribute,omitempty"`+}++func (x *DatabaseRole) Reset() {+ *x = DatabaseRole{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_instance_role_service_proto_msgTypes[8]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *DatabaseRole) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*DatabaseRole) ProtoMessage() {}++func (x *DatabaseRole) ProtoReflect() protoreflect.Message {+ mi := &file_v1_instance_role_service_proto_msgTypes[8]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use DatabaseRole.ProtoReflect.Descriptor instead.+func (*DatabaseRole) Descriptor() ([]byte, []int) {+ return file_v1_instance_role_service_proto_rawDescGZIP(), []int{8}+}++func (x *DatabaseRole) GetName() string {+ if x != nil {+ return x.Name+ }+ return ""+}++func (x *DatabaseRole) GetTitle() string {+ if x != nil {+ return x.Title+ }+ return ""+}++func (x *DatabaseRole) GetPassword() string {+ if x != nil && x.Password != nil {+ return *x.Password+ }+ return ""+}++func (x *DatabaseRole) GetConnectionLimit() int32 {+ if x != nil && x.ConnectionLimit != nil {+ return *x.ConnectionLimit+ }+ return 0+}++func (x *DatabaseRole) GetValidUntil() string {+ if x != nil && x.ValidUntil != nil {+ return *x.ValidUntil+ }+ return ""+}++func (x *DatabaseRole) GetAttribute() *DatabaseRoleAttribute {+ if x != nil {+ return x.Attribute+ }+ return nil+}++var File_v1_instance_role_service_proto protoreflect.FileDescriptor++var file_v1_instance_role_service_proto_rawDesc = []byte{+ 0x0a, 0x1e, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x6f,+ 0x6c, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,+ 0x12, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67,+ 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61,+ 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f,+ 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70,+ 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69,+ 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e,+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72,+ 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f,+ 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,+ 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70,+ 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e,+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2a, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65,+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,+ 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d,+ 0x65, 0x22, 0x6c, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65,+ 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18,+ 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x06, 0x70, 0x61, 0x72,+ 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65,+ 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65,+ 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03,+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22,+ 0x6c, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70,+ 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20,+ 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05,+ 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61,+ 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,+ 0x6e, 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x66, 0x0a,+ 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,+ 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,+ 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74,+ 0x12, 0x33, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19,+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74,+ 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52,+ 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x85, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,+ 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x04, 0x72,+ 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65,+ 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65,+ 0x52, 0x6f, 0x6c, 0x65, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65,+ 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18,+ 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,+ 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73,+ 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x2d, 0x0a,+ 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,+ 0x73, 0x74, 0x12, 0x18, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,+ 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x2f, 0x0a, 0x13,+ 0x55, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75,+ 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,+ 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xf1, 0x01,+ 0x0a, 0x15, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x41, 0x74,+ 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x75, 0x70, 0x65, 0x72,+ 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x73, 0x75, 0x70,+ 0x65, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, 0x5f, 0x69, 0x6e, 0x68,+ 0x65, 0x72, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x49, 0x6e,+ 0x68, 0x65, 0x72, 0x69, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f,+ 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61,+ 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,+ 0x5f, 0x64, 0x62, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74,+ 0x65, 0x44, 0x62, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x61, 0x6e, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e,+ 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x63, 0x61, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e,+ 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18,+ 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69,+ 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x79, 0x70, 0x61, 0x73, 0x73, 0x5f, 0x72, 0x6c, 0x73,+ 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x62, 0x79, 0x70, 0x61, 0x73, 0x73, 0x52, 0x6c,+ 0x73, 0x22, 0xa9, 0x02, 0x0a, 0x0c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f,+ 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,+ 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18,+ 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x08,+ 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04,+ 0xe2, 0x41, 0x01, 0x04, 0x48, 0x00, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,+ 0x88, 0x01, 0x01, 0x12, 0x2e, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f,+ 0x6e, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52,+ 0x0f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x6d, 0x69, 0x74,+ 0x88, 0x01, 0x01, 0x12, 0x24, 0x0a, 0x0b, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x75, 0x6e, 0x74,+ 0x69, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69,+ 0x64, 0x55, 0x6e, 0x74, 0x69, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x40, 0x0a, 0x09, 0x61, 0x74, 0x74,+ 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x62,+ 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62,+ 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65,+ 0x52, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x5f,+ 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x63, 0x6f, 0x6e,+ 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x42, 0x0e, 0x0a,+ 0x0c, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x75, 0x6e, 0x74, 0x69, 0x6c, 0x32, 0xed, 0x06,+ 0x0a, 0x13, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x53, 0x65,+ 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7f, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65,+ 0x12, 0x1b, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47,+ 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61,+ 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x3c, 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d,+ 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, 0x12, 0x2d, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61,+ 0x6d, 0x65, 0x3d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f,+ 0x2a, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x72, 0x6f,+ 0x6c, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x8a, 0x01, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52,+ 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,+ 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75,+ 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,+ 0x6e, 0x73, 0x65, 0x22, 0x3e, 0xda, 0x41, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x82, 0xd3,+ 0xe4, 0x93, 0x02, 0x2f, 0x12, 0x2d, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e,+ 0x74, 0x3d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x2a,+ 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x72, 0x6f,+ 0x6c, 0x65, 0x73, 0x12, 0x92, 0x01, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f,+ 0x6c, 0x65, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,+ 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,+ 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31,+ 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x49, 0xda,+ 0x41, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x2c, 0x72, 0x6f, 0x6c, 0x65, 0x82, 0xd3, 0xe4,+ 0x93, 0x02, 0x35, 0x3a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x2d, 0x2f, 0x76, 0x31, 0x2f, 0x7b,+ 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65,+ 0x6e, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f,+ 0x2a, 0x7d, 0x2f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x9c, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64,+ 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65,+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f,+ 0x6c, 0x65, 0x22, 0x53, 0xda, 0x41, 0x10, 0x72, 0x6f, 0x6c, 0x65, 0x2c, 0x75, 0x70, 0x64, 0x61,+ 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3a, 0x3a, 0x04, 0x72,+ 0x6f, 0x6c, 0x65, 0x32, 0x32, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x72, 0x6f, 0x6c, 0x65, 0x2e, 0x6e,+ 0x61, 0x6d, 0x65, 0x3d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73,+ 0x2f, 0x2a, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x72,+ 0x6f, 0x6c, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x82, 0x01, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65,+ 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52,+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x3c,+ 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, 0x2a, 0x2d, 0x2f,+ 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e,+ 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65,+ 0x73, 0x2f, 0x2a, 0x2f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x8e, 0x01, 0x0a,+ 0x0c, 0x55, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x20, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x6e, 0x64, 0x65,+ 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,+ 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x61,+ 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x41, 0x82, 0xd3, 0xe4, 0x93,+ 0x02, 0x3b, 0x3a, 0x01, 0x2a, 0x22, 0x36, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65,+ 0x3d, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x2a, 0x2f,+ 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x73, 0x2f, 0x2a, 0x2f, 0x72, 0x6f, 0x6c, 0x65,+ 0x73, 0x2f, 0x2a, 0x7d, 0x3a, 0x75, 0x6e, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x11, 0x5a,+ 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x31,+ 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,+}++var (+ file_v1_instance_role_service_proto_rawDescOnce sync.Once+ file_v1_instance_role_service_proto_rawDescData = file_v1_instance_role_service_proto_rawDesc+)++func file_v1_instance_role_service_proto_rawDescGZIP() []byte {+ file_v1_instance_role_service_proto_rawDescOnce.Do(func() {+ file_v1_instance_role_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_instance_role_service_proto_rawDescData)+ })+ return file_v1_instance_role_service_proto_rawDescData+}++var file_v1_instance_role_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)+var file_v1_instance_role_service_proto_goTypes = []interface{}{+ (*GetRoleRequest)(nil), // 0: bytebase.v1.GetRoleRequest+ (*ListRolesRequest)(nil), // 1: bytebase.v1.ListRolesRequest+ (*ListRolesResponse)(nil), // 2: bytebase.v1.ListRolesResponse+ (*CreateRoleRequest)(nil), // 3: bytebase.v1.CreateRoleRequest+ (*UpdateRoleRequest)(nil), // 4: bytebase.v1.UpdateRoleRequest+ (*DeleteRoleRequest)(nil), // 5: bytebase.v1.DeleteRoleRequest+ (*UndeleteRoleRequest)(nil), // 6: bytebase.v1.UndeleteRoleRequest+ (*DatabaseRoleAttribute)(nil), // 7: bytebase.v1.DatabaseRoleAttribute+ (*DatabaseRole)(nil), // 8: bytebase.v1.DatabaseRole+ (*fieldmaskpb.FieldMask)(nil), // 9: google.protobuf.FieldMask+ (*emptypb.Empty)(nil), // 10: google.protobuf.Empty+}+var file_v1_instance_role_service_proto_depIdxs = []int32{+ 8, // 0: bytebase.v1.ListRolesResponse.roles:type_name -> bytebase.v1.DatabaseRole+ 8, // 1: bytebase.v1.CreateRoleRequest.role:type_name -> bytebase.v1.DatabaseRole+ 8, // 2: bytebase.v1.UpdateRoleRequest.role:type_name -> bytebase.v1.DatabaseRole+ 9, // 3: bytebase.v1.UpdateRoleRequest.update_mask:type_name -> google.protobuf.FieldMask+ 7, // 4: bytebase.v1.DatabaseRole.attribute:type_name -> bytebase.v1.DatabaseRoleAttribute+ 0, // 5: bytebase.v1.InstanceRoleService.GetRole:input_type -> bytebase.v1.GetRoleRequest+ 1, // 6: bytebase.v1.InstanceRoleService.ListRoles:input_type -> bytebase.v1.ListRolesRequest+ 3, // 7: bytebase.v1.InstanceRoleService.CreateRole:input_type -> bytebase.v1.CreateRoleRequest+ 4, // 8: bytebase.v1.InstanceRoleService.UpdateRole:input_type -> bytebase.v1.UpdateRoleRequest+ 5, // 9: bytebase.v1.InstanceRoleService.DeleteRole:input_type -> bytebase.v1.DeleteRoleRequest+ 6, // 10: bytebase.v1.InstanceRoleService.UndeleteRole:input_type -> bytebase.v1.UndeleteRoleRequest+ 8, // 11: bytebase.v1.InstanceRoleService.GetRole:output_type -> bytebase.v1.DatabaseRole+ 2, // 12: bytebase.v1.InstanceRoleService.ListRoles:output_type -> bytebase.v1.ListRolesResponse+ 8, // 13: bytebase.v1.InstanceRoleService.CreateRole:output_type -> bytebase.v1.DatabaseRole+ 8, // 14: bytebase.v1.InstanceRoleService.UpdateRole:output_type -> bytebase.v1.DatabaseRole+ 10, // 15: bytebase.v1.InstanceRoleService.DeleteRole:output_type -> google.protobuf.Empty+ 8, // 16: bytebase.v1.InstanceRoleService.UndeleteRole:output_type -> bytebase.v1.DatabaseRole+ 11, // [11:17] is the sub-list for method output_type+ 5, // [5:11] is the sub-list for method input_type+ 5, // [5:5] is the sub-list for extension type_name+ 5, // [5:5] is the sub-list for extension extendee+ 0, // [0:5] is the sub-list for field type_name+}++func init() { file_v1_instance_role_service_proto_init() }+func file_v1_instance_role_service_proto_init() {+ if File_v1_instance_role_service_proto != nil {+ return+ }+ file_v1_common_proto_init()+ if !protoimpl.UnsafeEnabled {+ file_v1_instance_role_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*GetRoleRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_instance_role_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*ListRolesRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_instance_role_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*ListRolesResponse); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_instance_role_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*CreateRoleRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_instance_role_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*UpdateRoleRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_instance_role_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*DeleteRoleRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_instance_role_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*UndeleteRoleRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_instance_role_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*DatabaseRoleAttribute); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_instance_role_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*DatabaseRole); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ }+ file_v1_instance_role_service_proto_msgTypes[8].OneofWrappers = []interface{}{}+ type x struct{}+ out := protoimpl.TypeBuilder{+ File: protoimpl.DescBuilder{+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),+ RawDescriptor: file_v1_instance_role_service_proto_rawDesc,+ NumEnums: 0,+ NumMessages: 9,+ NumExtensions: 0,+ NumServices: 1,+ },+ GoTypes: file_v1_instance_role_service_proto_goTypes,+ DependencyIndexes: file_v1_instance_role_service_proto_depIdxs,+ MessageInfos: file_v1_instance_role_service_proto_msgTypes,+ }.Build()+ File_v1_instance_role_service_proto = out.File+ file_v1_instance_role_service_proto_rawDesc = nil+ file_v1_instance_role_service_proto_goTypes = nil+ file_v1_instance_role_service_proto_depIdxs = nil+}diff --git a/proto/generated-go/v1/instance_role_service.pb.gw.go b/proto/generated-go/v1/instance_role_service.pb.gw.gonew file mode 100644index 0000000000..4fdaa66a4c--- /dev/null+++ b/proto/generated-go/v1/instance_role_service.pb.gw.go@@ -0,0 +1,802 @@+// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.+// source: v1/instance_role_service.proto++/*+Package v1 is a reverse proxy.++It translates gRPC into RESTful JSON APIs.+*/+package v1++import (+ "context"+ "io"+ "net/http"++ "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"+ "github.com/grpc-ecosystem/grpc-gateway/v2/utilities"+ "google.golang.org/grpc"+ "google.golang.org/grpc/codes"+ "google.golang.org/grpc/grpclog"+ "google.golang.org/grpc/metadata"+ "google.golang.org/grpc/status"+ "google.golang.org/protobuf/proto"+)++// Suppress "imported and not used" errors+var _ codes.Code+var _ io.Reader+var _ status.Status+var _ = runtime.String+var _ = utilities.NewDoubleArray+var _ = metadata.Join++func request_InstanceRoleService_GetRole_0(ctx context.Context, marshaler runtime.Marshaler, client InstanceRoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq GetRoleRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := client.GetRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InstanceRoleService_GetRole_0(ctx context.Context, marshaler runtime.Marshaler, server InstanceRoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq GetRoleRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := server.GetRole(ctx, &protoReq)+ return msg, metadata, err++}++var (+ filter_InstanceRoleService_ListRoles_0 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}}+)++func request_InstanceRoleService_ListRoles_0(ctx context.Context, marshaler runtime.Marshaler, client InstanceRoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq ListRolesRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["parent"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")+ }++ protoReq.Parent, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)+ }++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InstanceRoleService_ListRoles_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := client.ListRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InstanceRoleService_ListRoles_0(ctx context.Context, marshaler runtime.Marshaler, server InstanceRoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq ListRolesRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["parent"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")+ }++ protoReq.Parent, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)+ }++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InstanceRoleService_ListRoles_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := server.ListRoles(ctx, &protoReq)+ return msg, metadata, err++}++func request_InstanceRoleService_CreateRole_0(ctx context.Context, marshaler runtime.Marshaler, client InstanceRoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq CreateRoleRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Role); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["parent"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")+ }++ protoReq.Parent, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)+ }++ msg, err := client.CreateRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InstanceRoleService_CreateRole_0(ctx context.Context, marshaler runtime.Marshaler, server InstanceRoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq CreateRoleRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Role); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["parent"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")+ }++ protoReq.Parent, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)+ }++ msg, err := server.CreateRole(ctx, &protoReq)+ return msg, metadata, err++}++var (+ filter_InstanceRoleService_UpdateRole_0 = &utilities.DoubleArray{Encoding: map[string]int{"role": 0, "name": 1}, Base: []int{1, 4, 5, 2, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 4, 2, 2, 3}}+)++func request_InstanceRoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Marshaler, client InstanceRoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq UpdateRoleRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Role); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {+ if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Role); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ } else {+ protoReq.UpdateMask = fieldMask+ }+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["role.name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "role.name")+ }++ err = runtime.PopulateFieldFromPath(&protoReq, "role.name", val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role.name", err)+ }++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InstanceRoleService_UpdateRole_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := client.UpdateRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InstanceRoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Marshaler, server InstanceRoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq UpdateRoleRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Role); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {+ if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Role); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ } else {+ protoReq.UpdateMask = fieldMask+ }+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["role.name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "role.name")+ }++ err = runtime.PopulateFieldFromPath(&protoReq, "role.name", val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role.name", err)+ }++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InstanceRoleService_UpdateRole_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := server.UpdateRole(ctx, &protoReq)+ return msg, metadata, err++}++func request_InstanceRoleService_DeleteRole_0(ctx context.Context, marshaler runtime.Marshaler, client InstanceRoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq DeleteRoleRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := client.DeleteRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InstanceRoleService_DeleteRole_0(ctx context.Context, marshaler runtime.Marshaler, server InstanceRoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq DeleteRoleRequest+ var metadata runtime.ServerMetadata++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := server.DeleteRole(ctx, &protoReq)+ return msg, metadata, err++}++func request_InstanceRoleService_UndeleteRole_0(ctx context.Context, marshaler runtime.Marshaler, client InstanceRoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq UndeleteRoleRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := client.UndeleteRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InstanceRoleService_UndeleteRole_0(ctx context.Context, marshaler runtime.Marshaler, server InstanceRoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq UndeleteRoleRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")+ }++ protoReq.Name, err = runtime.String(val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)+ }++ msg, err := server.UndeleteRole(ctx, &protoReq)+ return msg, metadata, err++}++// RegisterInstanceRoleServiceHandlerServer registers the http handlers for service InstanceRoleService to "mux".+// UnaryRPC :call InstanceRoleServiceServer directly.+// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.+// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterInstanceRoleServiceHandlerFromEndpoint instead.+func RegisterInstanceRoleServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server InstanceRoleServiceServer) error {++ mux.Handle("GET", pattern_InstanceRoleService_GetRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/GetRole", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/roles/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InstanceRoleService_GetRole_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_GetRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("GET", pattern_InstanceRoleService_ListRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/ListRoles", runtime.WithHTTPPathPattern("/v1/{parent=environments/*/instances/*}/roles"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InstanceRoleService_ListRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_ListRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("POST", pattern_InstanceRoleService_CreateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/CreateRole", runtime.WithHTTPPathPattern("/v1/{parent=environments/*/instances/*}/roles"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InstanceRoleService_CreateRole_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_CreateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("PATCH", pattern_InstanceRoleService_UpdateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/UpdateRole", runtime.WithHTTPPathPattern("/v1/{role.name=environments/*/instances/*/roles/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InstanceRoleService_UpdateRole_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_UpdateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("DELETE", pattern_InstanceRoleService_DeleteRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/DeleteRole", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/roles/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InstanceRoleService_DeleteRole_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_DeleteRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("POST", pattern_InstanceRoleService_UndeleteRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/UndeleteRole", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/roles/*}:undelete"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InstanceRoleService_UndeleteRole_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_UndeleteRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ return nil+}++// RegisterInstanceRoleServiceHandlerFromEndpoint is same as RegisterInstanceRoleServiceHandler but+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.+func RegisterInstanceRoleServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {+ conn, err := grpc.Dial(endpoint, opts...)+ if err != nil {+ return err+ }+ defer func() {+ if err != nil {+ if cerr := conn.Close(); cerr != nil {+ grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)+ }+ return+ }+ go func() {+ <-ctx.Done()+ if cerr := conn.Close(); cerr != nil {+ grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)+ }+ }()+ }()++ return RegisterInstanceRoleServiceHandler(ctx, mux, conn)+}++// RegisterInstanceRoleServiceHandler registers the http handlers for service InstanceRoleService to "mux".+// The handlers forward requests to the grpc endpoint over "conn".+func RegisterInstanceRoleServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {+ return RegisterInstanceRoleServiceHandlerClient(ctx, mux, NewInstanceRoleServiceClient(conn))+}++// RegisterInstanceRoleServiceHandlerClient registers the http handlers for service InstanceRoleService+// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "InstanceRoleServiceClient".+// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "InstanceRoleServiceClient"+// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in+// "InstanceRoleServiceClient" to call the correct interceptors.+func RegisterInstanceRoleServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client InstanceRoleServiceClient) error {++ mux.Handle("GET", pattern_InstanceRoleService_GetRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/GetRole", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/roles/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InstanceRoleService_GetRole_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_GetRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("GET", pattern_InstanceRoleService_ListRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/ListRoles", runtime.WithHTTPPathPattern("/v1/{parent=environments/*/instances/*}/roles"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InstanceRoleService_ListRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_ListRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("POST", pattern_InstanceRoleService_CreateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/CreateRole", runtime.WithHTTPPathPattern("/v1/{parent=environments/*/instances/*}/roles"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InstanceRoleService_CreateRole_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_CreateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("PATCH", pattern_InstanceRoleService_UpdateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/UpdateRole", runtime.WithHTTPPathPattern("/v1/{role.name=environments/*/instances/*/roles/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InstanceRoleService_UpdateRole_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_UpdateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("DELETE", pattern_InstanceRoleService_DeleteRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/DeleteRole", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/roles/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InstanceRoleService_DeleteRole_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_DeleteRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("POST", pattern_InstanceRoleService_UndeleteRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InstanceRoleService/UndeleteRole", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/roles/*}:undelete"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InstanceRoleService_UndeleteRole_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InstanceRoleService_UndeleteRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ return nil+}++var (+ pattern_InstanceRoleService_GetRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 4, 6, 5, 4}, []string{"v1", "environments", "instances", "roles", "name"}, ""))++ pattern_InstanceRoleService_ListRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 4, 5, 3, 2, 4}, []string{"v1", "environments", "instances", "parent", "roles"}, ""))++ pattern_InstanceRoleService_CreateRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 4, 5, 3, 2, 4}, []string{"v1", "environments", "instances", "parent", "roles"}, ""))++ pattern_InstanceRoleService_UpdateRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 4, 6, 5, 4}, []string{"v1", "environments", "instances", "roles", "role.name"}, ""))++ pattern_InstanceRoleService_DeleteRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 4, 6, 5, 4}, []string{"v1", "environments", "instances", "roles", "name"}, ""))++ pattern_InstanceRoleService_UndeleteRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 4, 6, 5, 4}, []string{"v1", "environments", "instances", "roles", "name"}, "undelete"))+)++var (+ forward_InstanceRoleService_GetRole_0 = runtime.ForwardResponseMessage++ forward_InstanceRoleService_ListRoles_0 = runtime.ForwardResponseMessage++ forward_InstanceRoleService_CreateRole_0 = runtime.ForwardResponseMessage++ forward_InstanceRoleService_UpdateRole_0 = runtime.ForwardResponseMessage++ forward_InstanceRoleService_DeleteRole_0 = runtime.ForwardResponseMessage++ forward_InstanceRoleService_UndeleteRole_0 = runtime.ForwardResponseMessage+)diff --git a/proto/generated-go/v1/instance_role_service_grpc.pb.go b/proto/generated-go/v1/instance_role_service_grpc.pb.gonew file mode 100644index 0000000000..9a51a9a95f--- /dev/null+++ b/proto/generated-go/v1/instance_role_service_grpc.pb.go@@ -0,0 +1,286 @@+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.+// versions:+// - protoc-gen-go-grpc v1.2.0+// - protoc (unknown)+// source: v1/instance_role_service.proto++package v1++import (+ context "context"+ grpc "google.golang.org/grpc"+ codes "google.golang.org/grpc/codes"+ status "google.golang.org/grpc/status"+ emptypb "google.golang.org/protobuf/types/known/emptypb"+)++// This is a compile-time assertion to ensure that this generated file+// is compatible with the grpc package it is being compiled against.+// Requires gRPC-Go v1.32.0 or later.+const _ = grpc.SupportPackageIsVersion7++// InstanceRoleServiceClient is the client API for InstanceRoleService service.+//+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.+type InstanceRoleServiceClient interface {+ GetRole(ctx context.Context, in *GetRoleRequest, opts ...grpc.CallOption) (*DatabaseRole, error)+ ListRoles(ctx context.Context, in *ListRolesRequest, opts ...grpc.CallOption) (*ListRolesResponse, error)+ CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...grpc.CallOption) (*DatabaseRole, error)+ UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...grpc.CallOption) (*DatabaseRole, error)+ DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)+ UndeleteRole(ctx context.Context, in *UndeleteRoleRequest, opts ...grpc.CallOption) (*DatabaseRole, error)+}++type instanceRoleServiceClient struct {+ cc grpc.ClientConnInterface+}++func NewInstanceRoleServiceClient(cc grpc.ClientConnInterface) InstanceRoleServiceClient {+ return &instanceRoleServiceClient{cc}+}++func (c *instanceRoleServiceClient) GetRole(ctx context.Context, in *GetRoleRequest, opts ...grpc.CallOption) (*DatabaseRole, error) {+ out := new(DatabaseRole)+ err := c.cc.Invoke(ctx, "/bytebase.v1.InstanceRoleService/GetRole", in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++func (c *instanceRoleServiceClient) ListRoles(ctx context.Context, in *ListRolesRequest, opts ...grpc.CallOption) (*ListRolesResponse, error) {+ out := new(ListRolesResponse)+ err := c.cc.Invoke(ctx, "/bytebase.v1.InstanceRoleService/ListRoles", in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++func (c *instanceRoleServiceClient) CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...grpc.CallOption) (*DatabaseRole, error) {+ out := new(DatabaseRole)+ err := c.cc.Invoke(ctx, "/bytebase.v1.InstanceRoleService/CreateRole", in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++func (c *instanceRoleServiceClient) UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...grpc.CallOption) (*DatabaseRole, error) {+ out := new(DatabaseRole)+ err := c.cc.Invoke(ctx, "/bytebase.v1.InstanceRoleService/UpdateRole", in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++func (c *instanceRoleServiceClient) DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {+ out := new(emptypb.Empty)+ err := c.cc.Invoke(ctx, "/bytebase.v1.InstanceRoleService/DeleteRole", in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++func (c *instanceRoleServiceClient) UndeleteRole(ctx context.Context, in *UndeleteRoleRequest, opts ...grpc.CallOption) (*DatabaseRole, error) {+ out := new(DatabaseRole)+ err := c.cc.Invoke(ctx, "/bytebase.v1.InstanceRoleService/UndeleteRole", in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++// InstanceRoleServiceServer is the server API for InstanceRoleService service.+// All implementations must embed UnimplementedInstanceRoleServiceServer+// for forward compatibility+type InstanceRoleServiceServer interface {+ GetRole(context.Context, *GetRoleRequest) (*DatabaseRole, error)+ ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error)+ CreateRole(context.Context, *CreateRoleRequest) (*DatabaseRole, error)+ UpdateRole(context.Context, *UpdateRoleRequest) (*DatabaseRole, error)+ DeleteRole(context.Context, *DeleteRoleRequest) (*emptypb.Empty, error)+ UndeleteRole(context.Context, *UndeleteRoleRequest) (*DatabaseRole, error)+ mustEmbedUnimplementedInstanceRoleServiceServer()+}++// UnimplementedInstanceRoleServiceServer must be embedded to have forward compatible implementations.+type UnimplementedInstanceRoleServiceServer struct {+}++func (UnimplementedInstanceRoleServiceServer) GetRole(context.Context, *GetRoleRequest) (*DatabaseRole, error) {+ return nil, status.Errorf(codes.Unimplemented, "method GetRole not implemented")+}+func (UnimplementedInstanceRoleServiceServer) ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) {+ return nil, status.Errorf(codes.Unimplemented, "method ListRoles not implemented")+}+func (UnimplementedInstanceRoleServiceServer) CreateRole(context.Context, *CreateRoleRequest) (*DatabaseRole, error) {+ return nil, status.Errorf(codes.Unimplemented, "method CreateRole not implemented")+}+func (UnimplementedInstanceRoleServiceServer) UpdateRole(context.Context, *UpdateRoleRequest) (*DatabaseRole, error) {+ return nil, status.Errorf(codes.Unimplemented, "method UpdateRole not implemented")+}+func (UnimplementedInstanceRoleServiceServer) DeleteRole(context.Context, *DeleteRoleRequest) (*emptypb.Empty, error) {+ return nil, status.Errorf(codes.Unimplemented, "method DeleteRole not implemented")+}+func (UnimplementedInstanceRoleServiceServer) UndeleteRole(context.Context, *UndeleteRoleRequest) (*DatabaseRole, error) {+ return nil, status.Errorf(codes.Unimplemented, "method UndeleteRole not implemented")+}+func (UnimplementedInstanceRoleServiceServer) mustEmbedUnimplementedInstanceRoleServiceServer() {}++// UnsafeInstanceRoleServiceServer may be embedded to opt out of forward compatibility for this service.+// Use of this interface is not recommended, as added methods to InstanceRoleServiceServer will+// result in compilation errors.+type UnsafeInstanceRoleServiceServer interface {+ mustEmbedUnimplementedInstanceRoleServiceServer()+}++func RegisterInstanceRoleServiceServer(s grpc.ServiceRegistrar, srv InstanceRoleServiceServer) {+ s.RegisterService(&InstanceRoleService_ServiceDesc, srv)+}++func _InstanceRoleService_GetRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(GetRoleRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InstanceRoleServiceServer).GetRole(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: "/bytebase.v1.InstanceRoleService/GetRole",+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InstanceRoleServiceServer).GetRole(ctx, req.(*GetRoleRequest))+ }+ return interceptor(ctx, in, info, handler)+}++func _InstanceRoleService_ListRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(ListRolesRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InstanceRoleServiceServer).ListRoles(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: "/bytebase.v1.InstanceRoleService/ListRoles",+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InstanceRoleServiceServer).ListRoles(ctx, req.(*ListRolesRequest))+ }+ return interceptor(ctx, in, info, handler)+}++func _InstanceRoleService_CreateRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(CreateRoleRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InstanceRoleServiceServer).CreateRole(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: "/bytebase.v1.InstanceRoleService/CreateRole",+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InstanceRoleServiceServer).CreateRole(ctx, req.(*CreateRoleRequest))+ }+ return interceptor(ctx, in, info, handler)+}++func _InstanceRoleService_UpdateRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(UpdateRoleRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InstanceRoleServiceServer).UpdateRole(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: "/bytebase.v1.InstanceRoleService/UpdateRole",+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InstanceRoleServiceServer).UpdateRole(ctx, req.(*UpdateRoleRequest))+ }+ return interceptor(ctx, in, info, handler)+}++func _InstanceRoleService_DeleteRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(DeleteRoleRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InstanceRoleServiceServer).DeleteRole(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: "/bytebase.v1.InstanceRoleService/DeleteRole",+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InstanceRoleServiceServer).DeleteRole(ctx, req.(*DeleteRoleRequest))+ }+ return interceptor(ctx, in, info, handler)+}++func _InstanceRoleService_UndeleteRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(UndeleteRoleRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InstanceRoleServiceServer).UndeleteRole(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: "/bytebase.v1.InstanceRoleService/UndeleteRole",+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InstanceRoleServiceServer).UndeleteRole(ctx, req.(*UndeleteRoleRequest))+ }+ return interceptor(ctx, in, info, handler)+}++// InstanceRoleService_ServiceDesc is the grpc.ServiceDesc for InstanceRoleService service.+// It's only intended for direct use with grpc.RegisterService,+// and not to be introspected or modified (even as a copy)+var InstanceRoleService_ServiceDesc = grpc.ServiceDesc{+ ServiceName: "bytebase.v1.InstanceRoleService",+ HandlerType: (*InstanceRoleServiceServer)(nil),+ Methods: []grpc.MethodDesc{+ {+ MethodName: "GetRole",+ Handler: _InstanceRoleService_GetRole_Handler,+ },+ {+ MethodName: "ListRoles",+ Handler: _InstanceRoleService_ListRoles_Handler,+ },+ {+ MethodName: "CreateRole",+ Handler: _InstanceRoleService_CreateRole_Handler,+ },+ {+ MethodName: "UpdateRole",+ Handler: _InstanceRoleService_UpdateRole_Handler,+ },+ {+ MethodName: "DeleteRole",+ Handler: _InstanceRoleService_DeleteRole_Handler,+ },+ {+ MethodName: "UndeleteRole",+ Handler: _InstanceRoleService_UndeleteRole_Handler,+ },+ },+ Streams: []grpc.StreamDesc{},+ Metadata: "v1/instance_role_service.proto",+}diff --git a/proto/v1/database_role.proto b/proto/v1/database_role.protodeleted file mode 100644index f8f585345d..0000000000--- a/proto/v1/database_role.proto+++ /dev/null@@ -1,69 +0,0 @@-syntax = "proto3";--package bytebase.v1;-option go_package = "generated-go/v1";--// RoleAttribute is the attribute for role. Docs: https://www.postgresql.org/docs/current/role-attributes.html-message DatabaseRoleAttribute {- // A database superuser bypasses all permission checks, except the right to log in.- bool super_user = 1;-- // A role is given permission to inherit the privileges of roles it is a member of. To create a role without the permission, use "noInherit = true"- bool no_inherit = 2;-- // A role must be explicitly given permission to create more roles (except for superusers, since those bypass all permission checks).- bool create_role = 3;-- // A role must be explicitly given permission to create databases (except for superusers, since those bypass all permission checks).- bool create_db = 4;-- // Only roles that have the LOGIN attribute can be used as the initial role name for a database connection.- bool can_login = 5;-- // A role must explicitly be given permission to initiate streaming replication (except for superusers, since those bypass all permission checks).- bool replication = 6;-- // A role must be explicitly given permission to bypass every row-level security (RLS) policy (except for superusers, since those bypass all permission checks).- bool bypass_rls = 7;-}--// DatabaseRole is the API message for database role.-message DatabaseRole {- // The role unique name.- string name = 1;-- // The Bytebase instance id for this role.- int32 instance_id = 2;-- // The connection count limit for this role.- int32 connection_limit = 3;-- // The expiration for the role's password.- optional string valid_until = 4;-- // The role attribute.- DatabaseRoleAttribute attribute = 5;-}--// ListDatabaseRoleResponse is the API message for role list.-message ListDatabaseRoleResponse {- repeated DatabaseRole roles = 1;-}--// DatabaseRoleUpsert is the API message for upserting a database role.-message DatabaseRoleUpsert {- // The role unique name.- string name = 1;-- // A password is only significant if the client authentication method requires the user to supply a password when connecting to the database.- optional string password = 2;-- // Connection limit can specify how many concurrent connections a role can make. -1 (the default) means no limit.- optional int32 connection_limit = 3;-- // The VALID UNTIL clause sets a date and time after which the role's password is no longer valid. If this clause is omitted the password will be valid for all time.- optional string valid_until = 4;-- // The role attribute.- optional DatabaseRoleAttribute attribute = 5;-}diff --git a/proto/v1/instance_role_service.proto b/proto/v1/instance_role_service.protonew file mode 100644index 0000000000..69257232b9--- /dev/null+++ b/proto/v1/instance_role_service.proto@@ -0,0 +1,173 @@+syntax = "proto3";++package bytebase.v1;++import "google/api/annotations.proto";+import "google/api/client.proto";+import "google/api/field_behavior.proto";+import "google/protobuf/empty.proto";+import "google/protobuf/field_mask.proto";++import "v1/common.proto";++option go_package = "generated-go/v1";++service InstanceRoleService {+ rpc GetRole(GetRoleRequest) returns (DatabaseRole) {+ option (google.api.http) = {+ get: "/v1/{name=environments/*/instances/*/roles/*}"+ };+ option (google.api.method_signature) = "name";+ }++ rpc ListRoles(ListRolesRequest) returns (ListRolesResponse) {+ option (google.api.http) = {+ get: "/v1/{parent=environments/*/instances/*}/roles"+ };+ option (google.api.method_signature) = "parent";+ }++ rpc CreateRole(CreateRoleRequest) returns (DatabaseRole) {+ option (google.api.http) = {+ post: "/v1/{parent=environments/*/instances/*}/roles"+ body: "role"+ };+ option (google.api.method_signature) = "parent,role";+ }++ rpc UpdateRole(UpdateRoleRequest) returns (DatabaseRole) {+ option (google.api.http) = {+ patch: "/v1/{role.name=environments/*/instances/*/roles/*}"+ body: "role"+ };+ option (google.api.method_signature) = "role,update_mask";+ }++ rpc DeleteRole(DeleteRoleRequest) returns (google.protobuf.Empty) {+ option (google.api.http) = {+ delete: "/v1/{name=environments/*/instances/*/roles/*}"+ };+ option (google.api.method_signature) = "name";+ }++ rpc UndeleteRole(UndeleteRoleRequest) returns (DatabaseRole) {+ option (google.api.http) = {+ post: "/v1/{name=environments/*/instances/*/roles/*}:undelete"+ body: "*"+ };+ }+}++message GetRoleRequest {+ // The name of the role to retrieve.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ // The role name is the unique name for the role.+ string name = 1 [(google.api.field_behavior) = REQUIRED];+}++message ListRolesRequest {+ // The parent, which owns this collection of roles.+ // Format: environments/{environment}/instances/{instance}+ string parent = 1 [(google.api.field_behavior) = REQUIRED];++ // The maximum number of roles to return. The service may return fewer than+ // this value.+ // If unspecified, at most 50 roles will be returned.+ // The maximum value is 1000; values above 1000 will be coerced to 1000.+ int32 page_size = 2;++ // A page token, received from a previous `ListRoles` call.+ // Provide this to retrieve the subsequent page.+ //+ // When paginating, all other parameters provided to `ListRoles` must match+ // the call that provided the page token.+ string page_token = 3;+}++message ListRolesResponse {+ // The roles from the specified request.+ repeated DatabaseRole roles = 1;++ // A token, which can be sent as `page_token` to retrieve the next page.+ // If this field is omitted, there are no subsequent pages.+ string next_page_token = 2;+}++message CreateRoleRequest {+ // The parent resource where this role will be created.+ // Format: environments/{environment}/instances/{instance}+ string parent = 1 [(google.api.field_behavior) = REQUIRED];++ // The role to create.+ DatabaseRole role = 2 [(google.api.field_behavior) = REQUIRED];+}++message UpdateRoleRequest {+ // The role to update.+ //+ // The role's `name`, `environment` and `instance` field is used to identify the role to update.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ DatabaseRole role = 1 [(google.api.field_behavior) = REQUIRED];++ // The list of fields to update.+ google.protobuf.FieldMask update_mask = 2;+}++message DeleteRoleRequest {+ // The name of the role to delete.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ string name = 1 [(google.api.field_behavior) = REQUIRED];+}++message UndeleteRoleRequest {+ // The name of the deleted role.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ string name = 1 [(google.api.field_behavior) = REQUIRED];+}++// RoleAttribute is the attribute for role. Docs: https://www.postgresql.org/docs/current/role-attributes.html+message DatabaseRoleAttribute {+ // A database superuser bypasses all permission checks, except the right to log in.+ bool super_user = 1;++ // A role is given permission to inherit the privileges of roles it is a member of. To create a role without the permission, use "noInherit = true"+ bool no_inherit = 2;++ // A role must be explicitly given permission to create more roles (except for superusers, since those bypass all permission checks).+ bool create_role = 3;++ // A role must be explicitly given permission to create databases (except for superusers, since those bypass all permission checks).+ bool create_db = 4;++ // Only roles that have the LOGIN attribute can be used as the initial role name for a database connection.+ bool can_login = 5;++ // A role must explicitly be given permission to initiate streaming replication (except for superusers, since those bypass all permission checks).+ bool replication = 6;++ // A role must be explicitly given permission to bypass every row-level security (RLS) policy (except for superusers, since those bypass all permission checks).+ bool bypass_rls = 7;+}++// DatabaseRole is the API message for database role.+message DatabaseRole {+ // The name of the role.+ // Format: environments/{environment}/instances/{instance}/roles/{role name}+ // The role name is the unique name for the role.+ string name = 1;++ // The role unique name.+ string title = 2;++ // The role password.+ optional string password = 3 [(google.api.field_behavior) = INPUT_ONLY];++ // The connection count limit for this role.+ optional int32 connection_limit = 4;++ // The expiration for the role's password.+ optional string valid_until = 5;++ // The role attribute.+ DatabaseRoleAttribute attribute = 6;+}\ No newline at end of filediff --git a/server/api/v1/common.go b/server/api/v1/common.goindex 9a6de7c6de..31f4dd3fca 100644--- a/server/api/v1/common.go+++ b/server/api/v1/common.go@@ -17,6 +17,7 @@ const (environmentNamePrefix = "environments/"instanceNamePrefix = "instances/"databaseIDPrefix = "databases/"+ instanceRolePrefix = "roles/"userNamePrefix = "users/")@@ -51,6 +52,15 @@ func getEnvironmentInstanceID(name string) (string, string, error) {return tokens[0], tokens[1], nil}+func getEnvironmentInstanceRoleID(name string) (string, string, string, error) {+ // the instance request should be environments/{environment-id}/instances/{instance-id}/roles/{role-name}+ tokens, err := getNameParentTokens(name, environmentNamePrefix, instanceNamePrefix, instanceRolePrefix)+ if err != nil {+ return "", "", "", err+ }+ return tokens[0], tokens[1], tokens[2], nil+}+func getEnvironmentInstanceDatabaseID(name string) (string, string, string, error) {// the instance request should be environments/{environment-id}/instances/{instance-id}/databases/{database-id}tokens, err := getNameParentTokens(name, environmentNamePrefix, instanceNamePrefix, databaseIDPrefix)diff --git a/server/api/v1/database_role_service.go b/server/api/v1/database_role_service.gonew file mode 100644index 0000000000..f6263772b4--- /dev/null+++ b/server/api/v1/database_role_service.go@@ -0,0 +1,352 @@+package v1++import (+ "context"+ "fmt"+ "time"++ "google.golang.org/grpc/codes"+ "google.golang.org/grpc/status"+ "google.golang.org/protobuf/types/known/emptypb"++ "github.com/bytebase/bytebase/api"+ "github.com/bytebase/bytebase/common"+ "github.com/bytebase/bytebase/plugin/db"+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+ "github.com/bytebase/bytebase/server/component/dbfactory"+ "github.com/bytebase/bytebase/store"+)++// InstanceRoleService implements the database role service.+type InstanceRoleService struct {+ v1pb.UnimplementedInstanceRoleServiceServer+ store *store.Store+ dbFactory *dbfactory.DBFactory+}++// NewInstanceRoleService creates a new InstanceRoleService.+func NewInstanceRoleService(store *store.Store, dbFactory *dbfactory.DBFactory) *InstanceRoleService {+ return &InstanceRoleService{+ store: store,+ dbFactory: dbFactory,+ }+}++// GetRole gets an role.+func (s *InstanceRoleService) GetRole(ctx context.Context, request *v1pb.GetRoleRequest) (*v1pb.DatabaseRole, error) {+ environmentID, instanceID, roleName, err := getEnvironmentInstanceRoleID(request.Name)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }++ environment, instance, err := s.getEnvironmentAndInstance(ctx, environmentID, instanceID)+ if err != nil {+ return nil, err+ }++ role, err := func() (*db.DatabaseRoleMessage, error) {+ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, convertToLegacyInstance(instance, environment), "" /* database name */)+ if err != nil {+ return nil, err+ }+ defer driver.Close(ctx)++ role, err := driver.FindRole(ctx, roleName)+ if err != nil {+ return nil, err+ }++ return role, nil+ }()+ if err != nil {+ if common.ErrorCode(err) == common.NotFound {+ return nil, status.Errorf(codes.NotFound, "role %s not found", request.Name)+ }+ return nil, status.Errorf(codes.Internal, err.Error())+ }++ return convertToRole(role, instance), nil+}++// ListRoles lists all roles in an instance.+func (s *InstanceRoleService) ListRoles(ctx context.Context, request *v1pb.ListRolesRequest) (*v1pb.ListRolesResponse, error) {+ environmentID, instanceID, err := getEnvironmentInstanceID(request.Parent)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }++ environment, instance, err := s.getEnvironmentAndInstance(ctx, environmentID, instanceID)+ if err != nil {+ return nil, err+ }++ roleList, err := func() ([]*db.DatabaseRoleMessage, error) {+ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, convertToLegacyInstance(instance, environment), "" /* database name */)+ if err != nil {+ return nil, err+ }+ defer driver.Close(ctx)++ roleList, err := driver.ListRole(ctx)+ if err != nil {+ return nil, err+ }++ return roleList, nil+ }()+ if err != nil {+ return nil, status.Errorf(codes.Internal, err.Error())+ }++ response := &v1pb.ListRolesResponse{}+ for _, role := range roleList {+ response.Roles = append(response.Roles, convertToRole(role, instance))+ }+ return response, nil+}++// CreateRole creates an role.+func (s *InstanceRoleService) CreateRole(ctx context.Context, request *v1pb.CreateRoleRequest) (*v1pb.DatabaseRole, error) {+ if request.Role == nil {+ return nil, status.Errorf(codes.InvalidArgument, "role must be set")+ }+ environmentID, instanceID, err := getEnvironmentInstanceID(request.Parent)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }+ environment, instance, err := s.getEnvironmentAndInstance(ctx, environmentID, instanceID)+ if err != nil {+ return nil, err+ }++ roleUpsert := &db.DatabaseRoleUpsertMessage{+ Name: request.Role.Title,+ Password: request.Role.Password,+ ConnectionLimit: request.Role.ConnectionLimit,+ ValidUntil: request.Role.ValidUntil,+ Attribute: &db.DatabaseRoleAttributeMessage{+ SuperUser: request.Role.Attribute.SuperUser,+ NoInherit: request.Role.Attribute.NoInherit,+ CreateRole: request.Role.Attribute.CreateRole,+ CreateDb: request.Role.Attribute.CreateDb,+ CanLogin: request.Role.Attribute.CanLogin,+ Replication: request.Role.Attribute.Replication,+ BypassRls: request.Role.Attribute.BypassRls,+ },+ }+ if err := validateRole(roleUpsert); err != nil {+ return nil, err+ }++ role, err := func() (*db.DatabaseRoleMessage, error) {+ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, convertToLegacyInstance(instance, environment), "" /* database name */)+ if err != nil {+ return nil, err+ }+ defer driver.Close(ctx)++ role, err := driver.CreateRole(ctx, roleUpsert)+ if err != nil {+ return nil, err+ }++ return role, nil+ }()+ if err != nil {+ return nil, status.Errorf(codes.Internal, err.Error())+ }++ return convertToRole(role, instance), nil+}++// UpdateRole updates an role.+func (s *InstanceRoleService) UpdateRole(ctx context.Context, request *v1pb.UpdateRoleRequest) (*v1pb.DatabaseRole, error) {+ if request.UpdateMask == nil {+ return nil, status.Errorf(codes.InvalidArgument, "update_mask must be set")+ }+ environmentID, instanceID, roleName, err := getEnvironmentInstanceRoleID(request.Role.Name)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }++ environment, instance, err := s.getEnvironmentAndInstance(ctx, environmentID, instanceID)+ if err != nil {+ return nil, err+ }++ upsert := &db.DatabaseRoleUpsertMessage{+ Name: roleName,+ }+ for _, path := range request.UpdateMask.Paths {+ switch path {+ case "role.title":+ upsert.Name = request.Role.Title+ case "role.password":+ upsert.Password = request.Role.Password+ case "role.connection_limit":+ upsert.ConnectionLimit = request.Role.ConnectionLimit+ case "role.valid_until":+ upsert.ValidUntil = request.Role.ValidUntil+ case "role.attribute":+ upsert.Attribute = &db.DatabaseRoleAttributeMessage{+ SuperUser: request.Role.Attribute.SuperUser,+ NoInherit: request.Role.Attribute.NoInherit,+ CreateRole: request.Role.Attribute.CreateRole,+ CreateDb: request.Role.Attribute.CreateDb,+ CanLogin: request.Role.Attribute.CanLogin,+ Replication: request.Role.Attribute.Replication,+ BypassRls: request.Role.Attribute.BypassRls,+ }+ }+ }+ if err := validateRole(upsert); err != nil {+ return nil, err+ }++ role, err := func() (*db.DatabaseRoleMessage, error) {+ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, convertToLegacyInstance(instance, environment), "" /* database name */)+ if err != nil {+ return nil, err+ }+ defer driver.Close(ctx)++ role, err := driver.UpdateRole(ctx, roleName, upsert)+ if err != nil {+ return nil, err+ }++ return role, nil+ }()+ if err != nil {+ if common.ErrorCode(err) == common.NotFound {+ return nil, status.Errorf(codes.NotFound, "role %s not found", request.Role.Name)+ }+ return nil, status.Errorf(codes.Internal, err.Error())+ }++ return convertToRole(role, instance), nil+}++// DeleteRole deletes an role.+func (s *InstanceRoleService) DeleteRole(ctx context.Context, request *v1pb.DeleteRoleRequest) (*emptypb.Empty, error) {+ environmentID, instanceID, roleName, err := getEnvironmentInstanceRoleID(request.Name)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }++ environment, instance, err := s.getEnvironmentAndInstance(ctx, environmentID, instanceID)+ if err != nil {+ return nil, err+ }++ if err := func() error {+ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, convertToLegacyInstance(instance, environment), "" /* database name */)+ if err != nil {+ return err+ }+ defer driver.Close(ctx)++ return driver.DeleteRole(ctx, roleName)+ }(); err != nil {+ return nil, status.Errorf(codes.Internal, err.Error())+ }++ return &emptypb.Empty{}, nil+}++// UndeleteRole undeletes an role.+func (*InstanceRoleService) UndeleteRole(_ context.Context, _ *v1pb.UndeleteRoleRequest) (*v1pb.DatabaseRole, error) {+ return nil, status.Errorf(codes.Unimplemented, "Undelete role is not supported")+}++func (s *InstanceRoleService) getEnvironmentAndInstance(ctx context.Context, environmentID, instanceID string) (*store.EnvironmentMessage, *store.InstanceMessage, error) {+ environment, err := s.store.GetEnvironmentV2(ctx, environmentID)+ if err != nil {+ return nil, nil, status.Errorf(codes.Internal, err.Error())+ }+ if environment == nil {+ return nil, nil, status.Errorf(codes.NotFound, "environment %q not found", environmentID)+ }++ instance, err := s.store.GetInstanceV2(ctx, &store.FindInstanceMessage{+ EnvironmentID: &environmentID,+ ResourceID: &instanceID,+ })+ if err != nil {+ return nil, nil, status.Errorf(codes.Internal, err.Error())+ }+ if instance == nil {+ return nil, nil, status.Errorf(codes.NotFound, "instance %q not found", instanceID)+ }++ return environment, instance, nil+}++func convertToLegacyInstance(instance *store.InstanceMessage, environment *store.EnvironmentMessage) *api.Instance {+ port := ""+ host := ""+ ds := []*api.DataSource{}+ for _, dataSource := range instance.DataSources {+ if dataSource.Type == api.Admin {+ port = dataSource.Port+ host = dataSource.Host+ }+ ds = append(ds, &api.DataSource{+ Type: dataSource.Type,+ Name: dataSource.Title,+ Username: dataSource.Username,+ Password: dataSource.Password,+ SslCa: dataSource.SslCa,+ SslCert: dataSource.SslCert,+ SslKey: dataSource.SslKey,+ Host: dataSource.Host,+ Port: dataSource.Port,+ Database: dataSource.Database,+ })+ }++ return &api.Instance{+ ID: instance.UID,+ Engine: instance.Engine,+ Host: host,+ Port: port,+ Environment: &api.Environment{+ Name: environment.Title,+ },+ DataSourceList: ds,+ }+}++func convertToRole(role *db.DatabaseRoleMessage, instance *store.InstanceMessage) *v1pb.DatabaseRole {+ return &v1pb.DatabaseRole{+ Name: fmt.Sprintf("environments/%s/instances/%s/roles/%s", instance.EnvironmentID, instance.ResourceID, role.Name),+ Title: role.Name,+ ConnectionLimit: &role.ConnectionLimit,+ ValidUntil: role.ValidUntil,+ Attribute: &v1pb.DatabaseRoleAttribute{+ SuperUser: role.Attribute.SuperUser,+ NoInherit: role.Attribute.NoInherit,+ CreateRole: role.Attribute.CreateRole,+ CreateDb: role.Attribute.CreateDb,+ CanLogin: role.Attribute.CanLogin,+ Replication: role.Attribute.Replication,+ BypassRls: role.Attribute.BypassRls,+ },+ }+}++func validateRole(upsert *db.DatabaseRoleUpsertMessage) error {+ if upsert.Name == "" {+ return status.Errorf(codes.InvalidArgument, "Invalid role name, role name cannot be empty")+ }+ if v := upsert.ConnectionLimit; v != nil && *v < int32(-1) {+ return status.Errorf(codes.InvalidArgument, "Invalid connection limit, it should greater than or equal to -1")+ }+ if v := upsert.ValidUntil; v != nil {+ if _, err := time.Parse(time.RFC3339, *v); err != nil {+ return status.Errorf(codes.InvalidArgument, "Invalid timestamp for valid_until, timestamp should in '2006-01-02T15:04:05+08:00' format.")+ }+ }++ return nil+}diff --git a/server/openapi_instance.go b/server/openapi_instance.goindex fe4b110095..f11f443ba3 100644--- a/server/openapi_instance.go+++ b/server/openapi_instance.go@@ -1,506 +1,16 @@package serverimport (- "context""encoding/json"- "fmt""io""net/http"- "strconv"- "time""github.com/labstack/echo/v4"- "google.golang.org/protobuf/encoding/protojson""github.com/bytebase/bytebase/api"openAPIV1 "github.com/bytebase/bytebase/api/v1"- "github.com/bytebase/bytebase/common"- "github.com/bytebase/bytebase/plugin/db"- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"-- "github.com/bytebase/bytebase/store")-func (s *Server) listInstance(c echo.Context) error {- ctx := c.Request().Context()- rowStatus := api.Normal- find := &api.InstanceFind{- RowStatus: &rowStatus,- }- if name := c.QueryParam("name"); name != "" {- find.Name = &name- }-- instanceList, err := s.store.FindInstance(ctx, find)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch instance list").SetInternal(err)- }-- response := []*openAPIV1.Instance{}- for _, instance := range instanceList {- response = append(response, convertToOpenAPIInstance(instance))- }-- return c.JSON(http.StatusOK, response)-}--func (s *Server) createInstanceByOpenAPI(c echo.Context) error {- ctx := c.Request().Context()-- body, err := io.ReadAll(c.Request().Body)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Failed to read request body").SetInternal(err)- }-- instanceCreate := &openAPIV1.InstanceCreate{}- if err := json.Unmarshal(body, instanceCreate); err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Malformed create instance request").SetInternal(err)- }-- environmentName := instanceCreate.Environment- envList, err := s.store.FindEnvironment(ctx, &api.EnvironmentFind{- Name: &environmentName,- })- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to find environment by name: %s", instanceCreate.Environment)).SetInternal(err)- }- if len(envList) != 1 {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Should only find one environment with name: %s", instanceCreate.Environment))- }-- dataSourceCreateList, err := convertToAPIDataSouceList(instanceCreate.DataSourceList)- if err != nil {- return err- }- if len(dataSourceCreateList) == 0 {- return echo.NewHTTPError(http.StatusBadRequest, "Should specific at least one data source.")- }-- instance, err := s.createInstance(ctx, &store.InstanceCreate{- CreatorID: c.Get(getPrincipalIDContextKey()).(int),- EnvironmentID: envList[0].ID,- DataSourceList: dataSourceCreateList,- Name: instanceCreate.Name,- Engine: instanceCreate.Engine,- ExternalLink: instanceCreate.ExternalLink,- Host: instanceCreate.Host,- Port: instanceCreate.Port,- Database: instanceCreate.Database,- })- if err != nil {- return err- }-- return c.JSON(http.StatusOK, convertToOpenAPIInstance(instance))-}--func (s *Server) updateInstanceByOpenAPI(c echo.Context) error {- ctx := c.Request().Context()- id, err := strconv.Atoi(c.Param("instanceID"))- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("instanceID"))).SetInternal(err)- }-- body, err := io.ReadAll(c.Request().Body)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Failed to read request body").SetInternal(err)- }-- instancePatch := &openAPIV1.InstancePatch{}- if err := json.Unmarshal(body, instancePatch); err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Malformed patch instance request").SetInternal(err)- }-- patch := &store.InstancePatch{- ID: id,- UpdaterID: c.Get(getPrincipalIDContextKey()).(int),- Name: instancePatch.Name,- ExternalLink: instancePatch.ExternalLink,- Host: instancePatch.Host,- Port: instancePatch.Port,- Database: instancePatch.Database,- }-- dataSourceCreateList, err := convertToAPIDataSouceList(instancePatch.DataSourceList)- if err != nil {- return err- }- patch.DataSourceList = dataSourceCreateList-- instance, err := s.updateInstance(ctx, patch)- if err != nil {- return err- }-- return c.JSON(http.StatusOK, convertToOpenAPIInstance(instance))-}--func (s *Server) deleteInstanceByOpenAPI(c echo.Context) error {- ctx := c.Request().Context()- id, err := strconv.Atoi(c.Param("instanceID"))- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("instanceID"))).SetInternal(err)- }-- instance, err := s.store.GetInstanceByID(ctx, id)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)- }- if instance == nil {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance not found by id: %d", id))- }-- name := fmt.Sprintf("archived_%s_%d", instance.Name, time.Now().Unix())- rowStatus := string(api.Archived)- if _, err := s.updateInstance(ctx, &store.InstancePatch{- ID: id,- UpdaterID: c.Get(getPrincipalIDContextKey()).(int),- RowStatus: &rowStatus,- Name: &name,- }); err != nil {- return err- }-- return c.String(http.StatusOK, "ok")-}--func (s *Server) getInstanceByID(c echo.Context) error {- ctx := c.Request().Context()- id, err := strconv.Atoi(c.Param("instanceID"))- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("instanceID"))).SetInternal(err)- }-- instance, err := s.store.GetInstanceByID(ctx, id)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)- }- if instance == nil {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", id))- }-- return c.JSON(http.StatusOK, convertToOpenAPIInstance(instance))-}--func (s *Server) listDatabaseRole(c echo.Context) error {- ctx := c.Request().Context()- instance, err := s.validateInstance(ctx, c)- if err != nil {- return err- }-- roleList, err := func() ([]*v1pb.DatabaseRole, error) {- driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, "" /* database name */)- if err != nil {- return nil, err- }- defer driver.Close(ctx)-- roleList, err := driver.ListRole(ctx)- if err != nil {- return nil, err- }-- return roleList, nil- }()- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to list the role").SetInternal(err)- }-- response := &v1pb.ListDatabaseRoleResponse{}- for _, role := range roleList {- response.Roles = append(response.Roles, &v1pb.DatabaseRole{- Name: role.Name,- InstanceId: int32(instance.ID),- ConnectionLimit: role.ConnectionLimit,- ValidUntil: role.ValidUntil,- Attribute: role.Attribute,- })- }- metadataBytes, err := protojson.Marshal(response)- if err != nil {- return err- }-- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if _, err := c.Response().Write(metadataBytes); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to write schema response for role list").SetInternal(err)- }-- return nil-}--func (s *Server) getDatabaseRole(c echo.Context) error {- ctx := c.Request().Context()- roleName := c.Param("roleName")-- instance, err := s.validateInstance(ctx, c)- if err != nil {- return err- }-- role, err := func() (*v1pb.DatabaseRole, error) {- driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, "" /* database name */)- if err != nil {- return nil, err- }- defer driver.Close(ctx)-- role, err := driver.FindRole(ctx, roleName)- if err != nil {- return nil, err- }-- return role, nil- }()- if err != nil {- if common.ErrorCode(err) == common.NotFound {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Cannot found the role %s in instance %d", roleName, instance.ID))- }- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to query the role").SetInternal(err)- }-- return marshalDatabaseRoleResponse(c, role, instance.ID)-}--func (s *Server) createDatabaseRole(c echo.Context) error {- ctx := c.Request().Context()-- body, err := io.ReadAll(c.Request().Body)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Failed to read request body").SetInternal(err)- }-- upsert := &v1pb.DatabaseRoleUpsert{}- if err := protojson.Unmarshal(body, upsert); err != nil {- return err- }- if err := validateRole(upsert); err != nil {- return err- }-- instance, err := s.validateInstance(ctx, c)- if err != nil {- return err- }-- role, err := func() (*v1pb.DatabaseRole, error) {- driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, "" /* database name */)- if err != nil {- return nil, err- }- defer driver.Close(ctx)-- role, err := driver.CreateRole(ctx, upsert)- if err != nil {- return nil, err- }-- return role, nil- }()- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to create the role").SetInternal(err)- }-- return marshalDatabaseRoleResponse(c, role, instance.ID)-}--func (s *Server) deleteDatabaseRole(c echo.Context) error {- ctx := c.Request().Context()- roleName := c.Param("roleName")-- instance, err := s.validateInstance(ctx, c)- if err != nil {- return err- }-- if err := func() error {- driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, "" /* database name */)- if err != nil {- return err- }- defer driver.Close(ctx)-- return driver.DeleteRole(ctx, roleName)- }(); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to drop the role %s", roleName)).SetInternal(err)- }-- return c.String(http.StatusOK, "ok")-}--func (s *Server) updateDatabaseRole(c echo.Context) error {- ctx := c.Request().Context()-- body, err := io.ReadAll(c.Request().Body)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Failed to read request body").SetInternal(err)- }-- upsert := &v1pb.DatabaseRoleUpsert{}- if err := protojson.Unmarshal(body, upsert); err != nil {- return err- }- if err := validateRole(upsert); err != nil {- return err- }-- instance, err := s.validateInstance(ctx, c)- if err != nil {- return err- }-- rawName := c.Param("roleName")- role, err := func() (*v1pb.DatabaseRole, error) {- driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, "" /* database name */)- if err != nil {- return nil, err- }- defer driver.Close(ctx)-- role, err := driver.UpdateRole(ctx, rawName, upsert)- if err != nil {- return nil, err- }-- return role, nil- }()- if err != nil {- if common.ErrorCode(err) == common.NotFound {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Cannot found the role %s in instance %d", rawName, instance.ID))- }- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to update the role").SetInternal(err)- }-- return marshalDatabaseRoleResponse(c, role, instance.ID)-}--func validateRole(upsert *v1pb.DatabaseRoleUpsert) error {- if v := upsert.ConnectionLimit; v != nil && *v < int32(-1) {- return echo.NewHTTPError(http.StatusBadRequest, "Invalid connection limit, it should greater than or equal to -1")- }- if v := upsert.ValidUntil; v != nil {- if _, err := time.Parse(time.RFC3339, *v); err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Invalid timestamp for valid_until").SetInternal(err)- }- }-- return nil-}--func (s *Server) validateInstance(ctx context.Context, c echo.Context) (*api.Instance, error) {- instanceID, err := strconv.Atoi(c.Param("instanceID"))- if err != nil {- return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("instanceID"))).SetInternal(err)- }-- instance, err := s.store.GetInstanceByID(ctx, instanceID)- if err != nil {- return nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", instanceID)).SetInternal(err)- }- if instance == nil {- return nil, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Instance ID not found: %d", instanceID))- }- if instance.Engine != db.Postgres {- return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Role management for %v is not support", instance.Engine))- }-- return instance, nil-}--func marshalDatabaseRoleResponse(c echo.Context, role *v1pb.DatabaseRole, instanceID int) error {- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- metadataBytes, err := protojson.Marshal(&v1pb.DatabaseRole{- Name: role.Name,- InstanceId: int32(instanceID),- ConnectionLimit: role.ConnectionLimit,- ValidUntil: role.ValidUntil,- Attribute: role.Attribute,- })- if err != nil {- return err- }- if _, err := c.Response().Write(metadataBytes); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to write schema response for role %v", role.Name)).SetInternal(err)- }-- return nil-}--func convertToOpenAPIInstance(instance *api.Instance) *openAPIV1.Instance {- dataSourceList := []*openAPIV1.DataSource{}- for _, dataSource := range instance.DataSourceList {- dataSourceList = append(dataSourceList, &openAPIV1.DataSource{- ID: dataSource.ID,- DatabaseID: dataSource.DatabaseID,- Name: dataSource.Name,- Type: dataSource.Type,- Username: dataSource.Username,- Host: dataSource.Host,- Port: dataSource.Port,- })- }-- return &openAPIV1.Instance{- ID: instance.ID,- Environment: instance.Environment.Name,- Name: instance.Name,- Engine: instance.Engine,- EngineVersion: instance.EngineVersion,- ExternalLink: instance.ExternalLink,- Host: instance.Host,- Port: instance.Port,- Database: instance.Database,- DataSourceList: dataSourceList,- }-}--func convertToAPIDataSouceList(dataSourceList []*openAPIV1.DataSourceCreate) ([]*api.DataSourceCreate, error) {- var res []*api.DataSourceCreate-- dataSourceNameMap := map[string]bool{}- dataSourceTypeMap := map[api.DataSourceType]bool{}- for _, dataSource := range dataSourceList {- if dataSourceNameMap[dataSource.Name] {- return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Duplicate data source name %s. The data source name should be unique", dataSource.Name))- }- if dataSourceTypeMap[dataSource.Type] {- return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Duplicate data source type %s. The data source type should be unique", dataSource.Name))- }- dataSourceNameMap[dataSource.Name] = true- dataSourceTypeMap[dataSource.Type] = true-- switch dataSource.Type {- case api.Admin:- res = append(res, &api.DataSourceCreate{- Name: dataSource.Name,- Type: api.Admin,- Username: dataSource.Username,- Password: dataSource.Password,- SslCa: dataSource.SslCa,- SslCert: dataSource.SslCert,- SslKey: dataSource.SslKey,- })- case api.RO:- res = append(res, &api.DataSourceCreate{- Name: dataSource.Name,- Type: api.RO,- Username: dataSource.Username,- Password: dataSource.Password,- SslCa: dataSource.SslCa,- SslCert: dataSource.SslCert,- SslKey: dataSource.SslKey,- Host: dataSource.Host,- Port: dataSource.Port,- })- default:- return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("The data source type %s is not supported", dataSource.Type))- }- }-- return res, nil-}-func (s *Server) updateInstanceDatabase(c echo.Context) error {ctx := c.Request().Context()instanceName := c.Param("instanceName")diff --git a/server/server.go b/server/server.goindex 643d1e0e68..2856293833 100644--- a/server/server.go+++ b/server/server.go@@ -447,6 +447,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {v1pb.RegisterInstanceServiceServer(s.grpcServer, v1.NewInstanceService(s.store, s.licenseService))v1pb.RegisterProjectServiceServer(s.grpcServer, v1.NewProjectService(s.store))v1pb.RegisterDatabaseServiceServer(s.grpcServer, v1.NewDatabaseService(s.store))+ v1pb.RegisterInstanceRoleServiceServer(s.grpcServer, v1.NewInstanceRoleService(s.store, dbfactory.New(s.mysqlBinDir, s.mongoBinDir, s.pgBinDir, profile.DataDir)))opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}grpcEndpoint := fmt.Sprintf(":%d", profile.GrpcPort)if err := v1pb.RegisterAuthServiceHandlerFromEndpoint(ctx, mux, grpcEndpoint, opts); err != nil {@@ -464,6 +465,9 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {if err := v1pb.RegisterDatabaseServiceHandlerFromEndpoint(ctx, mux, grpcEndpoint, opts); err != nil {return nil, err}+ if err := v1pb.RegisterInstanceRoleServiceHandlerFromEndpoint(ctx, mux, grpcEndpoint, opts); err != nil {+ return nil, err+ }e.Any("/v1/*", echo.WrapHandler(mux))// Register open API routes@@ -491,16 +495,6 @@ func (s *Server) registerOpenAPIRoutes(e *echo.Echo, ce *casbin.Enforcer, prof c}e.POST("/v1/sql/advise", s.sqlCheckController)e.POST("/v1/sql/schema/diff", schemaDiff)- e.POST("/v1/instance", s.createInstanceByOpenAPI, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.GET("/v1/instance", s.listInstance, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.GET("/v1/instance/:instanceID", s.getInstanceByID, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.PATCH("/v1/instance/:instanceID", s.updateInstanceByOpenAPI, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.DELETE("/v1/instance/:instanceID", s.deleteInstanceByOpenAPI, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.GET("/v1/instance/:instanceID/role", s.listDatabaseRole, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.POST("/v1/instance/:instanceID/role", s.createDatabaseRole, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.GET("/v1/instance/:instanceID/role/:roleName", s.getDatabaseRole, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.PATCH("/v1/instance/:instanceID/role/:roleName", s.updateDatabaseRole, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)- e.DELETE("/v1/instance/:instanceID/role/:roleName", s.deleteDatabaseRole, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)e.PATCH("/v1/instances/:instanceName/databases/:database", s.updateInstanceDatabase, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)e.POST("/v1/issues", s.createIssueByOpenAPI, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)e.GET("/v1/environment", s.listEnvironment, jwtMiddlewareFunc, aclMiddlewareFunc, metricMiddlewareFunc)