Skip to content

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

feat: support list/get environment/instance/database policy (#4211)

ecmadao1f26c7f91260
diff --git a/api/policy.go b/api/policy.go
index 3c1917aa79..09c28b7e2e 100644
--- a/api/policy.go
+++ b/api/policy.go
@@ -452,3 +452,23 @@ func GetDefaultPolicy(pType PolicyType) (string, error) {
}
return "", nil
}
+
+// GetPolicyResourceType gets the policy resource type.
+func GetPolicyResourceType(resourceType string) (PolicyResourceType, error) {
+ var rt PolicyResourceType
+ switch resourceType {
+ case "workspace":
+ rt = PolicyResourceTypeWorkspace
+ case "environment":
+ rt = PolicyResourceTypeEnvironment
+ case "project":
+ rt = PolicyResourceTypeProject
+ case "instance":
+ rt = PolicyResourceTypeInstance
+ case "database":
+ rt = PolicyResourceTypeDatabase
+ default:
+ return PolicyResourceTypeUnknown, errors.Errorf("invalid policy resource type %q", rt)
+ }
+ return rt, nil
+}
diff --git a/frontend/src/types/proto/v1/org_policy_service.ts b/frontend/src/types/proto/v1/org_policy_service.ts
new file mode 100644
index 0000000000..84472b4b13
--- /dev/null
+++ b/frontend/src/types/proto/v1/org_policy_service.ts
@@ -0,0 +1,433 @@
+/* eslint-disable */
+import _m0 from "protobufjs/minimal";
+import { State, stateFromJSON, stateToJSON } from "./common";
+
+export const protobufPackage = "bytebase.v1";
+
+export enum PolicyType {
+ POLICY_TYPE_UNSPECIFIED = 0,
+ PIPELINE_APPROVAL = 1,
+ BACKUP_PLAN = 2,
+ SQL_REVIEW = 3,
+ SENSITIVE_DATA = 4,
+ ACCESS_CONTROL = 5,
+ UNRECOGNIZED = -1,
+}
+
+export function policyTypeFromJSON(object: any): PolicyType {
+ switch (object) {
+ case 0:
+ case "POLICY_TYPE_UNSPECIFIED":
+ return PolicyType.POLICY_TYPE_UNSPECIFIED;
+ case 1:
+ case "PIPELINE_APPROVAL":
+ return PolicyType.PIPELINE_APPROVAL;
+ case 2:
+ case "BACKUP_PLAN":
+ return PolicyType.BACKUP_PLAN;
+ case 3:
+ case "SQL_REVIEW":
+ return PolicyType.SQL_REVIEW;
+ case 4:
+ case "SENSITIVE_DATA":
+ return PolicyType.SENSITIVE_DATA;
+ case 5:
+ case "ACCESS_CONTROL":
+ return PolicyType.ACCESS_CONTROL;
+ case -1:
+ case "UNRECOGNIZED":
+ default:
+ return PolicyType.UNRECOGNIZED;
+ }
+}
+
+export function policyTypeToJSON(object: PolicyType): string {
+ switch (object) {
+ case PolicyType.POLICY_TYPE_UNSPECIFIED:
+ return "POLICY_TYPE_UNSPECIFIED";
+ case PolicyType.PIPELINE_APPROVAL:
+ return "PIPELINE_APPROVAL";
+ case PolicyType.BACKUP_PLAN:
+ return "BACKUP_PLAN";
+ case PolicyType.SQL_REVIEW:
+ return "SQL_REVIEW";
+ case PolicyType.SENSITIVE_DATA:
+ return "SENSITIVE_DATA";
+ case PolicyType.ACCESS_CONTROL:
+ return "ACCESS_CONTROL";
+ case PolicyType.UNRECOGNIZED:
+ default:
+ return "UNRECOGNIZED";
+ }
+}
+
+export interface GetPolicyRequest {
+ /**
+ * The name of the policy to retrieve.
+ * Format: {resource type}/{resource id}/policies/{policy type}
+ */
+ name: string;
+}
+
+export interface ListPoliciesRequest {
+ /**
+ * The parent, which owns this collection of policies.
+ * Format: {resource type}/{resource id}/policies/{policy type}
+ */
+ parent: string;
+ /**
+ * The maximum number of policies to return. The service may return fewer than
+ * this value.
+ * If unspecified, at most 50 policies 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 `GetPolicies` call.
+ * Provide this to retrieve the subsequent page.
+ *
+ * When paginating, all other parameters provided to `GetPolicies` must match
+ * the call that provided the page token.
+ */
+ pageToken: string;
+}
+
+export interface ListPoliciesResponse {
+ /** The policies from the specified request. */
+ policies: Policy[];
+ /**
+ * 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 Policy {
+ /**
+ * The name of the policy.
+ * Format: {resource type}/{resource id}/policies/{policy type}
+ */
+ name: string;
+ /** The system-assigned, unique identifier for a resource. */
+ uid: string;
+ state: State;
+ inheritFromParent: boolean;
+ type: PolicyType;
+ payload: string;
+}
+
+function createBaseGetPolicyRequest(): GetPolicyRequest {
+ return { name: "" };
+}
+
+export const GetPolicyRequest = {
+ encode(message: GetPolicyRequest, 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): GetPolicyRequest {
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseGetPolicyRequest();
+ 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): GetPolicyRequest {
+ return { name: isSet(object.name) ? String(object.name) : "" };
+ },
+
+ toJSON(message: GetPolicyRequest): unknown {
+ const obj: any = {};
+ message.name !== undefined && (obj.name = message.name);
+ return obj;
+ },
+
+ fromPartial<I extends Exact<DeepPartial<GetPolicyRequest>, I>>(object: I): GetPolicyRequest {
+ const message = createBaseGetPolicyRequest();
+ message.name = object.name ?? "";
+ return message;
+ },
+};
+
+function createBaseListPoliciesRequest(): ListPoliciesRequest {
+ return { parent: "", pageSize: 0, pageToken: "" };
+}
+
+export const ListPoliciesRequest = {
+ encode(message: ListPoliciesRequest, 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): ListPoliciesRequest {
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseListPoliciesRequest();
+ 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): ListPoliciesRequest {
+ 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: ListPoliciesRequest): 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<ListPoliciesRequest>, I>>(object: I): ListPoliciesRequest {
+ const message = createBaseListPoliciesRequest();
+ message.parent = object.parent ?? "";
+ message.pageSize = object.pageSize ?? 0;
+ message.pageToken = object.pageToken ?? "";
+ return message;
+ },
+};
+
+function createBaseListPoliciesResponse(): ListPoliciesResponse {
+ return { policies: [], nextPageToken: "" };
+}
+
+export const ListPoliciesResponse = {
+ encode(message: ListPoliciesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ for (const v of message.policies) {
+ Policy.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): ListPoliciesResponse {
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseListPoliciesResponse();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ message.policies.push(Policy.decode(reader, reader.uint32()));
+ break;
+ case 2:
+ message.nextPageToken = reader.string();
+ break;
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ },
+
+ fromJSON(object: any): ListPoliciesResponse {
+ return {
+ policies: Array.isArray(object?.policies) ? object.policies.map((e: any) => Policy.fromJSON(e)) : [],
+ nextPageToken: isSet(object.nextPageToken) ? String(object.nextPageToken) : "",
+ };
+ },
+
+ toJSON(message: ListPoliciesResponse): unknown {
+ const obj: any = {};
+ if (message.policies) {
+ obj.policies = message.policies.map((e) => e ? Policy.toJSON(e) : undefined);
+ } else {
+ obj.policies = [];
+ }
+ message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);
+ return obj;
+ },
+
+ fromPartial<I extends Exact<DeepPartial<ListPoliciesResponse>, I>>(object: I): ListPoliciesResponse {
+ const message = createBaseListPoliciesResponse();
+ message.policies = object.policies?.map((e) => Policy.fromPartial(e)) || [];
+ message.nextPageToken = object.nextPageToken ?? "";
+ return message;
+ },
+};
+
+function createBasePolicy(): Policy {
+ return { name: "", uid: "", state: 0, inheritFromParent: false, type: 0, payload: "" };
+}
+
+export const Policy = {
+ encode(message: Policy, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.name !== "") {
+ writer.uint32(10).string(message.name);
+ }
+ if (message.uid !== "") {
+ writer.uint32(18).string(message.uid);
+ }
+ if (message.state !== 0) {
+ writer.uint32(24).int32(message.state);
+ }
+ if (message.inheritFromParent === true) {
+ writer.uint32(32).bool(message.inheritFromParent);
+ }
+ if (message.type !== 0) {
+ writer.uint32(40).int32(message.type);
+ }
+ if (message.payload !== "") {
+ writer.uint32(50).string(message.payload);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): Policy {
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBasePolicy();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ message.name = reader.string();
+ break;
+ case 2:
+ message.uid = reader.string();
+ break;
+ case 3:
+ message.state = reader.int32() as any;
+ break;
+ case 4:
+ message.inheritFromParent = reader.bool();
+ break;
+ case 5:
+ message.type = reader.int32() as any;
+ break;
+ case 6:
+ message.payload = reader.string();
+ break;
+ default:
+ reader.skipType(tag & 7);
+ break;
+ }
+ }
+ return message;
+ },
+
+ fromJSON(object: any): Policy {
+ return {
+ name: isSet(object.name) ? String(object.name) : "",
+ uid: isSet(object.uid) ? String(object.uid) : "",
+ state: isSet(object.state) ? stateFromJSON(object.state) : 0,
+ inheritFromParent: isSet(object.inheritFromParent) ? Boolean(object.inheritFromParent) : false,
+ type: isSet(object.type) ? policyTypeFromJSON(object.type) : 0,
+ payload: isSet(object.payload) ? String(object.payload) : "",
+ };
+ },
+
+ toJSON(message: Policy): unknown {
+ const obj: any = {};
+ message.name !== undefined && (obj.name = message.name);
+ message.uid !== undefined && (obj.uid = message.uid);
+ message.state !== undefined && (obj.state = stateToJSON(message.state));
+ message.inheritFromParent !== undefined && (obj.inheritFromParent = message.inheritFromParent);
+ message.type !== undefined && (obj.type = policyTypeToJSON(message.type));
+ message.payload !== undefined && (obj.payload = message.payload);
+ return obj;
+ },
+
+ fromPartial<I extends Exact<DeepPartial<Policy>, I>>(object: I): Policy {
+ const message = createBasePolicy();
+ message.name = object.name ?? "";
+ message.uid = object.uid ?? "";
+ message.state = object.state ?? 0;
+ message.inheritFromParent = object.inheritFromParent ?? false;
+ message.type = object.type ?? 0;
+ message.payload = object.payload ?? "";
+ return message;
+ },
+};
+
+export interface OrgPolicyService {
+ GetPolicy(request: GetPolicyRequest): Promise<Policy>;
+ ListPolicies(request: ListPoliciesRequest): Promise<ListPoliciesResponse>;
+}
+
+export class OrgPolicyServiceClientImpl implements OrgPolicyService {
+ private readonly rpc: Rpc;
+ private readonly service: string;
+ constructor(rpc: Rpc, opts?: { service?: string }) {
+ this.service = opts?.service || "bytebase.v1.OrgPolicyService";
+ this.rpc = rpc;
+ this.GetPolicy = this.GetPolicy.bind(this);
+ this.ListPolicies = this.ListPolicies.bind(this);
+ }
+ GetPolicy(request: GetPolicyRequest): Promise<Policy> {
+ const data = GetPolicyRequest.encode(request).finish();
+ const promise = this.rpc.request(this.service, "GetPolicy", data);
+ return promise.then((data) => Policy.decode(new _m0.Reader(data)));
+ }
+
+ ListPolicies(request: ListPoliciesRequest): Promise<ListPoliciesResponse> {
+ const data = ListPoliciesRequest.encode(request).finish();
+ const promise = this.rpc.request(this.service, "ListPolicies", data);
+ return promise.then((data) => ListPoliciesResponse.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/proto/generated-go/v1/org_policy_service.pb.go b/proto/generated-go/v1/org_policy_service.pb.go
new file mode 100644
index 0000000000..de6eb093ad
--- /dev/null
+++ b/proto/generated-go/v1/org_policy_service.pb.go
@@ -0,0 +1,566 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.28.1
+// protoc (unknown)
+// source: v1/org_policy_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"
+ _ "google.golang.org/protobuf/types/known/emptypb"
+ _ "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 PolicyType int32
+
+const (
+ PolicyType_POLICY_TYPE_UNSPECIFIED PolicyType = 0
+ PolicyType_PIPELINE_APPROVAL PolicyType = 1
+ PolicyType_BACKUP_PLAN PolicyType = 2
+ PolicyType_SQL_REVIEW PolicyType = 3
+ PolicyType_SENSITIVE_DATA PolicyType = 4
+ PolicyType_ACCESS_CONTROL PolicyType = 5
+)
+
+// Enum value maps for PolicyType.
+var (
+ PolicyType_name = map[int32]string{
+ 0: "POLICY_TYPE_UNSPECIFIED",
+ 1: "PIPELINE_APPROVAL",
+ 2: "BACKUP_PLAN",
+ 3: "SQL_REVIEW",
+ 4: "SENSITIVE_DATA",
+ 5: "ACCESS_CONTROL",
+ }
+ PolicyType_value = map[string]int32{
+ "POLICY_TYPE_UNSPECIFIED": 0,
+ "PIPELINE_APPROVAL": 1,
+ "BACKUP_PLAN": 2,
+ "SQL_REVIEW": 3,
+ "SENSITIVE_DATA": 4,
+ "ACCESS_CONTROL": 5,
+ }
+)
+
+func (x PolicyType) Enum() *PolicyType {
+ p := new(PolicyType)
+ *p = x
+ return p
+}
+
+func (x PolicyType) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (PolicyType) Descriptor() protoreflect.EnumDescriptor {
+ return file_v1_org_policy_service_proto_enumTypes[0].Descriptor()
+}
+
+func (PolicyType) Type() protoreflect.EnumType {
+ return &file_v1_org_policy_service_proto_enumTypes[0]
+}
+
+func (x PolicyType) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use PolicyType.Descriptor instead.
+func (PolicyType) EnumDescriptor() ([]byte, []int) {
+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{0}
+}
+
+type GetPolicyRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // The name of the policy to retrieve.
+ // Format: {resource type}/{resource id}/policies/{policy type}
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (x *GetPolicyRequest) Reset() {
+ *x = GetPolicyRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_org_policy_service_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *GetPolicyRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetPolicyRequest) ProtoMessage() {}
+
+func (x *GetPolicyRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_org_policy_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 GetPolicyRequest.ProtoReflect.Descriptor instead.
+func (*GetPolicyRequest) Descriptor() ([]byte, []int) {
+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *GetPolicyRequest) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
+type ListPoliciesRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // The parent, which owns this collection of policies.
+ // Format: {resource type}/{resource id}/policies/{policy type}
+ Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`
+ // The maximum number of policies to return. The service may return fewer than
+ // this value.
+ // If unspecified, at most 50 policies 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 `GetPolicies` call.
+ // Provide this to retrieve the subsequent page.
+ //
+ // When paginating, all other parameters provided to `GetPolicies` 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 *ListPoliciesRequest) Reset() {
+ *x = ListPoliciesRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_org_policy_service_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *ListPoliciesRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ListPoliciesRequest) ProtoMessage() {}
+
+func (x *ListPoliciesRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_org_policy_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 ListPoliciesRequest.ProtoReflect.Descriptor instead.
+func (*ListPoliciesRequest) Descriptor() ([]byte, []int) {
+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *ListPoliciesRequest) GetParent() string {
+ if x != nil {
+ return x.Parent
+ }
+ return ""
+}
+
+func (x *ListPoliciesRequest) GetPageSize() int32 {
+ if x != nil {
+ return x.PageSize
+ }
+ return 0
+}
+
+func (x *ListPoliciesRequest) GetPageToken() string {
+ if x != nil {
+ return x.PageToken
+ }
+ return ""
+}
+
+type ListPoliciesResponse struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // The policies from the specified request.
+ Policies []*Policy `protobuf:"bytes,1,rep,name=policies,proto3" json:"policies,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 *ListPoliciesResponse) Reset() {
+ *x = ListPoliciesResponse{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_org_policy_service_proto_msgTypes[2]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *ListPoliciesResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ListPoliciesResponse) ProtoMessage() {}
+
+func (x *ListPoliciesResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_org_policy_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 ListPoliciesResponse.ProtoReflect.Descriptor instead.
+func (*ListPoliciesResponse) Descriptor() ([]byte, []int) {
+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *ListPoliciesResponse) GetPolicies() []*Policy {
+ if x != nil {
+ return x.Policies
+ }
+ return nil
+}
+
+func (x *ListPoliciesResponse) GetNextPageToken() string {
+ if x != nil {
+ return x.NextPageToken
+ }
+ return ""
+}
+
+type Policy struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // The name of the policy.
+ // Format: {resource type}/{resource id}/policies/{policy type}
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ // The system-assigned, unique identifier for a resource.
+ Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid,omitempty"`
+ State State `protobuf:"varint,3,opt,name=state,proto3,enum=bytebase.v1.State" json:"state,omitempty"`
+ InheritFromParent bool `protobuf:"varint,4,opt,name=inherit_from_parent,json=inheritFromParent,proto3" json:"inherit_from_parent,omitempty"`
+ Type PolicyType `protobuf:"varint,5,opt,name=type,proto3,enum=bytebase.v1.PolicyType" json:"type,omitempty"`
+ Payload string `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"`
+}
+
+func (x *Policy) Reset() {
+ *x = Policy{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_v1_org_policy_service_proto_msgTypes[3]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *Policy) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Policy) ProtoMessage() {}
+
+func (x *Policy) ProtoReflect() protoreflect.Message {
+ mi := &file_v1_org_policy_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 Policy.ProtoReflect.Descriptor instead.
+func (*Policy) Descriptor() ([]byte, []int) {
+ return file_v1_org_policy_service_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *Policy) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
+func (x *Policy) GetUid() string {
+ if x != nil {
+ return x.Uid
+ }
+ return ""
+}
+
+func (x *Policy) GetState() State {
+ if x != nil {
+ return x.State
+ }
+ return State_STATE_UNSPECIFIED
+}
+
+func (x *Policy) GetInheritFromParent() bool {
+ if x != nil {
+ return x.InheritFromParent
+ }
+ return false
+}
+
+func (x *Policy) GetType() PolicyType {
+ if x != nil {
+ return x.Type
+ }
+ return PolicyType_POLICY_TYPE_UNSPECIFIED
+}
+
+func (x *Policy) GetPayload() string {
+ if x != nil {
+ return x.Payload
+ }
+ return ""
+}
+
+var File_v1_org_policy_service_proto protoreflect.FileDescriptor
+
+var file_v1_org_policy_service_proto_rawDesc = []byte{
+ 0x0a, 0x1b, 0x76, 0x31, 0x2f, 0x6f, 0x72, 0x67, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 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, 0x2c, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 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, 0x6f, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 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, 0x6f, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65,
+ 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x08, 0x70, 0x6f, 0x6c,
+ 0x69, 0x63, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x62, 0x79,
+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79,
+ 0x52, 0x08, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 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, 0xd5, 0x01, 0x0a, 0x06, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x12, 0x0a,
+ 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
+ 0x65, 0x12, 0x16, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04,
+ 0xe2, 0x41, 0x01, 0x03, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x05, 0x73, 0x74, 0x61,
+ 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74,
+ 0x61, 0x74, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x5f, 0x66,
+ 0x72, 0x6f, 0x6d, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08,
+ 0x52, 0x11, 0x69, 0x6e, 0x68, 0x65, 0x72, 0x69, 0x74, 0x46, 0x72, 0x6f, 0x6d, 0x50, 0x61, 0x72,
+ 0x65, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28,
+ 0x0e, 0x32, 0x17, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e,
+ 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
+ 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28,
+ 0x09, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0x89, 0x01, 0x0a, 0x0a, 0x50,
+ 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x17, 0x50, 0x4f, 0x4c,
+ 0x49, 0x43, 0x59, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49,
+ 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x50, 0x49, 0x50, 0x45, 0x4c, 0x49,
+ 0x4e, 0x45, 0x5f, 0x41, 0x50, 0x50, 0x52, 0x4f, 0x56, 0x41, 0x4c, 0x10, 0x01, 0x12, 0x0f, 0x0a,
+ 0x0b, 0x42, 0x41, 0x43, 0x4b, 0x55, 0x50, 0x5f, 0x50, 0x4c, 0x41, 0x4e, 0x10, 0x02, 0x12, 0x0e,
+ 0x0a, 0x0a, 0x53, 0x51, 0x4c, 0x5f, 0x52, 0x45, 0x56, 0x49, 0x45, 0x57, 0x10, 0x03, 0x12, 0x12,
+ 0x0a, 0x0e, 0x53, 0x45, 0x4e, 0x53, 0x49, 0x54, 0x49, 0x56, 0x45, 0x5f, 0x44, 0x41, 0x54, 0x41,
+ 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x43, 0x4f, 0x4e,
+ 0x54, 0x52, 0x4f, 0x4c, 0x10, 0x05, 0x32, 0xed, 0x04, 0x0a, 0x10, 0x4f, 0x72, 0x67, 0x50, 0x6f,
+ 0x6c, 0x69, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa7, 0x02, 0x0a, 0x09,
+ 0x47, 0x65, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65,
+ 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63,
+ 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0xe5, 0x01,
+ 0xda, 0x41, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0xd7, 0x01, 0x5a, 0x22,
+ 0x12, 0x20, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x70, 0x72, 0x6f, 0x6a,
+ 0x65, 0x63, 0x74, 0x73, 0x2f, 0x2a, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x2f,
+ 0x2a, 0x7d, 0x5a, 0x26, 0x12, 0x24, 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, 0x70,
+ 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x5a, 0x32, 0x12, 0x30, 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, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x5a, 0x3e,
+ 0x12, 0x3c, 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, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73,
+ 0x2f, 0x2a, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0x15,
+ 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69,
+ 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0xae, 0x02, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f,
+ 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
+ 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65,
+ 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,
+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63,
+ 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xd8, 0x01, 0xda, 0x41,
+ 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0xce, 0x01, 0x5a, 0x22, 0x12, 0x20, 0x2f, 0x76, 0x31, 0x2f,
+ 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x73,
+ 0x2f, 0x2a, 0x7d, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x5a, 0x26, 0x12, 0x24,
+ 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, 0x7d, 0x2f, 0x70, 0x6f, 0x6c, 0x69,
+ 0x63, 0x69, 0x65, 0x73, 0x5a, 0x32, 0x12, 0x30, 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,
+ 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x5a, 0x3e, 0x12, 0x3c, 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, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x2a, 0x7d, 0x2f,
+ 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x0c, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x6f,
+ 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 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_org_policy_service_proto_rawDescOnce sync.Once
+ file_v1_org_policy_service_proto_rawDescData = file_v1_org_policy_service_proto_rawDesc
+)
+
+func file_v1_org_policy_service_proto_rawDescGZIP() []byte {
+ file_v1_org_policy_service_proto_rawDescOnce.Do(func() {
+ file_v1_org_policy_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_org_policy_service_proto_rawDescData)
+ })
+ return file_v1_org_policy_service_proto_rawDescData
+}
+
+var file_v1_org_policy_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
+var file_v1_org_policy_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
+var file_v1_org_policy_service_proto_goTypes = []interface{}{
+ (PolicyType)(0), // 0: bytebase.v1.PolicyType
+ (*GetPolicyRequest)(nil), // 1: bytebase.v1.GetPolicyRequest
+ (*ListPoliciesRequest)(nil), // 2: bytebase.v1.ListPoliciesRequest
+ (*ListPoliciesResponse)(nil), // 3: bytebase.v1.ListPoliciesResponse
+ (*Policy)(nil), // 4: bytebase.v1.Policy
+ (State)(0), // 5: bytebase.v1.State
+}
+var file_v1_org_policy_service_proto_depIdxs = []int32{
+ 4, // 0: bytebase.v1.ListPoliciesResponse.policies:type_name -> bytebase.v1.Policy
+ 5, // 1: bytebase.v1.Policy.state:type_name -> bytebase.v1.State
+ 0, // 2: bytebase.v1.Policy.type:type_name -> bytebase.v1.PolicyType
+ 1, // 3: bytebase.v1.OrgPolicyService.GetPolicy:input_type -> bytebase.v1.GetPolicyRequest
+ 2, // 4: bytebase.v1.OrgPolicyService.ListPolicies:input_type -> bytebase.v1.ListPoliciesRequest
+ 4, // 5: bytebase.v1.OrgPolicyService.GetPolicy:output_type -> bytebase.v1.Policy
+ 3, // 6: bytebase.v1.OrgPolicyService.ListPolicies:output_type -> bytebase.v1.ListPoliciesResponse
+ 5, // [5:7] is the sub-list for method output_type
+ 3, // [3:5] 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_org_policy_service_proto_init() }
+func file_v1_org_policy_service_proto_init() {
+ if File_v1_org_policy_service_proto != nil {
+ return
+ }
+ file_v1_common_proto_init()
+ if !protoimpl.UnsafeEnabled {
+ file_v1_org_policy_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*GetPolicyRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_v1_org_policy_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*ListPoliciesRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_v1_org_policy_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*ListPoliciesResponse); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_v1_org_policy_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*Policy); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_v1_org_policy_service_proto_rawDesc,
+ NumEnums: 1,
+ NumMessages: 4,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes: file_v1_org_policy_service_proto_goTypes,
+ DependencyIndexes: file_v1_org_policy_service_proto_depIdxs,
+ EnumInfos: file_v1_org_policy_service_proto_enumTypes,
+ MessageInfos: file_v1_org_policy_service_proto_msgTypes,
+ }.Build()
+ File_v1_org_policy_service_proto = out.File
+ file_v1_org_policy_service_proto_rawDesc = nil
+ file_v1_org_policy_service_proto_goTypes = nil
+ file_v1_org_policy_service_proto_depIdxs = nil
+}
diff --git a/proto/generated-go/v1/org_policy_service.pb.gw.go b/proto/generated-go/v1/org_policy_service.pb.gw.go
new file mode 100644
index 0000000000..16d4d7ecfc
--- /dev/null
+++ b/proto/generated-go/v1/org_policy_service.pb.gw.go
@@ -0,0 +1,1172 @@
+// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
+// source: v1/org_policy_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_OrgPolicyService_GetPolicy_0(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_GetPolicy_0(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+func request_OrgPolicyService_GetPolicy_1(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_GetPolicy_1(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+func request_OrgPolicyService_GetPolicy_2(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_GetPolicy_2(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+func request_OrgPolicyService_GetPolicy_3(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_GetPolicy_3(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+func request_OrgPolicyService_GetPolicy_4(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_GetPolicy_4(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetPolicyRequest
+ 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.GetPolicy(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+var (
+ filter_OrgPolicyService_ListPolicies_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
+)
+
+func request_OrgPolicyService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ var metadata runtime.ServerMetadata
+
+ if err := req.ParseForm(); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrgPolicyService_ListPolicies_0); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.ListPolicies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ var metadata runtime.ServerMetadata
+
+ if err := req.ParseForm(); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OrgPolicyService_ListPolicies_0); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.ListPolicies(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+var (
+ filter_OrgPolicyService_ListPolicies_1 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}}
+)
+
+func request_OrgPolicyService_ListPolicies_1(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ 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_OrgPolicyService_ListPolicies_1); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.ListPolicies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_ListPolicies_1(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ 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_OrgPolicyService_ListPolicies_1); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.ListPolicies(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+var (
+ filter_OrgPolicyService_ListPolicies_2 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}}
+)
+
+func request_OrgPolicyService_ListPolicies_2(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ 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_OrgPolicyService_ListPolicies_2); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.ListPolicies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_ListPolicies_2(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ 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_OrgPolicyService_ListPolicies_2); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.ListPolicies(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+var (
+ filter_OrgPolicyService_ListPolicies_3 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}}
+)
+
+func request_OrgPolicyService_ListPolicies_3(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ 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_OrgPolicyService_ListPolicies_3); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.ListPolicies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_ListPolicies_3(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ 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_OrgPolicyService_ListPolicies_3); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.ListPolicies(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+var (
+ filter_OrgPolicyService_ListPolicies_4 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 2, 0, 0}, Check: []int{0, 1, 2, 2}}
+)
+
+func request_OrgPolicyService_ListPolicies_4(ctx context.Context, marshaler runtime.Marshaler, client OrgPolicyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ 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_OrgPolicyService_ListPolicies_4); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := client.ListPolicies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_OrgPolicyService_ListPolicies_4(ctx context.Context, marshaler runtime.Marshaler, server OrgPolicyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq ListPoliciesRequest
+ 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_OrgPolicyService_ListPolicies_4); err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
+ }
+
+ msg, err := server.ListPolicies(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
+// RegisterOrgPolicyServiceHandlerServer registers the http handlers for service OrgPolicyService to "mux".
+// UnaryRPC :call OrgPolicyServiceServer 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 RegisterOrgPolicyServiceHandlerFromEndpoint instead.
+func RegisterOrgPolicyServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server OrgPolicyServiceServer) error {
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_GetPolicy_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_OrgPolicyService_GetPolicy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_1, 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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=projects/*/policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_GetPolicy_1(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_OrgPolicyService_GetPolicy_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_2, 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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=environments/*/policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_GetPolicy_2(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_OrgPolicyService_GetPolicy_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_3, 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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_GetPolicy_3(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_OrgPolicyService_GetPolicy_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_4, 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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/databases/*/policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_GetPolicy_4(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_OrgPolicyService_GetPolicy_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_ListPolicies_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_OrgPolicyService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_1, 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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/{parent=projects/*}/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_ListPolicies_1(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_OrgPolicyService_ListPolicies_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_2, 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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/{parent=environments/*}/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_ListPolicies_2(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_OrgPolicyService_ListPolicies_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_3, 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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/{parent=environments/*/instances/*}/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_ListPolicies_3(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_OrgPolicyService_ListPolicies_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_4, 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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/{parent=environments/*/instances/*/databases/*}/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_OrgPolicyService_ListPolicies_4(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_OrgPolicyService_ListPolicies_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+// RegisterOrgPolicyServiceHandlerFromEndpoint is same as RegisterOrgPolicyServiceHandler but
+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
+func RegisterOrgPolicyServiceHandlerFromEndpoint(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 RegisterOrgPolicyServiceHandler(ctx, mux, conn)
+}
+
+// RegisterOrgPolicyServiceHandler registers the http handlers for service OrgPolicyService to "mux".
+// The handlers forward requests to the grpc endpoint over "conn".
+func RegisterOrgPolicyServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
+ return RegisterOrgPolicyServiceHandlerClient(ctx, mux, NewOrgPolicyServiceClient(conn))
+}
+
+// RegisterOrgPolicyServiceHandlerClient registers the http handlers for service OrgPolicyService
+// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "OrgPolicyServiceClient".
+// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "OrgPolicyServiceClient"
+// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
+// "OrgPolicyServiceClient" to call the correct interceptors.
+func RegisterOrgPolicyServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client OrgPolicyServiceClient) error {
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_GetPolicy_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_GetPolicy_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_1, 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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=projects/*/policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_GetPolicy_1(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_GetPolicy_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_2, 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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=environments/*/policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_GetPolicy_2(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_GetPolicy_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_3, 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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_GetPolicy_3(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_GetPolicy_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_GetPolicy_4, 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.OrgPolicyService/GetPolicy", runtime.WithHTTPPathPattern("/v1/{name=environments/*/instances/*/databases/*/policies/*}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_GetPolicy_4(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_GetPolicy_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_ListPolicies_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_1, 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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/{parent=projects/*}/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_ListPolicies_1(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_ListPolicies_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_2, 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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/{parent=environments/*}/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_ListPolicies_2(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_ListPolicies_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_3, 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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/{parent=environments/*/instances/*}/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_ListPolicies_3(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_ListPolicies_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ mux.Handle("GET", pattern_OrgPolicyService_ListPolicies_4, 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.OrgPolicyService/ListPolicies", runtime.WithHTTPPathPattern("/v1/{parent=environments/*/instances/*/databases/*}/policies"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_OrgPolicyService_ListPolicies_4(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_OrgPolicyService_ListPolicies_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
+ return nil
+}
+
+var (
+ pattern_OrgPolicyService_GetPolicy_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "policies", "name"}, ""))
+
+ pattern_OrgPolicyService_GetPolicy_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 4, 5, 3}, []string{"v1", "projects", "policies", "name"}, ""))
+
+ pattern_OrgPolicyService_GetPolicy_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 4, 5, 3}, []string{"v1", "environments", "policies", "name"}, ""))
+
+ pattern_OrgPolicyService_GetPolicy_3 = 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", "policies", "name"}, ""))
+
+ pattern_OrgPolicyService_GetPolicy_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 4, 8, 5, 5}, []string{"v1", "environments", "instances", "databases", "policies", "name"}, ""))
+
+ pattern_OrgPolicyService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "policies"}, ""))
+
+ pattern_OrgPolicyService_ListPolicies_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2, 2, 3}, []string{"v1", "projects", "parent", "policies"}, ""))
+
+ pattern_OrgPolicyService_ListPolicies_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2, 2, 3}, []string{"v1", "environments", "parent", "policies"}, ""))
+
+ pattern_OrgPolicyService_ListPolicies_3 = 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", "policies"}, ""))
+
+ pattern_OrgPolicyService_ListPolicies_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 4, 6, 5, 4, 2, 5}, []string{"v1", "environments", "instances", "databases", "parent", "policies"}, ""))
+)
+
+var (
+ forward_OrgPolicyService_GetPolicy_0 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_GetPolicy_1 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_GetPolicy_2 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_GetPolicy_3 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_GetPolicy_4 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_ListPolicies_0 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_ListPolicies_1 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_ListPolicies_2 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_ListPolicies_3 = runtime.ForwardResponseMessage
+
+ forward_OrgPolicyService_ListPolicies_4 = runtime.ForwardResponseMessage
+)
diff --git a/proto/generated-go/v1/org_policy_service_grpc.pb.go b/proto/generated-go/v1/org_policy_service_grpc.pb.go
new file mode 100644
index 0000000000..8fba5010b9
--- /dev/null
+++ b/proto/generated-go/v1/org_policy_service_grpc.pb.go
@@ -0,0 +1,141 @@
+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
+// versions:
+// - protoc-gen-go-grpc v1.2.0
+// - protoc (unknown)
+// source: v1/org_policy_service.proto
+
+package v1
+
+import (
+ context "context"
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+)
+
+// 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
+
+// OrgPolicyServiceClient is the client API for OrgPolicyService 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 OrgPolicyServiceClient interface {
+ GetPolicy(ctx context.Context, in *GetPolicyRequest, opts ...grpc.CallOption) (*Policy, error)
+ ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error)
+}
+
+type orgPolicyServiceClient struct {
+ cc grpc.ClientConnInterface
+}
+
+func NewOrgPolicyServiceClient(cc grpc.ClientConnInterface) OrgPolicyServiceClient {
+ return &orgPolicyServiceClient{cc}
+}
+
+func (c *orgPolicyServiceClient) GetPolicy(ctx context.Context, in *GetPolicyRequest, opts ...grpc.CallOption) (*Policy, error) {
+ out := new(Policy)
+ err := c.cc.Invoke(ctx, "/bytebase.v1.OrgPolicyService/GetPolicy", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *orgPolicyServiceClient) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error) {
+ out := new(ListPoliciesResponse)
+ err := c.cc.Invoke(ctx, "/bytebase.v1.OrgPolicyService/ListPolicies", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// OrgPolicyServiceServer is the server API for OrgPolicyService service.
+// All implementations must embed UnimplementedOrgPolicyServiceServer
+// for forward compatibility
+type OrgPolicyServiceServer interface {
+ GetPolicy(context.Context, *GetPolicyRequest) (*Policy, error)
+ ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error)
+ mustEmbedUnimplementedOrgPolicyServiceServer()
+}
+
+// UnimplementedOrgPolicyServiceServer must be embedded to have forward compatible implementations.
+type UnimplementedOrgPolicyServiceServer struct {
+}
+
+func (UnimplementedOrgPolicyServiceServer) GetPolicy(context.Context, *GetPolicyRequest) (*Policy, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method GetPolicy not implemented")
+}
+func (UnimplementedOrgPolicyServiceServer) ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method ListPolicies not implemented")
+}
+func (UnimplementedOrgPolicyServiceServer) mustEmbedUnimplementedOrgPolicyServiceServer() {}
+
+// UnsafeOrgPolicyServiceServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to OrgPolicyServiceServer will
+// result in compilation errors.
+type UnsafeOrgPolicyServiceServer interface {
+ mustEmbedUnimplementedOrgPolicyServiceServer()
+}
+
+func RegisterOrgPolicyServiceServer(s grpc.ServiceRegistrar, srv OrgPolicyServiceServer) {
+ s.RegisterService(&OrgPolicyService_ServiceDesc, srv)
+}
+
+func _OrgPolicyService_GetPolicy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(GetPolicyRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(OrgPolicyServiceServer).GetPolicy(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/bytebase.v1.OrgPolicyService/GetPolicy",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(OrgPolicyServiceServer).GetPolicy(ctx, req.(*GetPolicyRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _OrgPolicyService_ListPolicies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ListPoliciesRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(OrgPolicyServiceServer).ListPolicies(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/bytebase.v1.OrgPolicyService/ListPolicies",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(OrgPolicyServiceServer).ListPolicies(ctx, req.(*ListPoliciesRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+// OrgPolicyService_ServiceDesc is the grpc.ServiceDesc for OrgPolicyService service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var OrgPolicyService_ServiceDesc = grpc.ServiceDesc{
+ ServiceName: "bytebase.v1.OrgPolicyService",
+ HandlerType: (*OrgPolicyServiceServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "GetPolicy",
+ Handler: _OrgPolicyService_GetPolicy_Handler,
+ },
+ {
+ MethodName: "ListPolicies",
+ Handler: _OrgPolicyService_ListPolicies_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "v1/org_policy_service.proto",
+}
diff --git a/proto/v1/org_policy_service.proto b/proto/v1/org_policy_service.proto
new file mode 100644
index 0000000000..6d8b5ada64
--- /dev/null
+++ b/proto/v1/org_policy_service.proto
@@ -0,0 +1,115 @@
+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 OrgPolicyService {
+ rpc GetPolicy(GetPolicyRequest) returns (Policy) {
+ option (google.api.http) = {
+ get: "/v1/{name=policies/*}"
+
+ additional_bindings {
+ get: "/v1/{name=projects/*/policies/*}"
+ }
+ additional_bindings {
+ get: "/v1/{name=environments/*/policies/*}"
+ }
+ additional_bindings {
+ get: "/v1/{name=environments/*/instances/*/policies/*}"
+ }
+ additional_bindings {
+ get: "/v1/{name=environments/*/instances/*/databases/*/policies/*}"
+ }
+ };
+ option (google.api.method_signature) = "name";
+ }
+
+ rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) {
+ option (google.api.http) = {
+ get: "/v1/policies"
+
+ additional_bindings {
+ get: "/v1/{parent=projects/*}/policies"
+ }
+ additional_bindings {
+ get: "/v1/{parent=environments/*}/policies"
+ }
+ additional_bindings {
+ get: "/v1/{parent=environments/*/instances/*}/policies"
+ }
+ additional_bindings {
+ get: "/v1/{parent=environments/*/instances/*/databases/*}/policies"
+ }
+ };
+ option (google.api.method_signature) = "";
+ }
+}
+
+message GetPolicyRequest {
+ // The name of the policy to retrieve.
+ // Format: {resource type}/{resource id}/policies/{policy type}
+ string name = 1 [(google.api.field_behavior) = REQUIRED];
+}
+
+message ListPoliciesRequest {
+ // The parent, which owns this collection of policies.
+ // Format: {resource type}/{resource id}/policies/{policy type}
+ string parent = 1 [(google.api.field_behavior) = REQUIRED];
+
+ // The maximum number of policies to return. The service may return fewer than
+ // this value.
+ // If unspecified, at most 50 policies 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 `GetPolicies` call.
+ // Provide this to retrieve the subsequent page.
+ //
+ // When paginating, all other parameters provided to `GetPolicies` must match
+ // the call that provided the page token.
+ string page_token = 3;
+}
+
+message ListPoliciesResponse {
+ // The policies from the specified request.
+ repeated Policy policies = 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 Policy {
+ // The name of the policy.
+ // Format: {resource type}/{resource id}/policies/{policy type}
+ string name = 1;
+
+ // The system-assigned, unique identifier for a resource.
+ string uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
+
+ State state = 3;
+
+ bool inherit_from_parent = 4;
+
+ PolicyType type = 5;
+
+ string payload = 6;
+}
+
+enum PolicyType {
+ POLICY_TYPE_UNSPECIFIED = 0;
+ PIPELINE_APPROVAL = 1;
+ BACKUP_PLAN = 2;
+ SQL_REVIEW = 3;
+ SENSITIVE_DATA = 4;
+ ACCESS_CONTROL = 5;
+}
diff --git a/server/api/v1/common.go b/server/api/v1/common.go
index 31f4dd3fca..0f463a4289 100644
--- a/server/api/v1/common.go
+++ b/server/api/v1/common.go
@@ -16,6 +16,7 @@ const (
projectNamePrefix = "projects/"
environmentNamePrefix = "environments/"
instanceNamePrefix = "instances/"
+ policyNamePrefix = "policies/"
databaseIDPrefix = "databases/"
instanceRolePrefix = "roles/"
userNamePrefix = "users/"
diff --git a/server/api/v1/org_policy_service.go b/server/api/v1/org_policy_service.go
new file mode 100644
index 0000000000..bbf192104c
--- /dev/null
+++ b/server/api/v1/org_policy_service.go
@@ -0,0 +1,235 @@
+package v1
+
+import (
+ "context"
+ "fmt"
+ "strings"
+
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
+
+ "github.com/pkg/errors"
+
+ "github.com/bytebase/bytebase/api"
+ enterpriseAPI "github.com/bytebase/bytebase/enterprise/api"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
+ "github.com/bytebase/bytebase/store"
+)
+
+// OrgPolicyService implements the workspace policy service.
+type OrgPolicyService struct {
+ v1pb.UnimplementedOrgPolicyServiceServer
+ store *store.Store
+ licenseService enterpriseAPI.LicenseService
+}
+
+// NewOrgPolicyService creates a new OrgPolicyService.
+func NewOrgPolicyService(store *store.Store, licenseService enterpriseAPI.LicenseService) *OrgPolicyService {
+ return &OrgPolicyService{
+ store: store,
+ licenseService: licenseService,
+ }
+}
+
+// GetPolicy gets a policy in a specific resource.
+func (s *OrgPolicyService) GetPolicy(ctx context.Context, request *v1pb.GetPolicyRequest) (*v1pb.Policy, error) {
+ tokens := strings.Split(request.Name, policyNamePrefix)
+ if len(tokens) != 2 {
+ return nil, status.Errorf(codes.InvalidArgument, "invalid request %s", request.Name)
+ }
+
+ token := tokens[0]
+ if strings.HasSuffix(token, "/") {
+ token = token[:(len(token) - 1)]
+ }
+ resourceType, resourceID, err := s.getPolicyResourceTypeAndID(ctx, token)
+ if err != nil {
+ return nil, err
+ }
+
+ policyType, err := convertPolicyType(tokens[1])
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+
+ policy, err := s.store.GetPolicyV2(ctx, &store.FindPolicyMessage{
+ ResourceType: &resourceType,
+ Type: &policyType,
+ ResourceUID: &resourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+ if policy == nil {
+ return nil, status.Errorf(codes.NotFound, "policy %q not found", request.Name)
+ }
+
+ return convertToPolicy(token, policy), nil
+}
+
+// ListPolicies lists policies in a specific resource.
+func (s *OrgPolicyService) ListPolicies(ctx context.Context, request *v1pb.ListPoliciesRequest) (*v1pb.ListPoliciesResponse, error) {
+ resourceType, resourceID, err := s.getPolicyResourceTypeAndID(ctx, request.Parent)
+ if err != nil {
+ return nil, err
+ }
+
+ policies, err := s.store.ListPoliciesV2(ctx, &store.FindPolicyMessage{
+ ResourceType: &resourceType,
+ ResourceUID: &resourceID,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, err.Error())
+ }
+
+ response := &v1pb.ListPoliciesResponse{}
+ for _, policy := range policies {
+ response.Policies = append(response.Policies, convertToPolicy(request.Parent, policy))
+ }
+ return response, nil
+}
+
+func (s *OrgPolicyService) getPolicyResourceTypeAndID(ctx context.Context, requestName string) (api.PolicyResourceType, int, error) {
+ if requestName == "" {
+ return api.PolicyResourceTypeWorkspace, 0, nil
+ }
+
+ if strings.HasPrefix(requestName, projectNamePrefix) {
+ projectID, err := getProjectID(requestName)
+ if err != nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{
+ ResourceID: &projectID,
+ ShowDeleted: true,
+ })
+ if err != nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.Internal, err.Error())
+ }
+ if project == nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.NotFound, "project %q not found", projectID)
+ }
+ if project.Deleted {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.InvalidArgument, "project %q has been deleted", projectID)
+ }
+
+ return api.PolicyResourceTypeProject, project.UID, nil
+ }
+
+ if strings.HasPrefix(requestName, environmentNamePrefix) {
+ sections := strings.Split(requestName, "/")
+
+ // environment policy request name should be environments/{environment id}
+ if len(sections) == 2 {
+ environmentID, err := getEnvironmentID(requestName)
+ if err != nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ environment, err := s.store.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{
+ ResourceID: &environmentID,
+ })
+ if err != nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.Internal, err.Error())
+ }
+ if environment == nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.NotFound, "environment %q not found", environmentID)
+ }
+ if environment.Deleted {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.InvalidArgument, "environment %q has been deleted", environmentID)
+ }
+
+ return api.PolicyResourceTypeEnvironment, environment.UID, nil
+ }
+
+ // instance policy request name should be environments/{environment id}/instances/{instance id}
+ if len(sections) == 4 {
+ environmentID, instanceID, err := getEnvironmentInstanceID(requestName)
+ if err != nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+
+ instance, err := s.store.GetInstanceV2(ctx, &store.FindInstanceMessage{
+ EnvironmentID: &environmentID,
+ ResourceID: &instanceID,
+ ShowDeleted: true,
+ })
+ if err != nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.Internal, err.Error())
+ }
+ if instance == nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.NotFound, "instance %q not found", instanceID)
+ }
+ if instance.Deleted {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.InvalidArgument, "instance %q has been deleted", instanceID)
+ }
+
+ return api.PolicyResourceTypeInstance, instance.UID, nil
+ }
+
+ // database policy request name should be environments/{environment id}/instances/{instance id}/databases/{db name}
+ if len(sections) == 6 {
+ environmentID, instanceID, databaseName, err := getEnvironmentInstanceDatabaseID(requestName)
+ if err != nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ database, err := s.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{
+ EnvironmentID: &environmentID,
+ InstanceID: &instanceID,
+ DatabaseName: &databaseName,
+ })
+ if err != nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.Internal, err.Error())
+ }
+ if database == nil {
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.NotFound, "database %q not found", databaseName)
+ }
+
+ return api.PolicyResourceTypeDatabase, database.UID, nil
+ }
+ }
+
+ return api.PolicyResourceTypeUnknown, 0, status.Errorf(codes.InvalidArgument, "unknown request name %s", requestName)
+}
+
+func convertToPolicy(prefix string, policyMessage *store.PolicyMessage) *v1pb.Policy {
+ pType := v1pb.PolicyType_POLICY_TYPE_UNSPECIFIED
+ switch policyMessage.Type {
+ case api.PolicyTypePipelineApproval:
+ pType = v1pb.PolicyType_PIPELINE_APPROVAL
+ case api.PolicyTypeBackupPlan:
+ pType = v1pb.PolicyType_BACKUP_PLAN
+ case api.PolicyTypeSQLReview:
+ pType = v1pb.PolicyType_SQL_REVIEW
+ case api.PolicyTypeSensitiveData:
+ pType = v1pb.PolicyType_SENSITIVE_DATA
+ case api.PolicyTypeAccessControl:
+ pType = v1pb.PolicyType_ACCESS_CONTROL
+ }
+
+ return &v1pb.Policy{
+ Name: fmt.Sprintf("%s/%s%s", prefix, policyNamePrefix, strings.ToLower(pType.String())),
+ Uid: fmt.Sprintf("%d", policyMessage.UID),
+ State: convertDeletedToState(policyMessage.Deleted),
+ InheritFromParent: policyMessage.InheritFromParent,
+ Type: pType,
+ Payload: policyMessage.Payload,
+ }
+}
+
+func convertPolicyType(pType string) (api.PolicyType, error) {
+ var policyType api.PolicyType
+ switch strings.ToUpper(pType) {
+ case v1pb.PolicyType_PIPELINE_APPROVAL.String():
+ return api.PolicyTypePipelineApproval, nil
+ case v1pb.PolicyType_BACKUP_PLAN.String():
+ return api.PolicyTypeBackupPlan, nil
+ case v1pb.PolicyType_SQL_REVIEW.String():
+ return api.PolicyTypeSQLReview, nil
+ case v1pb.PolicyType_SENSITIVE_DATA.String():
+ return api.PolicyTypeSensitiveData, nil
+ case v1pb.PolicyType_ACCESS_CONTROL.String():
+ return api.PolicyTypeAccessControl, nil
+ }
+ return policyType, errors.Errorf("invalid policy type %v", pType)
+}
diff --git a/server/policy.go b/server/policy.go
index c0473cf45e..2333322c19 100644
--- a/server/policy.go
+++ b/server/policy.go
@@ -55,7 +55,7 @@ func (s *Server) hasAccessToUpsertPolicy(policyUpsert *api.PolicyUpsert) error {
func (s *Server) registerPolicyRoutes(g *echo.Group) {
g.PATCH("/policy/:resourceType/:resourceID", func(c echo.Context) error {
ctx := c.Request().Context()
- resourceType, err := getPolicyResourceType(c.Param("resourceType"))
+ resourceType, err := api.GetPolicyResourceType(c.Param("resourceType"))
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
@@ -103,7 +103,7 @@ func (s *Server) registerPolicyRoutes(g *echo.Group) {
g.DELETE("/policy/:resourceType/:resourceID", func(c echo.Context) error {
ctx := c.Request().Context()
- resourceType, err := getPolicyResourceType(c.Param("resourceType"))
+ resourceType, err := api.GetPolicyResourceType(c.Param("resourceType"))
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
@@ -135,7 +135,7 @@ func (s *Server) registerPolicyRoutes(g *echo.Group) {
g.GET("/policy/:resourceType/:resourceID", func(c echo.Context) error {
ctx := c.Request().Context()
- resourceType, err := getPolicyResourceType(c.Param("resourceType"))
+ resourceType, err := api.GetPolicyResourceType(c.Param("resourceType"))
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
@@ -168,7 +168,7 @@ func (s *Server) registerPolicyRoutes(g *echo.Group) {
var resourceType *api.PolicyResourceType
var resourceID *int
if c.QueryParam("resourceType") != "" {
- rt, err := getPolicyResourceType(c.QueryParam("resourceType"))
+ rt, err := api.GetPolicyResourceType(c.QueryParam("resourceType"))
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
@@ -206,25 +206,6 @@ func (s *Server) registerPolicyRoutes(g *echo.Group) {
})
}
-func getPolicyResourceType(resourceType string) (api.PolicyResourceType, error) {
- var rt api.PolicyResourceType
- switch resourceType {
- case "workspace":
- rt = api.PolicyResourceTypeWorkspace
- case "environment":
- rt = api.PolicyResourceTypeEnvironment
- case "project":
- rt = api.PolicyResourceTypeProject
- case "instance":
- rt = api.PolicyResourceTypeInstance
- case "database":
- rt = api.PolicyResourceTypeDatabase
- default:
- return api.PolicyResourceTypeUnknown, errors.Errorf("invalid policy resource type %q", rt)
- }
- return rt, nil
-}
-
func getPolicyResourceID(resourceID string) (int, error) {
id, err := strconv.Atoi(resourceID)
if err != nil {
diff --git a/server/server.go b/server/server.go
index 2927e9cde6..e5e95f4992 100644
--- a/server/server.go
+++ b/server/server.go
@@ -455,6 +455,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
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)))
+ v1pb.RegisterOrgPolicyServiceServer(s.grpcServer, v1.NewOrgPolicyService(s.store, s.licenseService))
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
grpcEndpoint := fmt.Sprintf(":%d", profile.GrpcPort)
if err := v1pb.RegisterAuthServiceHandlerFromEndpoint(ctx, mux, grpcEndpoint, opts); err != nil {
@@ -475,6 +476,9 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
if err := v1pb.RegisterInstanceRoleServiceHandlerFromEndpoint(ctx, mux, grpcEndpoint, opts); err != nil {
return nil, err
}
+ if err := v1pb.RegisterOrgPolicyServiceHandlerFromEndpoint(ctx, mux, grpcEndpoint, opts); err != nil {
+ return nil, err
+ }
e.Any("/v1/*", echo.WrapHandler(mux))
// Register open API routes
diff --git a/store/policy.go b/store/policy.go
index 23b9e4b0ac..10dc73b0e9 100644
--- a/store/policy.go
+++ b/store/policy.go
@@ -539,3 +539,131 @@ func (s *Store) upsertPolicyCache(policyType api.PolicyType, resourceID int, pay
}
return nil
}
+
+// PolicyMessage is the mssage for policy.
+type PolicyMessage struct {
+ UID int
+ ResourceID string
+ ResourceType api.PolicyResourceType
+ Payload string
+ InheritFromParent bool
+ Deleted bool
+ Type api.PolicyType
+}
+
+// FindPolicyMessage is the message for finding policies.
+type FindPolicyMessage struct {
+ ResourceType *api.PolicyResourceType
+ ResourceUID *int
+ Type *api.PolicyType
+ ShowDeleted bool
+}
+
+// GetPolicyV2 gets a policy.
+func (s *Store) GetPolicyV2(ctx context.Context, find *FindPolicyMessage) (*PolicyMessage, error) {
+ // We will always return the resource regardless of its deleted state.
+ find.ShowDeleted = true
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return nil, FormatError(err)
+ }
+ defer tx.Rollback()
+
+ policies, err := s.listPolicyImplV2(ctx, tx, find)
+ if err != nil {
+ return nil, err
+ }
+ if len(policies) == 0 {
+ return nil, nil
+ }
+ if len(policies) > 1 {
+ return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d policies with filter %+v, expect 1", len(policies), find)}
+ }
+ policy := policies[0]
+
+ if err := tx.Commit(); err != nil {
+ return nil, FormatError(err)
+ }
+
+ // TODO: add cache
+ return policy, nil
+}
+
+// ListPoliciesV2 lists all policies.
+func (s *Store) ListPoliciesV2(ctx context.Context, find *FindPolicyMessage) ([]*PolicyMessage, error) {
+ tx, err := s.db.BeginTx(ctx, nil)
+ if err != nil {
+ return nil, FormatError(err)
+ }
+ defer tx.Rollback()
+
+ policies, err := s.listPolicyImplV2(ctx, tx, find)
+ if err != nil {
+ return nil, err
+ }
+
+ if err := tx.Commit(); err != nil {
+ return nil, FormatError(err)
+ }
+
+ // TODO: add cache
+ return policies, nil
+}
+
+func (*Store) listPolicyImplV2(ctx context.Context, tx *Tx, find *FindPolicyMessage) ([]*PolicyMessage, error) {
+ where, args := []string{"1 = 1"}, []interface{}{}
+ if v := find.ResourceType; v != nil {
+ where, args = append(where, fmt.Sprintf("resource_type = $%d", len(args)+1)), append(args, *v)
+ }
+ if v := find.ResourceUID; v != nil {
+ where, args = append(where, fmt.Sprintf("resource_id = $%d", len(args)+1)), append(args, *v)
+ }
+ if v := find.Type; v != nil {
+ where, args = append(where, fmt.Sprintf("type = $%d", len(args)+1)), append(args, *v)
+ }
+ if !find.ShowDeleted {
+ where, args = append(where, fmt.Sprintf("row_status = $%d", len(args)+1)), append(args, api.Normal)
+ }
+
+ rows, err := tx.QueryContext(ctx, `
+ SELECT
+ id,
+ row_status,
+ resource_type,
+ resource_id,
+ inherit_from_parent,
+ type,
+ payload
+ FROM policy
+ WHERE `+strings.Join(where, " AND "),
+ args...,
+ )
+ if err != nil {
+ return nil, FormatError(err)
+ }
+ defer rows.Close()
+
+ var policyList []*PolicyMessage
+ for rows.Next() {
+ var policyMessage PolicyMessage
+ var rowStatus string
+ if err := rows.Scan(
+ &policyMessage.UID,
+ &rowStatus,
+ &policyMessage.ResourceType,
+ &policyMessage.ResourceID,
+ &policyMessage.InheritFromParent,
+ &policyMessage.Type,
+ &policyMessage.Payload,
+ ); err != nil {
+ return nil, FormatError(err)
+ }
+ policyMessage.Deleted = convertRowStatusToDeleted(rowStatus)
+
+ policyList = append(policyList, &policyMessage)
+ }
+ if err := rows.Err(); err != nil {
+ return nil, FormatError(err)
+ }
+ return policyList, nil
+}