From 01319ad692dbca0de594c90f0b255485fb1f9815 Mon Sep 17 00:00:00 2001 From: Stefano Scafiti Date: Wed, 12 Nov 2025 16:59:18 +0100 Subject: [PATCH 1/3] feat: add broken sets API --- proto/apidocs.swagger.json | 37 + .../materialize/v0/brokensets_service.pb.go | 276 ++++++ .../v0/brokensets_service.pb.validate.go | 439 ++++++++++ .../v0/brokensets_service_grpc.pb.go | 136 +++ .../v0/brokensets_service_vtproto.pb.go | 828 ++++++++++++++++++ 5 files changed, 1716 insertions(+) create mode 100644 proto/authzed/api/materialize/v0/brokensets_service.pb.go create mode 100644 proto/authzed/api/materialize/v0/brokensets_service.pb.validate.go create mode 100644 proto/authzed/api/materialize/v0/brokensets_service_grpc.pb.go create mode 100644 proto/authzed/api/materialize/v0/brokensets_service_vtproto.pb.go diff --git a/proto/apidocs.swagger.json b/proto/apidocs.swagger.json index 02b0ee2..1c20a17 100644 --- a/proto/apidocs.swagger.json +++ b/proto/apidocs.swagger.json @@ -14,6 +14,9 @@ } }, "tags": [ + { + "name": "BrokenSetsService" + }, { "name": "PermissionsService" }, @@ -1172,6 +1175,23 @@ }, "description": "BreakingSchemaChange is used to signal a breaking schema change has happened, and that the consumer should\nexpect delays in the ingestion of new changes, because the permission set snapshot needs to be rebuilt from scratch.\nOnce the snapshot is ready, the consumer will receive a LookupPermissionSetsRequired event." }, + "v0BrokenSet": { + "type": "object", + "properties": { + "resourceType": { + "type": "string", + "description": "resource_type is the type of the broken resource." + }, + "resourceId": { + "type": "string", + "description": "resource_id is the id of the broken resource." + }, + "permission": { + "type": "string", + "description": "permission is the broken permission set." + } + } + }, "v0DownloadPermissionSetsResponse": { "type": "object", "properties": { @@ -1312,6 +1332,23 @@ } } }, + "v0ReadBrokenSetsResponse": { + "type": "object", + "properties": { + "brokenSets": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v0BrokenSet" + }, + "description": "broken_sets contains the list of broken sets found for the requested revision." + }, + "revision": { + "$ref": "#/definitions/v1ZedToken", + "description": "read_at is the ZedToken at which the broken set applies." + } + } + }, "v0SetReference": { "type": "object", "properties": { diff --git a/proto/authzed/api/materialize/v0/brokensets_service.pb.go b/proto/authzed/api/materialize/v0/brokensets_service.pb.go new file mode 100644 index 0000000..4ad113d --- /dev/null +++ b/proto/authzed/api/materialize/v0/brokensets_service.pb.go @@ -0,0 +1,276 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: authzed/api/materialize/v0/brokensets_service.proto + +package v0 + +import ( + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 ReadBrokenSetsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // batch_size specifies the maximum number of broken sets to return in a single response. + // If set to zero, the server will use the default batch size. + BatchSize uint32 `protobuf:"varint,1,opt,name=batch_size,json=batchSize,proto3" json:"batch_size,omitempty"` + // optional_at_revision defines the specific revision at which the broken sets should be evaluated. + // At this time, it is only compared against the revision of the provided backing store snapshot. + OptionalAtRevision *v1.ZedToken `protobuf:"bytes,2,opt,name=optional_at_revision,json=optionalAtRevision,proto3" json:"optional_at_revision,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReadBrokenSetsRequest) Reset() { + *x = ReadBrokenSetsRequest{} + mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReadBrokenSetsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadBrokenSetsRequest) ProtoMessage() {} + +func (x *ReadBrokenSetsRequest) ProtoReflect() protoreflect.Message { + mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadBrokenSetsRequest.ProtoReflect.Descriptor instead. +func (*ReadBrokenSetsRequest) Descriptor() ([]byte, []int) { + return file_authzed_api_materialize_v0_brokensets_service_proto_rawDescGZIP(), []int{0} +} + +func (x *ReadBrokenSetsRequest) GetBatchSize() uint32 { + if x != nil { + return x.BatchSize + } + return 0 +} + +func (x *ReadBrokenSetsRequest) GetOptionalAtRevision() *v1.ZedToken { + if x != nil { + return x.OptionalAtRevision + } + return nil +} + +type BrokenSet struct { + state protoimpl.MessageState `protogen:"open.v1"` + // resource_type is the type of the broken resource. + ResourceType string `protobuf:"bytes,1,opt,name=resource_type,json=resourceType,proto3" json:"resource_type,omitempty"` + // resource_id is the id of the broken resource. + ResourceId string `protobuf:"bytes,2,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` + // permission is the broken permission set. + Permission string `protobuf:"bytes,3,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BrokenSet) Reset() { + *x = BrokenSet{} + mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BrokenSet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BrokenSet) ProtoMessage() {} + +func (x *BrokenSet) ProtoReflect() protoreflect.Message { + mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BrokenSet.ProtoReflect.Descriptor instead. +func (*BrokenSet) Descriptor() ([]byte, []int) { + return file_authzed_api_materialize_v0_brokensets_service_proto_rawDescGZIP(), []int{1} +} + +func (x *BrokenSet) GetResourceType() string { + if x != nil { + return x.ResourceType + } + return "" +} + +func (x *BrokenSet) GetResourceId() string { + if x != nil { + return x.ResourceId + } + return "" +} + +func (x *BrokenSet) GetPermission() string { + if x != nil { + return x.Permission + } + return "" +} + +type ReadBrokenSetsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // broken_sets contains the list of broken sets found for the requested revision. + BrokenSets []*BrokenSet `protobuf:"bytes,1,rep,name=broken_sets,json=brokenSets,proto3" json:"broken_sets,omitempty"` + // read_at is the ZedToken at which the broken set applies. + Revision *v1.ZedToken `protobuf:"bytes,2,opt,name=revision,proto3" json:"revision,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReadBrokenSetsResponse) Reset() { + *x = ReadBrokenSetsResponse{} + mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReadBrokenSetsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadBrokenSetsResponse) ProtoMessage() {} + +func (x *ReadBrokenSetsResponse) ProtoReflect() protoreflect.Message { + mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadBrokenSetsResponse.ProtoReflect.Descriptor instead. +func (*ReadBrokenSetsResponse) Descriptor() ([]byte, []int) { + return file_authzed_api_materialize_v0_brokensets_service_proto_rawDescGZIP(), []int{2} +} + +func (x *ReadBrokenSetsResponse) GetBrokenSets() []*BrokenSet { + if x != nil { + return x.BrokenSets + } + return nil +} + +func (x *ReadBrokenSetsResponse) GetRevision() *v1.ZedToken { + if x != nil { + return x.Revision + } + return nil +} + +var File_authzed_api_materialize_v0_brokensets_service_proto protoreflect.FileDescriptor + +const file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc = "" + + "\n" + + "3authzed/api/materialize/v0/brokensets_service.proto\x12\x1aauthzed.api.materialize.v0\x1a\x19authzed/api/v1/core.proto\"\x82\x01\n" + + "\x15ReadBrokenSetsRequest\x12\x1d\n" + + "\n" + + "batch_size\x18\x01 \x01(\rR\tbatchSize\x12J\n" + + "\x14optional_at_revision\x18\x02 \x01(\v2\x18.authzed.api.v1.ZedTokenR\x12optionalAtRevision\"q\n" + + "\tBrokenSet\x12#\n" + + "\rresource_type\x18\x01 \x01(\tR\fresourceType\x12\x1f\n" + + "\vresource_id\x18\x02 \x01(\tR\n" + + "resourceId\x12\x1e\n" + + "\n" + + "permission\x18\x03 \x01(\tR\n" + + "permission\"\x96\x01\n" + + "\x16ReadBrokenSetsResponse\x12F\n" + + "\vbroken_sets\x18\x01 \x03(\v2%.authzed.api.materialize.v0.BrokenSetR\n" + + "brokenSets\x124\n" + + "\brevision\x18\x02 \x01(\v2\x18.authzed.api.v1.ZedTokenR\brevision2\x90\x01\n" + + "\x11BrokenSetsService\x12{\n" + + "\x0eReadBrokenSets\x121.authzed.api.materialize.v0.ReadBrokenSetsRequest\x1a2.authzed.api.materialize.v0.ReadBrokenSetsResponse\"\x000\x01Bb\n" + + "\x1ecom.authzed.api.materialize.v0P\x01Z>github.com/authzed/authzed-go/proto/authzed/api/materialize/v0b\x06proto3" + +var ( + file_authzed_api_materialize_v0_brokensets_service_proto_rawDescOnce sync.Once + file_authzed_api_materialize_v0_brokensets_service_proto_rawDescData []byte +) + +func file_authzed_api_materialize_v0_brokensets_service_proto_rawDescGZIP() []byte { + file_authzed_api_materialize_v0_brokensets_service_proto_rawDescOnce.Do(func() { + file_authzed_api_materialize_v0_brokensets_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc), len(file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc))) + }) + return file_authzed_api_materialize_v0_brokensets_service_proto_rawDescData +} + +var file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_authzed_api_materialize_v0_brokensets_service_proto_goTypes = []any{ + (*ReadBrokenSetsRequest)(nil), // 0: authzed.api.materialize.v0.ReadBrokenSetsRequest + (*BrokenSet)(nil), // 1: authzed.api.materialize.v0.BrokenSet + (*ReadBrokenSetsResponse)(nil), // 2: authzed.api.materialize.v0.ReadBrokenSetsResponse + (*v1.ZedToken)(nil), // 3: authzed.api.v1.ZedToken +} +var file_authzed_api_materialize_v0_brokensets_service_proto_depIdxs = []int32{ + 3, // 0: authzed.api.materialize.v0.ReadBrokenSetsRequest.optional_at_revision:type_name -> authzed.api.v1.ZedToken + 1, // 1: authzed.api.materialize.v0.ReadBrokenSetsResponse.broken_sets:type_name -> authzed.api.materialize.v0.BrokenSet + 3, // 2: authzed.api.materialize.v0.ReadBrokenSetsResponse.revision:type_name -> authzed.api.v1.ZedToken + 0, // 3: authzed.api.materialize.v0.BrokenSetsService.ReadBrokenSets:input_type -> authzed.api.materialize.v0.ReadBrokenSetsRequest + 2, // 4: authzed.api.materialize.v0.BrokenSetsService.ReadBrokenSets:output_type -> authzed.api.materialize.v0.ReadBrokenSetsResponse + 4, // [4:5] is the sub-list for method output_type + 3, // [3:4] 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_authzed_api_materialize_v0_brokensets_service_proto_init() } +func file_authzed_api_materialize_v0_brokensets_service_proto_init() { + if File_authzed_api_materialize_v0_brokensets_service_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc), len(file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc)), + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_authzed_api_materialize_v0_brokensets_service_proto_goTypes, + DependencyIndexes: file_authzed_api_materialize_v0_brokensets_service_proto_depIdxs, + MessageInfos: file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes, + }.Build() + File_authzed_api_materialize_v0_brokensets_service_proto = out.File + file_authzed_api_materialize_v0_brokensets_service_proto_goTypes = nil + file_authzed_api_materialize_v0_brokensets_service_proto_depIdxs = nil +} diff --git a/proto/authzed/api/materialize/v0/brokensets_service.pb.validate.go b/proto/authzed/api/materialize/v0/brokensets_service.pb.validate.go new file mode 100644 index 0000000..02b8d78 --- /dev/null +++ b/proto/authzed/api/materialize/v0/brokensets_service.pb.validate.go @@ -0,0 +1,439 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: authzed/api/materialize/v0/brokensets_service.proto + +package v0 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ReadBrokenSetsRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ReadBrokenSetsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReadBrokenSetsRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ReadBrokenSetsRequestMultiError, or nil if none found. +func (m *ReadBrokenSetsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ReadBrokenSetsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for BatchSize + + if all { + switch v := interface{}(m.GetOptionalAtRevision()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReadBrokenSetsRequestValidationError{ + field: "OptionalAtRevision", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReadBrokenSetsRequestValidationError{ + field: "OptionalAtRevision", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOptionalAtRevision()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReadBrokenSetsRequestValidationError{ + field: "OptionalAtRevision", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ReadBrokenSetsRequestMultiError(errors) + } + + return nil +} + +// ReadBrokenSetsRequestMultiError is an error wrapping multiple validation +// errors returned by ReadBrokenSetsRequest.ValidateAll() if the designated +// constraints aren't met. +type ReadBrokenSetsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReadBrokenSetsRequestMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ReadBrokenSetsRequestMultiError) AllErrors() []error { return m } + +// ReadBrokenSetsRequestValidationError is the validation error returned by +// ReadBrokenSetsRequest.Validate if the designated constraints aren't met. +type ReadBrokenSetsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReadBrokenSetsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReadBrokenSetsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReadBrokenSetsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReadBrokenSetsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReadBrokenSetsRequestValidationError) ErrorName() string { + return "ReadBrokenSetsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ReadBrokenSetsRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReadBrokenSetsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReadBrokenSetsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReadBrokenSetsRequestValidationError{} + +// Validate checks the field values on BrokenSet with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *BrokenSet) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on BrokenSet with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in BrokenSetMultiError, or nil +// if none found. +func (m *BrokenSet) ValidateAll() error { + return m.validate(true) +} + +func (m *BrokenSet) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for ResourceType + + // no validation rules for ResourceId + + // no validation rules for Permission + + if len(errors) > 0 { + return BrokenSetMultiError(errors) + } + + return nil +} + +// BrokenSetMultiError is an error wrapping multiple validation errors returned +// by BrokenSet.ValidateAll() if the designated constraints aren't met. +type BrokenSetMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m BrokenSetMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m BrokenSetMultiError) AllErrors() []error { return m } + +// BrokenSetValidationError is the validation error returned by +// BrokenSet.Validate if the designated constraints aren't met. +type BrokenSetValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e BrokenSetValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e BrokenSetValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e BrokenSetValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e BrokenSetValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e BrokenSetValidationError) ErrorName() string { return "BrokenSetValidationError" } + +// Error satisfies the builtin error interface +func (e BrokenSetValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sBrokenSet.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = BrokenSetValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = BrokenSetValidationError{} + +// Validate checks the field values on ReadBrokenSetsResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ReadBrokenSetsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReadBrokenSetsResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ReadBrokenSetsResponseMultiError, or nil if none found. +func (m *ReadBrokenSetsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ReadBrokenSetsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetBrokenSets() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReadBrokenSetsResponseValidationError{ + field: fmt.Sprintf("BrokenSets[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReadBrokenSetsResponseValidationError{ + field: fmt.Sprintf("BrokenSets[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReadBrokenSetsResponseValidationError{ + field: fmt.Sprintf("BrokenSets[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetRevision()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReadBrokenSetsResponseValidationError{ + field: "Revision", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReadBrokenSetsResponseValidationError{ + field: "Revision", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRevision()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReadBrokenSetsResponseValidationError{ + field: "Revision", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ReadBrokenSetsResponseMultiError(errors) + } + + return nil +} + +// ReadBrokenSetsResponseMultiError is an error wrapping multiple validation +// errors returned by ReadBrokenSetsResponse.ValidateAll() if the designated +// constraints aren't met. +type ReadBrokenSetsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReadBrokenSetsResponseMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ReadBrokenSetsResponseMultiError) AllErrors() []error { return m } + +// ReadBrokenSetsResponseValidationError is the validation error returned by +// ReadBrokenSetsResponse.Validate if the designated constraints aren't met. +type ReadBrokenSetsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReadBrokenSetsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReadBrokenSetsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReadBrokenSetsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReadBrokenSetsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReadBrokenSetsResponseValidationError) ErrorName() string { + return "ReadBrokenSetsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ReadBrokenSetsResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReadBrokenSetsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReadBrokenSetsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReadBrokenSetsResponseValidationError{} diff --git a/proto/authzed/api/materialize/v0/brokensets_service_grpc.pb.go b/proto/authzed/api/materialize/v0/brokensets_service_grpc.pb.go new file mode 100644 index 0000000..a83ab34 --- /dev/null +++ b/proto/authzed/api/materialize/v0/brokensets_service_grpc.pb.go @@ -0,0 +1,136 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: authzed/api/materialize/v0/brokensets_service.proto + +package v0 + +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.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + BrokenSetsService_ReadBrokenSets_FullMethodName = "/authzed.api.materialize.v0.BrokenSetsService/ReadBrokenSets" +) + +// BrokenSetsServiceClient is the client API for BrokenSetsService 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 BrokenSetsServiceClient interface { + // ReadBrokenSets returns all broken sets detected during + // the hydration process. + // + // Each broken set represents a circular dependency in the permission + // graph. The response includes the sets involved in each cycle, + // along with their associated resources. + ReadBrokenSets(ctx context.Context, in *ReadBrokenSetsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadBrokenSetsResponse], error) +} + +type brokenSetsServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewBrokenSetsServiceClient(cc grpc.ClientConnInterface) BrokenSetsServiceClient { + return &brokenSetsServiceClient{cc} +} + +func (c *brokenSetsServiceClient) ReadBrokenSets(ctx context.Context, in *ReadBrokenSetsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadBrokenSetsResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &BrokenSetsService_ServiceDesc.Streams[0], BrokenSetsService_ReadBrokenSets_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[ReadBrokenSetsRequest, ReadBrokenSetsResponse]{ClientStream: stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type BrokenSetsService_ReadBrokenSetsClient = grpc.ServerStreamingClient[ReadBrokenSetsResponse] + +// BrokenSetsServiceServer is the server API for BrokenSetsService service. +// All implementations must embed UnimplementedBrokenSetsServiceServer +// for forward compatibility. +type BrokenSetsServiceServer interface { + // ReadBrokenSets returns all broken sets detected during + // the hydration process. + // + // Each broken set represents a circular dependency in the permission + // graph. The response includes the sets involved in each cycle, + // along with their associated resources. + ReadBrokenSets(*ReadBrokenSetsRequest, grpc.ServerStreamingServer[ReadBrokenSetsResponse]) error + mustEmbedUnimplementedBrokenSetsServiceServer() +} + +// UnimplementedBrokenSetsServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedBrokenSetsServiceServer struct{} + +func (UnimplementedBrokenSetsServiceServer) ReadBrokenSets(*ReadBrokenSetsRequest, grpc.ServerStreamingServer[ReadBrokenSetsResponse]) error { + return status.Errorf(codes.Unimplemented, "method ReadBrokenSets not implemented") +} +func (UnimplementedBrokenSetsServiceServer) mustEmbedUnimplementedBrokenSetsServiceServer() {} +func (UnimplementedBrokenSetsServiceServer) testEmbeddedByValue() {} + +// UnsafeBrokenSetsServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BrokenSetsServiceServer will +// result in compilation errors. +type UnsafeBrokenSetsServiceServer interface { + mustEmbedUnimplementedBrokenSetsServiceServer() +} + +func RegisterBrokenSetsServiceServer(s grpc.ServiceRegistrar, srv BrokenSetsServiceServer) { + // If the following call pancis, it indicates UnimplementedBrokenSetsServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&BrokenSetsService_ServiceDesc, srv) +} + +func _BrokenSetsService_ReadBrokenSets_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ReadBrokenSetsRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(BrokenSetsServiceServer).ReadBrokenSets(m, &grpc.GenericServerStream[ReadBrokenSetsRequest, ReadBrokenSetsResponse]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type BrokenSetsService_ReadBrokenSetsServer = grpc.ServerStreamingServer[ReadBrokenSetsResponse] + +// BrokenSetsService_ServiceDesc is the grpc.ServiceDesc for BrokenSetsService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var BrokenSetsService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "authzed.api.materialize.v0.BrokenSetsService", + HandlerType: (*BrokenSetsServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "ReadBrokenSets", + Handler: _BrokenSetsService_ReadBrokenSets_Handler, + ServerStreams: true, + }, + }, + Metadata: "authzed/api/materialize/v0/brokensets_service.proto", +} diff --git a/proto/authzed/api/materialize/v0/brokensets_service_vtproto.pb.go b/proto/authzed/api/materialize/v0/brokensets_service_vtproto.pb.go new file mode 100644 index 0000000..98516fd --- /dev/null +++ b/proto/authzed/api/materialize/v0/brokensets_service_vtproto.pb.go @@ -0,0 +1,828 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.1-0.20240319094008-0393e58bdf10 +// source: authzed/api/materialize/v0/brokensets_service.proto + +package v0 + +import ( + fmt "fmt" + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" +) + +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) +) + +func (m *ReadBrokenSetsRequest) CloneVT() *ReadBrokenSetsRequest { + if m == nil { + return (*ReadBrokenSetsRequest)(nil) + } + r := new(ReadBrokenSetsRequest) + r.BatchSize = m.BatchSize + if rhs := m.OptionalAtRevision; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ZedToken }); ok { + r.OptionalAtRevision = vtpb.CloneVT() + } else { + r.OptionalAtRevision = proto.Clone(rhs).(*v1.ZedToken) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ReadBrokenSetsRequest) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *BrokenSet) CloneVT() *BrokenSet { + if m == nil { + return (*BrokenSet)(nil) + } + r := new(BrokenSet) + r.ResourceType = m.ResourceType + r.ResourceId = m.ResourceId + r.Permission = m.Permission + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *BrokenSet) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ReadBrokenSetsResponse) CloneVT() *ReadBrokenSetsResponse { + if m == nil { + return (*ReadBrokenSetsResponse)(nil) + } + r := new(ReadBrokenSetsResponse) + if rhs := m.BrokenSets; rhs != nil { + tmpContainer := make([]*BrokenSet, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.BrokenSets = tmpContainer + } + if rhs := m.Revision; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ZedToken }); ok { + r.Revision = vtpb.CloneVT() + } else { + r.Revision = proto.Clone(rhs).(*v1.ZedToken) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ReadBrokenSetsResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *ReadBrokenSetsRequest) EqualVT(that *ReadBrokenSetsRequest) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.BatchSize != that.BatchSize { + return false + } + if equal, ok := interface{}(this.OptionalAtRevision).(interface{ EqualVT(*v1.ZedToken) bool }); ok { + if !equal.EqualVT(that.OptionalAtRevision) { + return false + } + } else if !proto.Equal(this.OptionalAtRevision, that.OptionalAtRevision) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ReadBrokenSetsRequest) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ReadBrokenSetsRequest) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *BrokenSet) EqualVT(that *BrokenSet) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.ResourceType != that.ResourceType { + return false + } + if this.ResourceId != that.ResourceId { + return false + } + if this.Permission != that.Permission { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *BrokenSet) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*BrokenSet) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ReadBrokenSetsResponse) EqualVT(that *ReadBrokenSetsResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.BrokenSets) != len(that.BrokenSets) { + return false + } + for i, vx := range this.BrokenSets { + vy := that.BrokenSets[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &BrokenSet{} + } + if q == nil { + q = &BrokenSet{} + } + if !p.EqualVT(q) { + return false + } + } + } + if equal, ok := interface{}(this.Revision).(interface{ EqualVT(*v1.ZedToken) bool }); ok { + if !equal.EqualVT(that.Revision) { + return false + } + } else if !proto.Equal(this.Revision, that.Revision) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ReadBrokenSetsResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ReadBrokenSetsResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *ReadBrokenSetsRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ReadBrokenSetsRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ReadBrokenSetsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.OptionalAtRevision != nil { + if vtmsg, ok := interface{}(m.OptionalAtRevision).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.OptionalAtRevision) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.BatchSize != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.BatchSize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BrokenSet) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BrokenSet) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *BrokenSet) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Permission) > 0 { + i -= len(m.Permission) + copy(dAtA[i:], m.Permission) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Permission))) + i-- + dAtA[i] = 0x1a + } + if len(m.ResourceId) > 0 { + i -= len(m.ResourceId) + copy(dAtA[i:], m.ResourceId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ResourceType) > 0 { + i -= len(m.ResourceType) + copy(dAtA[i:], m.ResourceType) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ReadBrokenSetsResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ReadBrokenSetsResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ReadBrokenSetsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Revision != nil { + if vtmsg, ok := interface{}(m.Revision).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Revision) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if len(m.BrokenSets) > 0 { + for iNdEx := len(m.BrokenSets) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.BrokenSets[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ReadBrokenSetsRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BatchSize != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.BatchSize)) + } + if m.OptionalAtRevision != nil { + if size, ok := interface{}(m.OptionalAtRevision).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.OptionalAtRevision) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *BrokenSet) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ResourceType) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.ResourceId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Permission) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ReadBrokenSetsResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.BrokenSets) > 0 { + for _, e := range m.BrokenSets { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.Revision != nil { + if size, ok := interface{}(m.Revision).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Revision) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ReadBrokenSetsRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ReadBrokenSetsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ReadBrokenSetsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BatchSize", wireType) + } + m.BatchSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BatchSize |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalAtRevision", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.OptionalAtRevision == nil { + m.OptionalAtRevision = &v1.ZedToken{} + } + if unmarshal, ok := interface{}(m.OptionalAtRevision).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.OptionalAtRevision); err != nil { + return err + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BrokenSet) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BrokenSet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BrokenSet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Permission = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ReadBrokenSetsResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ReadBrokenSetsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ReadBrokenSetsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BrokenSets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BrokenSets = append(m.BrokenSets, &BrokenSet{}) + if err := m.BrokenSets[len(m.BrokenSets)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Revision == nil { + m.Revision = &v1.ZedToken{} + } + if unmarshal, ok := interface{}(m.Revision).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Revision); err != nil { + return err + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} From e5640dd4213e93d881d3e8b9b9de4ccd9d5d9a51 Mon Sep 17 00:00:00 2001 From: Stefano Scafiti Date: Thu, 13 Nov 2025 11:53:04 +0100 Subject: [PATCH 2/3] Generate proto files --- proto/apidocs.swagger.json | 60 +-- .../materialize/v0/brokenpermissions.pb.go | 274 ++++++++++ .../v0/brokenpermissions.pb.validate.go | 472 ++++++++++++++++++ .../v0/brokenpermissions_grpc.pb.go | 135 +++++ ....pb.go => brokenpermissions_vtproto.pb.go} | 467 +++++++++-------- .../materialize/v0/brokensets_service.pb.go | 276 ---------- .../v0/brokensets_service.pb.validate.go | 439 ---------------- .../v0/brokensets_service_grpc.pb.go | 136 ----- 8 files changed, 1158 insertions(+), 1101 deletions(-) create mode 100644 proto/authzed/api/materialize/v0/brokenpermissions.pb.go create mode 100644 proto/authzed/api/materialize/v0/brokenpermissions.pb.validate.go create mode 100644 proto/authzed/api/materialize/v0/brokenpermissions_grpc.pb.go rename proto/authzed/api/materialize/v0/{brokensets_service_vtproto.pb.go => brokenpermissions_vtproto.pb.go} (70%) delete mode 100644 proto/authzed/api/materialize/v0/brokensets_service.pb.go delete mode 100644 proto/authzed/api/materialize/v0/brokensets_service.pb.validate.go delete mode 100644 proto/authzed/api/materialize/v0/brokensets_service_grpc.pb.go diff --git a/proto/apidocs.swagger.json b/proto/apidocs.swagger.json index 1c20a17..c567be4 100644 --- a/proto/apidocs.swagger.json +++ b/proto/apidocs.swagger.json @@ -15,16 +15,16 @@ }, "tags": [ { - "name": "BrokenSetsService" + "name": "WatchPermissionsService" }, { - "name": "PermissionsService" + "name": "BrokenPermissionsService" }, { - "name": "RelationshipsService" + "name": "PermissionsService" }, { - "name": "WatchPermissionsService" + "name": "RelationshipsService" }, { "name": "WatchPermissionSetsService" @@ -1175,23 +1175,6 @@ }, "description": "BreakingSchemaChange is used to signal a breaking schema change has happened, and that the consumer should\nexpect delays in the ingestion of new changes, because the permission set snapshot needs to be rebuilt from scratch.\nOnce the snapshot is ready, the consumer will receive a LookupPermissionSetsRequired event." }, - "v0BrokenSet": { - "type": "object", - "properties": { - "resourceType": { - "type": "string", - "description": "resource_type is the type of the broken resource." - }, - "resourceId": { - "type": "string", - "description": "resource_id is the id of the broken resource." - }, - "permission": { - "type": "string", - "description": "permission is the broken permission set." - } - } - }, "v0DownloadPermissionSetsResponse": { "type": "object", "properties": { @@ -1332,20 +1315,41 @@ } } }, - "v0ReadBrokenSetsResponse": { + "v0ReadBrokenWatchedPermissionsResponse": { "type": "object", "properties": { - "brokenSets": { + "revision": { + "$ref": "#/definitions/v1ZedToken", + "description": "revision is the ZedToken at which the response was evaluated." + }, + "watchedPermission": { + "$ref": "#/definitions/v0WatchedPermission", + "description": "The watched permission that broke." + }, + "cycle": { "type": "array", "items": { "type": "object", - "$ref": "#/definitions/v0BrokenSet" + "$ref": "#/definitions/v0Resource" }, - "description": "broken_sets contains the list of broken sets found for the requested revision." + "description": "The resources involved in the cycle." + } + } + }, + "v0Resource": { + "type": "object", + "properties": { + "objectType": { + "type": "string", + "description": "object_type is the type of the resource." }, - "revision": { - "$ref": "#/definitions/v1ZedToken", - "description": "read_at is the ZedToken at which the broken set applies." + "objectId": { + "type": "string", + "description": "object_id is the id of the resource." + }, + "permissionOrRelation": { + "type": "string", + "description": "permission_or_relation is the permission/relation." } } }, diff --git a/proto/authzed/api/materialize/v0/brokenpermissions.pb.go b/proto/authzed/api/materialize/v0/brokenpermissions.pb.go new file mode 100644 index 0000000..a7d94a0 --- /dev/null +++ b/proto/authzed/api/materialize/v0/brokenpermissions.pb.go @@ -0,0 +1,274 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: authzed/api/materialize/v0/brokenpermissions.proto + +package v0 + +import ( + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +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 ReadBrokenWatchedPermissionsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // optional_at_revision defines the specific revision at which the broken sets should be evaluated. + // At this time, it is only compared against the revision of the provided backing store snapshot. + OptionalAtRevision *v1.ZedToken `protobuf:"bytes,2,opt,name=optional_at_revision,json=optionalAtRevision,proto3" json:"optional_at_revision,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReadBrokenWatchedPermissionsRequest) Reset() { + *x = ReadBrokenWatchedPermissionsRequest{} + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReadBrokenWatchedPermissionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadBrokenWatchedPermissionsRequest) ProtoMessage() {} + +func (x *ReadBrokenWatchedPermissionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadBrokenWatchedPermissionsRequest.ProtoReflect.Descriptor instead. +func (*ReadBrokenWatchedPermissionsRequest) Descriptor() ([]byte, []int) { + return file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescGZIP(), []int{0} +} + +func (x *ReadBrokenWatchedPermissionsRequest) GetOptionalAtRevision() *v1.ZedToken { + if x != nil { + return x.OptionalAtRevision + } + return nil +} + +type ReadBrokenWatchedPermissionsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // revision is the ZedToken at which the response was evaluated. + Revision *v1.ZedToken `protobuf:"bytes,1,opt,name=revision,proto3" json:"revision,omitempty"` + // The watched permission that broke. + WatchedPermission *WatchedPermission `protobuf:"bytes,2,opt,name=watched_permission,json=watchedPermission,proto3" json:"watched_permission,omitempty"` + // The resources involved in the cycle. + Cycle []*Resource `protobuf:"bytes,3,rep,name=cycle,proto3" json:"cycle,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ReadBrokenWatchedPermissionsResponse) Reset() { + *x = ReadBrokenWatchedPermissionsResponse{} + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ReadBrokenWatchedPermissionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadBrokenWatchedPermissionsResponse) ProtoMessage() {} + +func (x *ReadBrokenWatchedPermissionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadBrokenWatchedPermissionsResponse.ProtoReflect.Descriptor instead. +func (*ReadBrokenWatchedPermissionsResponse) Descriptor() ([]byte, []int) { + return file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescGZIP(), []int{1} +} + +func (x *ReadBrokenWatchedPermissionsResponse) GetRevision() *v1.ZedToken { + if x != nil { + return x.Revision + } + return nil +} + +func (x *ReadBrokenWatchedPermissionsResponse) GetWatchedPermission() *WatchedPermission { + if x != nil { + return x.WatchedPermission + } + return nil +} + +func (x *ReadBrokenWatchedPermissionsResponse) GetCycle() []*Resource { + if x != nil { + return x.Cycle + } + return nil +} + +type Resource struct { + state protoimpl.MessageState `protogen:"open.v1"` + // object_type is the type of the resource. + ObjectType string `protobuf:"bytes,1,opt,name=object_type,json=objectType,proto3" json:"object_type,omitempty"` + // object_id is the id of the resource. + ObjectId string `protobuf:"bytes,2,opt,name=object_id,json=objectId,proto3" json:"object_id,omitempty"` + // permission_or_relation is the permission/relation. + PermissionOrRelation string `protobuf:"bytes,3,opt,name=permission_or_relation,json=permissionOrRelation,proto3" json:"permission_or_relation,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Resource) Reset() { + *x = Resource{} + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Resource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource) ProtoMessage() {} + +func (x *Resource) ProtoReflect() protoreflect.Message { + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Resource.ProtoReflect.Descriptor instead. +func (*Resource) Descriptor() ([]byte, []int) { + return file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescGZIP(), []int{2} +} + +func (x *Resource) GetObjectType() string { + if x != nil { + return x.ObjectType + } + return "" +} + +func (x *Resource) GetObjectId() string { + if x != nil { + return x.ObjectId + } + return "" +} + +func (x *Resource) GetPermissionOrRelation() string { + if x != nil { + return x.PermissionOrRelation + } + return "" +} + +var File_authzed_api_materialize_v0_brokenpermissions_proto protoreflect.FileDescriptor + +const file_authzed_api_materialize_v0_brokenpermissions_proto_rawDesc = "" + + "\n" + + "2authzed/api/materialize/v0/brokenpermissions.proto\x12\x1aauthzed.api.materialize.v0\x1a1authzed/api/materialize/v0/watchpermissions.proto\x1a\x19authzed/api/v1/core.proto\"q\n" + + "#ReadBrokenWatchedPermissionsRequest\x12J\n" + + "\x14optional_at_revision\x18\x02 \x01(\v2\x18.authzed.api.v1.ZedTokenR\x12optionalAtRevision\"\xf6\x01\n" + + "$ReadBrokenWatchedPermissionsResponse\x124\n" + + "\brevision\x18\x01 \x01(\v2\x18.authzed.api.v1.ZedTokenR\brevision\x12\\\n" + + "\x12watched_permission\x18\x02 \x01(\v2-.authzed.api.materialize.v0.WatchedPermissionR\x11watchedPermission\x12:\n" + + "\x05cycle\x18\x03 \x03(\v2$.authzed.api.materialize.v0.ResourceR\x05cycle\"~\n" + + "\bResource\x12\x1f\n" + + "\vobject_type\x18\x01 \x01(\tR\n" + + "objectType\x12\x1b\n" + + "\tobject_id\x18\x02 \x01(\tR\bobjectId\x124\n" + + "\x16permission_or_relation\x18\x03 \x01(\tR\x14permissionOrRelation2\xc2\x01\n" + + "\x18BrokenPermissionsService\x12\xa5\x01\n" + + "\x1cReadBrokenWatchedPermissions\x12?.authzed.api.materialize.v0.ReadBrokenWatchedPermissionsRequest\x1a@.authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse\"\x000\x01Bb\n" + + "\x1ecom.authzed.api.materialize.v0P\x01Z>github.com/authzed/authzed-go/proto/authzed/api/materialize/v0b\x06proto3" + +var ( + file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescOnce sync.Once + file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescData []byte +) + +func file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescGZIP() []byte { + file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescOnce.Do(func() { + file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_authzed_api_materialize_v0_brokenpermissions_proto_rawDesc), len(file_authzed_api_materialize_v0_brokenpermissions_proto_rawDesc))) + }) + return file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescData +} + +var file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_authzed_api_materialize_v0_brokenpermissions_proto_goTypes = []any{ + (*ReadBrokenWatchedPermissionsRequest)(nil), // 0: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsRequest + (*ReadBrokenWatchedPermissionsResponse)(nil), // 1: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse + (*Resource)(nil), // 2: authzed.api.materialize.v0.Resource + (*v1.ZedToken)(nil), // 3: authzed.api.v1.ZedToken + (*WatchedPermission)(nil), // 4: authzed.api.materialize.v0.WatchedPermission +} +var file_authzed_api_materialize_v0_brokenpermissions_proto_depIdxs = []int32{ + 3, // 0: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsRequest.optional_at_revision:type_name -> authzed.api.v1.ZedToken + 3, // 1: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.revision:type_name -> authzed.api.v1.ZedToken + 4, // 2: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.watched_permission:type_name -> authzed.api.materialize.v0.WatchedPermission + 2, // 3: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.cycle:type_name -> authzed.api.materialize.v0.Resource + 0, // 4: authzed.api.materialize.v0.BrokenPermissionsService.ReadBrokenWatchedPermissions:input_type -> authzed.api.materialize.v0.ReadBrokenWatchedPermissionsRequest + 1, // 5: authzed.api.materialize.v0.BrokenPermissionsService.ReadBrokenWatchedPermissions:output_type -> authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse + 5, // [5:6] is the sub-list for method output_type + 4, // [4:5] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_authzed_api_materialize_v0_brokenpermissions_proto_init() } +func file_authzed_api_materialize_v0_brokenpermissions_proto_init() { + if File_authzed_api_materialize_v0_brokenpermissions_proto != nil { + return + } + file_authzed_api_materialize_v0_watchpermissions_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_authzed_api_materialize_v0_brokenpermissions_proto_rawDesc), len(file_authzed_api_materialize_v0_brokenpermissions_proto_rawDesc)), + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_authzed_api_materialize_v0_brokenpermissions_proto_goTypes, + DependencyIndexes: file_authzed_api_materialize_v0_brokenpermissions_proto_depIdxs, + MessageInfos: file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes, + }.Build() + File_authzed_api_materialize_v0_brokenpermissions_proto = out.File + file_authzed_api_materialize_v0_brokenpermissions_proto_goTypes = nil + file_authzed_api_materialize_v0_brokenpermissions_proto_depIdxs = nil +} diff --git a/proto/authzed/api/materialize/v0/brokenpermissions.pb.validate.go b/proto/authzed/api/materialize/v0/brokenpermissions.pb.validate.go new file mode 100644 index 0000000..a8a4947 --- /dev/null +++ b/proto/authzed/api/materialize/v0/brokenpermissions.pb.validate.go @@ -0,0 +1,472 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: authzed/api/materialize/v0/brokenpermissions.proto + +package v0 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ReadBrokenWatchedPermissionsRequest with +// the rules defined in the proto definition for this message. If any rules +// are violated, the first error encountered is returned, or nil if there are +// no violations. +func (m *ReadBrokenWatchedPermissionsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReadBrokenWatchedPermissionsRequest +// with the rules defined in the proto definition for this message. If any +// rules are violated, the result is a list of violation errors wrapped in +// ReadBrokenWatchedPermissionsRequestMultiError, or nil if none found. +func (m *ReadBrokenWatchedPermissionsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ReadBrokenWatchedPermissionsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetOptionalAtRevision()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReadBrokenWatchedPermissionsRequestValidationError{ + field: "OptionalAtRevision", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReadBrokenWatchedPermissionsRequestValidationError{ + field: "OptionalAtRevision", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOptionalAtRevision()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReadBrokenWatchedPermissionsRequestValidationError{ + field: "OptionalAtRevision", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ReadBrokenWatchedPermissionsRequestMultiError(errors) + } + + return nil +} + +// ReadBrokenWatchedPermissionsRequestMultiError is an error wrapping multiple +// validation errors returned by +// ReadBrokenWatchedPermissionsRequest.ValidateAll() if the designated +// constraints aren't met. +type ReadBrokenWatchedPermissionsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReadBrokenWatchedPermissionsRequestMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ReadBrokenWatchedPermissionsRequestMultiError) AllErrors() []error { return m } + +// ReadBrokenWatchedPermissionsRequestValidationError is the validation error +// returned by ReadBrokenWatchedPermissionsRequest.Validate if the designated +// constraints aren't met. +type ReadBrokenWatchedPermissionsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReadBrokenWatchedPermissionsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReadBrokenWatchedPermissionsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReadBrokenWatchedPermissionsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReadBrokenWatchedPermissionsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReadBrokenWatchedPermissionsRequestValidationError) ErrorName() string { + return "ReadBrokenWatchedPermissionsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ReadBrokenWatchedPermissionsRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReadBrokenWatchedPermissionsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReadBrokenWatchedPermissionsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReadBrokenWatchedPermissionsRequestValidationError{} + +// Validate checks the field values on ReadBrokenWatchedPermissionsResponse +// with the rules defined in the proto definition for this message. If any +// rules are violated, the first error encountered is returned, or nil if +// there are no violations. +func (m *ReadBrokenWatchedPermissionsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReadBrokenWatchedPermissionsResponse +// with the rules defined in the proto definition for this message. If any +// rules are violated, the result is a list of violation errors wrapped in +// ReadBrokenWatchedPermissionsResponseMultiError, or nil if none found. +func (m *ReadBrokenWatchedPermissionsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ReadBrokenWatchedPermissionsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRevision()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReadBrokenWatchedPermissionsResponseValidationError{ + field: "Revision", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReadBrokenWatchedPermissionsResponseValidationError{ + field: "Revision", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRevision()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReadBrokenWatchedPermissionsResponseValidationError{ + field: "Revision", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetWatchedPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReadBrokenWatchedPermissionsResponseValidationError{ + field: "WatchedPermission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReadBrokenWatchedPermissionsResponseValidationError{ + field: "WatchedPermission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetWatchedPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReadBrokenWatchedPermissionsResponseValidationError{ + field: "WatchedPermission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetCycle() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReadBrokenWatchedPermissionsResponseValidationError{ + field: fmt.Sprintf("Cycle[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReadBrokenWatchedPermissionsResponseValidationError{ + field: fmt.Sprintf("Cycle[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReadBrokenWatchedPermissionsResponseValidationError{ + field: fmt.Sprintf("Cycle[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ReadBrokenWatchedPermissionsResponseMultiError(errors) + } + + return nil +} + +// ReadBrokenWatchedPermissionsResponseMultiError is an error wrapping multiple +// validation errors returned by +// ReadBrokenWatchedPermissionsResponse.ValidateAll() if the designated +// constraints aren't met. +type ReadBrokenWatchedPermissionsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReadBrokenWatchedPermissionsResponseMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ReadBrokenWatchedPermissionsResponseMultiError) AllErrors() []error { return m } + +// ReadBrokenWatchedPermissionsResponseValidationError is the validation error +// returned by ReadBrokenWatchedPermissionsResponse.Validate if the designated +// constraints aren't met. +type ReadBrokenWatchedPermissionsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReadBrokenWatchedPermissionsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReadBrokenWatchedPermissionsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReadBrokenWatchedPermissionsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReadBrokenWatchedPermissionsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReadBrokenWatchedPermissionsResponseValidationError) ErrorName() string { + return "ReadBrokenWatchedPermissionsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ReadBrokenWatchedPermissionsResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReadBrokenWatchedPermissionsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReadBrokenWatchedPermissionsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReadBrokenWatchedPermissionsResponseValidationError{} + +// Validate checks the field values on Resource with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Resource) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Resource with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in ResourceMultiError, or nil +// if none found. +func (m *Resource) ValidateAll() error { + return m.validate(true) +} + +func (m *Resource) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for ObjectType + + // no validation rules for ObjectId + + // no validation rules for PermissionOrRelation + + if len(errors) > 0 { + return ResourceMultiError(errors) + } + + return nil +} + +// ResourceMultiError is an error wrapping multiple validation errors returned +// by Resource.ValidateAll() if the designated constraints aren't met. +type ResourceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResourceMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ResourceMultiError) AllErrors() []error { return m } + +// ResourceValidationError is the validation error returned by +// Resource.Validate if the designated constraints aren't met. +type ResourceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResourceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResourceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResourceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResourceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResourceValidationError) ErrorName() string { return "ResourceValidationError" } + +// Error satisfies the builtin error interface +func (e ResourceValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sResource.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResourceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResourceValidationError{} diff --git a/proto/authzed/api/materialize/v0/brokenpermissions_grpc.pb.go b/proto/authzed/api/materialize/v0/brokenpermissions_grpc.pb.go new file mode 100644 index 0000000..0ccf596 --- /dev/null +++ b/proto/authzed/api/materialize/v0/brokenpermissions_grpc.pb.go @@ -0,0 +1,135 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: authzed/api/materialize/v0/brokenpermissions.proto + +package v0 + +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.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + BrokenPermissionsService_ReadBrokenWatchedPermissions_FullMethodName = "/authzed.api.materialize.v0.BrokenPermissionsService/ReadBrokenWatchedPermissions" +) + +// BrokenPermissionsServiceClient is the client API for BrokenPermissionsService 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 BrokenPermissionsServiceClient interface { + // ReadBrokenWatchedPermissions returns all cycles detected during + // the hydration process. + // + // Each cycle a circular dependency in the permission graph. + // The response includes the broken permission, along with the resources involved in each cycle. + ReadBrokenWatchedPermissions(ctx context.Context, in *ReadBrokenWatchedPermissionsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadBrokenWatchedPermissionsResponse], error) +} + +type brokenPermissionsServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewBrokenPermissionsServiceClient(cc grpc.ClientConnInterface) BrokenPermissionsServiceClient { + return &brokenPermissionsServiceClient{cc} +} + +func (c *brokenPermissionsServiceClient) ReadBrokenWatchedPermissions(ctx context.Context, in *ReadBrokenWatchedPermissionsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadBrokenWatchedPermissionsResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &BrokenPermissionsService_ServiceDesc.Streams[0], BrokenPermissionsService_ReadBrokenWatchedPermissions_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[ReadBrokenWatchedPermissionsRequest, ReadBrokenWatchedPermissionsResponse]{ClientStream: stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type BrokenPermissionsService_ReadBrokenWatchedPermissionsClient = grpc.ServerStreamingClient[ReadBrokenWatchedPermissionsResponse] + +// BrokenPermissionsServiceServer is the server API for BrokenPermissionsService service. +// All implementations must embed UnimplementedBrokenPermissionsServiceServer +// for forward compatibility. +type BrokenPermissionsServiceServer interface { + // ReadBrokenWatchedPermissions returns all cycles detected during + // the hydration process. + // + // Each cycle a circular dependency in the permission graph. + // The response includes the broken permission, along with the resources involved in each cycle. + ReadBrokenWatchedPermissions(*ReadBrokenWatchedPermissionsRequest, grpc.ServerStreamingServer[ReadBrokenWatchedPermissionsResponse]) error + mustEmbedUnimplementedBrokenPermissionsServiceServer() +} + +// UnimplementedBrokenPermissionsServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedBrokenPermissionsServiceServer struct{} + +func (UnimplementedBrokenPermissionsServiceServer) ReadBrokenWatchedPermissions(*ReadBrokenWatchedPermissionsRequest, grpc.ServerStreamingServer[ReadBrokenWatchedPermissionsResponse]) error { + return status.Errorf(codes.Unimplemented, "method ReadBrokenWatchedPermissions not implemented") +} +func (UnimplementedBrokenPermissionsServiceServer) mustEmbedUnimplementedBrokenPermissionsServiceServer() { +} +func (UnimplementedBrokenPermissionsServiceServer) testEmbeddedByValue() {} + +// UnsafeBrokenPermissionsServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to BrokenPermissionsServiceServer will +// result in compilation errors. +type UnsafeBrokenPermissionsServiceServer interface { + mustEmbedUnimplementedBrokenPermissionsServiceServer() +} + +func RegisterBrokenPermissionsServiceServer(s grpc.ServiceRegistrar, srv BrokenPermissionsServiceServer) { + // If the following call pancis, it indicates UnimplementedBrokenPermissionsServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&BrokenPermissionsService_ServiceDesc, srv) +} + +func _BrokenPermissionsService_ReadBrokenWatchedPermissions_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ReadBrokenWatchedPermissionsRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(BrokenPermissionsServiceServer).ReadBrokenWatchedPermissions(m, &grpc.GenericServerStream[ReadBrokenWatchedPermissionsRequest, ReadBrokenWatchedPermissionsResponse]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type BrokenPermissionsService_ReadBrokenWatchedPermissionsServer = grpc.ServerStreamingServer[ReadBrokenWatchedPermissionsResponse] + +// BrokenPermissionsService_ServiceDesc is the grpc.ServiceDesc for BrokenPermissionsService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var BrokenPermissionsService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "authzed.api.materialize.v0.BrokenPermissionsService", + HandlerType: (*BrokenPermissionsServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "ReadBrokenWatchedPermissions", + Handler: _BrokenPermissionsService_ReadBrokenWatchedPermissions_Handler, + ServerStreams: true, + }, + }, + Metadata: "authzed/api/materialize/v0/brokenpermissions.proto", +} diff --git a/proto/authzed/api/materialize/v0/brokensets_service_vtproto.pb.go b/proto/authzed/api/materialize/v0/brokenpermissions_vtproto.pb.go similarity index 70% rename from proto/authzed/api/materialize/v0/brokensets_service_vtproto.pb.go rename to proto/authzed/api/materialize/v0/brokenpermissions_vtproto.pb.go index 98516fd..dd94705 100644 --- a/proto/authzed/api/materialize/v0/brokensets_service_vtproto.pb.go +++ b/proto/authzed/api/materialize/v0/brokenpermissions_vtproto.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-vtproto. DO NOT EDIT. // protoc-gen-go-vtproto version: v0.6.1-0.20240319094008-0393e58bdf10 -// source: authzed/api/materialize/v0/brokensets_service.proto +// source: authzed/api/materialize/v0/brokenpermissions.proto package v0 @@ -20,12 +20,11 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -func (m *ReadBrokenSetsRequest) CloneVT() *ReadBrokenSetsRequest { +func (m *ReadBrokenWatchedPermissionsRequest) CloneVT() *ReadBrokenWatchedPermissionsRequest { if m == nil { - return (*ReadBrokenSetsRequest)(nil) + return (*ReadBrokenWatchedPermissionsRequest)(nil) } - r := new(ReadBrokenSetsRequest) - r.BatchSize = m.BatchSize + r := new(ReadBrokenWatchedPermissionsRequest) if rhs := m.OptionalAtRevision; rhs != nil { if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ZedToken }); ok { r.OptionalAtRevision = vtpb.CloneVT() @@ -40,18 +39,30 @@ func (m *ReadBrokenSetsRequest) CloneVT() *ReadBrokenSetsRequest { return r } -func (m *ReadBrokenSetsRequest) CloneMessageVT() proto.Message { +func (m *ReadBrokenWatchedPermissionsRequest) CloneMessageVT() proto.Message { return m.CloneVT() } -func (m *BrokenSet) CloneVT() *BrokenSet { +func (m *ReadBrokenWatchedPermissionsResponse) CloneVT() *ReadBrokenWatchedPermissionsResponse { if m == nil { - return (*BrokenSet)(nil) + return (*ReadBrokenWatchedPermissionsResponse)(nil) + } + r := new(ReadBrokenWatchedPermissionsResponse) + r.WatchedPermission = m.WatchedPermission.CloneVT() + if rhs := m.Revision; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ZedToken }); ok { + r.Revision = vtpb.CloneVT() + } else { + r.Revision = proto.Clone(rhs).(*v1.ZedToken) + } + } + if rhs := m.Cycle; rhs != nil { + tmpContainer := make([]*Resource, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Cycle = tmpContainer } - r := new(BrokenSet) - r.ResourceType = m.ResourceType - r.ResourceId = m.ResourceId - r.Permission = m.Permission if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -59,29 +70,18 @@ func (m *BrokenSet) CloneVT() *BrokenSet { return r } -func (m *BrokenSet) CloneMessageVT() proto.Message { +func (m *ReadBrokenWatchedPermissionsResponse) CloneMessageVT() proto.Message { return m.CloneVT() } -func (m *ReadBrokenSetsResponse) CloneVT() *ReadBrokenSetsResponse { +func (m *Resource) CloneVT() *Resource { if m == nil { - return (*ReadBrokenSetsResponse)(nil) - } - r := new(ReadBrokenSetsResponse) - if rhs := m.BrokenSets; rhs != nil { - tmpContainer := make([]*BrokenSet, len(rhs)) - for k, v := range rhs { - tmpContainer[k] = v.CloneVT() - } - r.BrokenSets = tmpContainer - } - if rhs := m.Revision; rhs != nil { - if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ZedToken }); ok { - r.Revision = vtpb.CloneVT() - } else { - r.Revision = proto.Clone(rhs).(*v1.ZedToken) - } + return (*Resource)(nil) } + r := new(Resource) + r.ObjectType = m.ObjectType + r.ObjectId = m.ObjectId + r.PermissionOrRelation = m.PermissionOrRelation if len(m.unknownFields) > 0 { r.unknownFields = make([]byte, len(m.unknownFields)) copy(r.unknownFields, m.unknownFields) @@ -89,19 +89,16 @@ func (m *ReadBrokenSetsResponse) CloneVT() *ReadBrokenSetsResponse { return r } -func (m *ReadBrokenSetsResponse) CloneMessageVT() proto.Message { +func (m *Resource) CloneMessageVT() proto.Message { return m.CloneVT() } -func (this *ReadBrokenSetsRequest) EqualVT(that *ReadBrokenSetsRequest) bool { +func (this *ReadBrokenWatchedPermissionsRequest) EqualVT(that *ReadBrokenWatchedPermissionsRequest) bool { if this == that { return true } else if this == nil || that == nil { return false } - if this.BatchSize != that.BatchSize { - return false - } if equal, ok := interface{}(this.OptionalAtRevision).(interface{ EqualVT(*v1.ZedToken) bool }); ok { if !equal.EqualVT(that.OptionalAtRevision) { return false @@ -112,79 +109,82 @@ func (this *ReadBrokenSetsRequest) EqualVT(that *ReadBrokenSetsRequest) bool { return string(this.unknownFields) == string(that.unknownFields) } -func (this *ReadBrokenSetsRequest) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*ReadBrokenSetsRequest) +func (this *ReadBrokenWatchedPermissionsRequest) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ReadBrokenWatchedPermissionsRequest) if !ok { return false } return this.EqualVT(that) } -func (this *BrokenSet) EqualVT(that *BrokenSet) bool { +func (this *ReadBrokenWatchedPermissionsResponse) EqualVT(that *ReadBrokenWatchedPermissionsResponse) bool { if this == that { return true } else if this == nil || that == nil { return false } - if this.ResourceType != that.ResourceType { + if equal, ok := interface{}(this.Revision).(interface{ EqualVT(*v1.ZedToken) bool }); ok { + if !equal.EqualVT(that.Revision) { + return false + } + } else if !proto.Equal(this.Revision, that.Revision) { return false } - if this.ResourceId != that.ResourceId { + if !this.WatchedPermission.EqualVT(that.WatchedPermission) { return false } - if this.Permission != that.Permission { + if len(this.Cycle) != len(that.Cycle) { return false } + for i, vx := range this.Cycle { + vy := that.Cycle[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &Resource{} + } + if q == nil { + q = &Resource{} + } + if !p.EqualVT(q) { + return false + } + } + } return string(this.unknownFields) == string(that.unknownFields) } -func (this *BrokenSet) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*BrokenSet) +func (this *ReadBrokenWatchedPermissionsResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ReadBrokenWatchedPermissionsResponse) if !ok { return false } return this.EqualVT(that) } -func (this *ReadBrokenSetsResponse) EqualVT(that *ReadBrokenSetsResponse) bool { +func (this *Resource) EqualVT(that *Resource) bool { if this == that { return true } else if this == nil || that == nil { return false } - if len(this.BrokenSets) != len(that.BrokenSets) { + if this.ObjectType != that.ObjectType { return false } - for i, vx := range this.BrokenSets { - vy := that.BrokenSets[i] - if p, q := vx, vy; p != q { - if p == nil { - p = &BrokenSet{} - } - if q == nil { - q = &BrokenSet{} - } - if !p.EqualVT(q) { - return false - } - } + if this.ObjectId != that.ObjectId { + return false } - if equal, ok := interface{}(this.Revision).(interface{ EqualVT(*v1.ZedToken) bool }); ok { - if !equal.EqualVT(that.Revision) { - return false - } - } else if !proto.Equal(this.Revision, that.Revision) { + if this.PermissionOrRelation != that.PermissionOrRelation { return false } return string(this.unknownFields) == string(that.unknownFields) } -func (this *ReadBrokenSetsResponse) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*ReadBrokenSetsResponse) +func (this *Resource) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Resource) if !ok { return false } return this.EqualVT(that) } -func (m *ReadBrokenSetsRequest) MarshalVT() (dAtA []byte, err error) { +func (m *ReadBrokenWatchedPermissionsRequest) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -197,12 +197,12 @@ func (m *ReadBrokenSetsRequest) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ReadBrokenSetsRequest) MarshalToVT(dAtA []byte) (int, error) { +func (m *ReadBrokenWatchedPermissionsRequest) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *ReadBrokenSetsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *ReadBrokenWatchedPermissionsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -236,15 +236,10 @@ func (m *ReadBrokenSetsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) i-- dAtA[i] = 0x12 } - if m.BatchSize != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.BatchSize)) - i-- - dAtA[i] = 0x8 - } return len(dAtA) - i, nil } -func (m *BrokenSet) MarshalVT() (dAtA []byte, err error) { +func (m *ReadBrokenWatchedPermissionsResponse) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -257,12 +252,12 @@ func (m *BrokenSet) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *BrokenSet) MarshalToVT(dAtA []byte) (int, error) { +func (m *ReadBrokenWatchedPermissionsResponse) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *BrokenSet) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *ReadBrokenWatchedPermissionsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -274,31 +269,54 @@ func (m *BrokenSet) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if len(m.Permission) > 0 { - i -= len(m.Permission) - copy(dAtA[i:], m.Permission) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Permission))) - i-- - dAtA[i] = 0x1a + if len(m.Cycle) > 0 { + for iNdEx := len(m.Cycle) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Cycle[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } } - if len(m.ResourceId) > 0 { - i -= len(m.ResourceId) - copy(dAtA[i:], m.ResourceId) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceId))) + if m.WatchedPermission != nil { + size, err := m.WatchedPermission.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) i-- dAtA[i] = 0x12 } - if len(m.ResourceType) > 0 { - i -= len(m.ResourceType) - copy(dAtA[i:], m.ResourceType) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceType))) + if m.Revision != nil { + if vtmsg, ok := interface{}(m.Revision).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Revision) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *ReadBrokenSetsResponse) MarshalVT() (dAtA []byte, err error) { +func (m *Resource) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil } @@ -311,12 +329,12 @@ func (m *ReadBrokenSetsResponse) MarshalVT() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ReadBrokenSetsResponse) MarshalToVT(dAtA []byte) (int, error) { +func (m *Resource) MarshalToVT(dAtA []byte) (int, error) { size := m.SizeVT() return m.MarshalToSizedBufferVT(dAtA[:size]) } -func (m *ReadBrokenSetsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { +func (m *Resource) MarshalToSizedBufferVT(dAtA []byte) (int, error) { if m == nil { return 0, nil } @@ -328,52 +346,36 @@ func (m *ReadBrokenSetsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } - if m.Revision != nil { - if vtmsg, ok := interface{}(m.Revision).(interface { - MarshalToSizedBufferVT([]byte) (int, error) - }); ok { - size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - } else { - encoded, err := proto.Marshal(m.Revision) - if err != nil { - return 0, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) - } + if len(m.PermissionOrRelation) > 0 { + i -= len(m.PermissionOrRelation) + copy(dAtA[i:], m.PermissionOrRelation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.PermissionOrRelation))) + i-- + dAtA[i] = 0x1a + } + if len(m.ObjectId) > 0 { + i -= len(m.ObjectId) + copy(dAtA[i:], m.ObjectId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ObjectId))) i-- dAtA[i] = 0x12 } - if len(m.BrokenSets) > 0 { - for iNdEx := len(m.BrokenSets) - 1; iNdEx >= 0; iNdEx-- { - size, err := m.BrokenSets[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } + if len(m.ObjectType) > 0 { + i -= len(m.ObjectType) + copy(dAtA[i:], m.ObjectType) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ObjectType))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *ReadBrokenSetsRequest) SizeVT() (n int) { +func (m *ReadBrokenWatchedPermissionsRequest) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - if m.BatchSize != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.BatchSize)) - } if m.OptionalAtRevision != nil { if size, ok := interface{}(m.OptionalAtRevision).(interface { SizeVT() int @@ -388,55 +390,59 @@ func (m *ReadBrokenSetsRequest) SizeVT() (n int) { return n } -func (m *BrokenSet) SizeVT() (n int) { +func (m *ReadBrokenWatchedPermissionsResponse) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ResourceType) - if l > 0 { + if m.Revision != nil { + if size, ok := interface{}(m.Revision).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Revision) + } n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } - l = len(m.ResourceId) - if l > 0 { + if m.WatchedPermission != nil { + l = m.WatchedPermission.SizeVT() n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } - l = len(m.Permission) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + if len(m.Cycle) > 0 { + for _, e := range m.Cycle { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } } n += len(m.unknownFields) return n } -func (m *ReadBrokenSetsResponse) SizeVT() (n int) { +func (m *Resource) SizeVT() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.BrokenSets) > 0 { - for _, e := range m.BrokenSets { - l = e.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } + l = len(m.ObjectType) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } - if m.Revision != nil { - if size, ok := interface{}(m.Revision).(interface { - SizeVT() int - }); ok { - l = size.SizeVT() - } else { - l = proto.Size(m.Revision) - } + l = len(m.ObjectId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.PermissionOrRelation) + if l > 0 { n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) } n += len(m.unknownFields) return n } -func (m *ReadBrokenSetsRequest) UnmarshalVT(dAtA []byte) error { +func (m *ReadBrokenWatchedPermissionsRequest) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -459,31 +465,12 @@ func (m *ReadBrokenSetsRequest) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ReadBrokenSetsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: ReadBrokenWatchedPermissionsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ReadBrokenSetsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ReadBrokenWatchedPermissionsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BatchSize", wireType) - } - m.BatchSize = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BatchSize |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OptionalAtRevision", wireType) @@ -550,7 +537,7 @@ func (m *ReadBrokenSetsRequest) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *BrokenSet) UnmarshalVT(dAtA []byte) error { +func (m *ReadBrokenWatchedPermissionsResponse) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -573,17 +560,17 @@ func (m *BrokenSet) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BrokenSet: wiretype end group for non-group") + return fmt.Errorf("proto: ReadBrokenWatchedPermissionsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BrokenSet: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ReadBrokenWatchedPermissionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceType", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -593,29 +580,41 @@ func (m *BrokenSet) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.ResourceType = string(dAtA[iNdEx:postIndex]) + if m.Revision == nil { + m.Revision = &v1.ZedToken{} + } + if unmarshal, ok := interface{}(m.Revision).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Revision); err != nil { + return err + } + } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field WatchedPermission", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -625,29 +624,33 @@ func (m *BrokenSet) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.ResourceId = string(dAtA[iNdEx:postIndex]) + if m.WatchedPermission == nil { + m.WatchedPermission = &WatchedPermission{} + } + if err := m.WatchedPermission.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Cycle", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -657,23 +660,25 @@ func (m *BrokenSet) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.Permission = string(dAtA[iNdEx:postIndex]) + m.Cycle = append(m.Cycle, &Resource{}) + if err := m.Cycle[len(m.Cycle)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -697,7 +702,7 @@ func (m *BrokenSet) UnmarshalVT(dAtA []byte) error { } return nil } -func (m *ReadBrokenSetsResponse) UnmarshalVT(dAtA []byte) error { +func (m *Resource) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -720,17 +725,17 @@ func (m *ReadBrokenSetsResponse) UnmarshalVT(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ReadBrokenSetsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: Resource: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ReadBrokenSetsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Resource: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BrokenSets", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ObjectType", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -740,31 +745,29 @@ func (m *ReadBrokenSetsResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - m.BrokenSets = append(m.BrokenSets, &BrokenSet{}) - if err := m.BrokenSets[len(m.BrokenSets)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ObjectType = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ObjectId", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protohelpers.ErrIntOverflow @@ -774,35 +777,55 @@ func (m *ReadBrokenSetsResponse) UnmarshalVT(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return protohelpers.ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return protohelpers.ErrInvalidLength } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Revision == nil { - m.Revision = &v1.ZedToken{} + m.ObjectId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PermissionOrRelation", wireType) } - if unmarshal, ok := interface{}(m.Revision).(interface { - UnmarshalVT([]byte) error - }); ok { - if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow } - } else { - if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Revision); err != nil { - return err + if iNdEx >= l { + return io.ErrUnexpectedEOF } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.PermissionOrRelation = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/proto/authzed/api/materialize/v0/brokensets_service.pb.go b/proto/authzed/api/materialize/v0/brokensets_service.pb.go deleted file mode 100644 index 4ad113d..0000000 --- a/proto/authzed/api/materialize/v0/brokensets_service.pb.go +++ /dev/null @@ -1,276 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: authzed/api/materialize/v0/brokensets_service.proto - -package v0 - -import ( - v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -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 ReadBrokenSetsRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // batch_size specifies the maximum number of broken sets to return in a single response. - // If set to zero, the server will use the default batch size. - BatchSize uint32 `protobuf:"varint,1,opt,name=batch_size,json=batchSize,proto3" json:"batch_size,omitempty"` - // optional_at_revision defines the specific revision at which the broken sets should be evaluated. - // At this time, it is only compared against the revision of the provided backing store snapshot. - OptionalAtRevision *v1.ZedToken `protobuf:"bytes,2,opt,name=optional_at_revision,json=optionalAtRevision,proto3" json:"optional_at_revision,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ReadBrokenSetsRequest) Reset() { - *x = ReadBrokenSetsRequest{} - mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ReadBrokenSetsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadBrokenSetsRequest) ProtoMessage() {} - -func (x *ReadBrokenSetsRequest) ProtoReflect() protoreflect.Message { - mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadBrokenSetsRequest.ProtoReflect.Descriptor instead. -func (*ReadBrokenSetsRequest) Descriptor() ([]byte, []int) { - return file_authzed_api_materialize_v0_brokensets_service_proto_rawDescGZIP(), []int{0} -} - -func (x *ReadBrokenSetsRequest) GetBatchSize() uint32 { - if x != nil { - return x.BatchSize - } - return 0 -} - -func (x *ReadBrokenSetsRequest) GetOptionalAtRevision() *v1.ZedToken { - if x != nil { - return x.OptionalAtRevision - } - return nil -} - -type BrokenSet struct { - state protoimpl.MessageState `protogen:"open.v1"` - // resource_type is the type of the broken resource. - ResourceType string `protobuf:"bytes,1,opt,name=resource_type,json=resourceType,proto3" json:"resource_type,omitempty"` - // resource_id is the id of the broken resource. - ResourceId string `protobuf:"bytes,2,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` - // permission is the broken permission set. - Permission string `protobuf:"bytes,3,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *BrokenSet) Reset() { - *x = BrokenSet{} - mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *BrokenSet) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BrokenSet) ProtoMessage() {} - -func (x *BrokenSet) ProtoReflect() protoreflect.Message { - mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BrokenSet.ProtoReflect.Descriptor instead. -func (*BrokenSet) Descriptor() ([]byte, []int) { - return file_authzed_api_materialize_v0_brokensets_service_proto_rawDescGZIP(), []int{1} -} - -func (x *BrokenSet) GetResourceType() string { - if x != nil { - return x.ResourceType - } - return "" -} - -func (x *BrokenSet) GetResourceId() string { - if x != nil { - return x.ResourceId - } - return "" -} - -func (x *BrokenSet) GetPermission() string { - if x != nil { - return x.Permission - } - return "" -} - -type ReadBrokenSetsResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // broken_sets contains the list of broken sets found for the requested revision. - BrokenSets []*BrokenSet `protobuf:"bytes,1,rep,name=broken_sets,json=brokenSets,proto3" json:"broken_sets,omitempty"` - // read_at is the ZedToken at which the broken set applies. - Revision *v1.ZedToken `protobuf:"bytes,2,opt,name=revision,proto3" json:"revision,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ReadBrokenSetsResponse) Reset() { - *x = ReadBrokenSetsResponse{} - mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ReadBrokenSetsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ReadBrokenSetsResponse) ProtoMessage() {} - -func (x *ReadBrokenSetsResponse) ProtoReflect() protoreflect.Message { - mi := &file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ReadBrokenSetsResponse.ProtoReflect.Descriptor instead. -func (*ReadBrokenSetsResponse) Descriptor() ([]byte, []int) { - return file_authzed_api_materialize_v0_brokensets_service_proto_rawDescGZIP(), []int{2} -} - -func (x *ReadBrokenSetsResponse) GetBrokenSets() []*BrokenSet { - if x != nil { - return x.BrokenSets - } - return nil -} - -func (x *ReadBrokenSetsResponse) GetRevision() *v1.ZedToken { - if x != nil { - return x.Revision - } - return nil -} - -var File_authzed_api_materialize_v0_brokensets_service_proto protoreflect.FileDescriptor - -const file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc = "" + - "\n" + - "3authzed/api/materialize/v0/brokensets_service.proto\x12\x1aauthzed.api.materialize.v0\x1a\x19authzed/api/v1/core.proto\"\x82\x01\n" + - "\x15ReadBrokenSetsRequest\x12\x1d\n" + - "\n" + - "batch_size\x18\x01 \x01(\rR\tbatchSize\x12J\n" + - "\x14optional_at_revision\x18\x02 \x01(\v2\x18.authzed.api.v1.ZedTokenR\x12optionalAtRevision\"q\n" + - "\tBrokenSet\x12#\n" + - "\rresource_type\x18\x01 \x01(\tR\fresourceType\x12\x1f\n" + - "\vresource_id\x18\x02 \x01(\tR\n" + - "resourceId\x12\x1e\n" + - "\n" + - "permission\x18\x03 \x01(\tR\n" + - "permission\"\x96\x01\n" + - "\x16ReadBrokenSetsResponse\x12F\n" + - "\vbroken_sets\x18\x01 \x03(\v2%.authzed.api.materialize.v0.BrokenSetR\n" + - "brokenSets\x124\n" + - "\brevision\x18\x02 \x01(\v2\x18.authzed.api.v1.ZedTokenR\brevision2\x90\x01\n" + - "\x11BrokenSetsService\x12{\n" + - "\x0eReadBrokenSets\x121.authzed.api.materialize.v0.ReadBrokenSetsRequest\x1a2.authzed.api.materialize.v0.ReadBrokenSetsResponse\"\x000\x01Bb\n" + - "\x1ecom.authzed.api.materialize.v0P\x01Z>github.com/authzed/authzed-go/proto/authzed/api/materialize/v0b\x06proto3" - -var ( - file_authzed_api_materialize_v0_brokensets_service_proto_rawDescOnce sync.Once - file_authzed_api_materialize_v0_brokensets_service_proto_rawDescData []byte -) - -func file_authzed_api_materialize_v0_brokensets_service_proto_rawDescGZIP() []byte { - file_authzed_api_materialize_v0_brokensets_service_proto_rawDescOnce.Do(func() { - file_authzed_api_materialize_v0_brokensets_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc), len(file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc))) - }) - return file_authzed_api_materialize_v0_brokensets_service_proto_rawDescData -} - -var file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_authzed_api_materialize_v0_brokensets_service_proto_goTypes = []any{ - (*ReadBrokenSetsRequest)(nil), // 0: authzed.api.materialize.v0.ReadBrokenSetsRequest - (*BrokenSet)(nil), // 1: authzed.api.materialize.v0.BrokenSet - (*ReadBrokenSetsResponse)(nil), // 2: authzed.api.materialize.v0.ReadBrokenSetsResponse - (*v1.ZedToken)(nil), // 3: authzed.api.v1.ZedToken -} -var file_authzed_api_materialize_v0_brokensets_service_proto_depIdxs = []int32{ - 3, // 0: authzed.api.materialize.v0.ReadBrokenSetsRequest.optional_at_revision:type_name -> authzed.api.v1.ZedToken - 1, // 1: authzed.api.materialize.v0.ReadBrokenSetsResponse.broken_sets:type_name -> authzed.api.materialize.v0.BrokenSet - 3, // 2: authzed.api.materialize.v0.ReadBrokenSetsResponse.revision:type_name -> authzed.api.v1.ZedToken - 0, // 3: authzed.api.materialize.v0.BrokenSetsService.ReadBrokenSets:input_type -> authzed.api.materialize.v0.ReadBrokenSetsRequest - 2, // 4: authzed.api.materialize.v0.BrokenSetsService.ReadBrokenSets:output_type -> authzed.api.materialize.v0.ReadBrokenSetsResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] 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_authzed_api_materialize_v0_brokensets_service_proto_init() } -func file_authzed_api_materialize_v0_brokensets_service_proto_init() { - if File_authzed_api_materialize_v0_brokensets_service_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc), len(file_authzed_api_materialize_v0_brokensets_service_proto_rawDesc)), - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_authzed_api_materialize_v0_brokensets_service_proto_goTypes, - DependencyIndexes: file_authzed_api_materialize_v0_brokensets_service_proto_depIdxs, - MessageInfos: file_authzed_api_materialize_v0_brokensets_service_proto_msgTypes, - }.Build() - File_authzed_api_materialize_v0_brokensets_service_proto = out.File - file_authzed_api_materialize_v0_brokensets_service_proto_goTypes = nil - file_authzed_api_materialize_v0_brokensets_service_proto_depIdxs = nil -} diff --git a/proto/authzed/api/materialize/v0/brokensets_service.pb.validate.go b/proto/authzed/api/materialize/v0/brokensets_service.pb.validate.go deleted file mode 100644 index 02b8d78..0000000 --- a/proto/authzed/api/materialize/v0/brokensets_service.pb.validate.go +++ /dev/null @@ -1,439 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: authzed/api/materialize/v0/brokensets_service.proto - -package v0 - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ReadBrokenSetsRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *ReadBrokenSetsRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ReadBrokenSetsRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// ReadBrokenSetsRequestMultiError, or nil if none found. -func (m *ReadBrokenSetsRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ReadBrokenSetsRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for BatchSize - - if all { - switch v := interface{}(m.GetOptionalAtRevision()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ReadBrokenSetsRequestValidationError{ - field: "OptionalAtRevision", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReadBrokenSetsRequestValidationError{ - field: "OptionalAtRevision", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetOptionalAtRevision()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ReadBrokenSetsRequestValidationError{ - field: "OptionalAtRevision", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ReadBrokenSetsRequestMultiError(errors) - } - - return nil -} - -// ReadBrokenSetsRequestMultiError is an error wrapping multiple validation -// errors returned by ReadBrokenSetsRequest.ValidateAll() if the designated -// constraints aren't met. -type ReadBrokenSetsRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ReadBrokenSetsRequestMultiError) Error() string { - msgs := make([]string, 0, len(m)) - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ReadBrokenSetsRequestMultiError) AllErrors() []error { return m } - -// ReadBrokenSetsRequestValidationError is the validation error returned by -// ReadBrokenSetsRequest.Validate if the designated constraints aren't met. -type ReadBrokenSetsRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ReadBrokenSetsRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ReadBrokenSetsRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ReadBrokenSetsRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ReadBrokenSetsRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ReadBrokenSetsRequestValidationError) ErrorName() string { - return "ReadBrokenSetsRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ReadBrokenSetsRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sReadBrokenSetsRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ReadBrokenSetsRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ReadBrokenSetsRequestValidationError{} - -// Validate checks the field values on BrokenSet with the rules defined in the -// proto definition for this message. If any rules are violated, the first -// error encountered is returned, or nil if there are no violations. -func (m *BrokenSet) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on BrokenSet with the rules defined in -// the proto definition for this message. If any rules are violated, the -// result is a list of violation errors wrapped in BrokenSetMultiError, or nil -// if none found. -func (m *BrokenSet) ValidateAll() error { - return m.validate(true) -} - -func (m *BrokenSet) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for ResourceType - - // no validation rules for ResourceId - - // no validation rules for Permission - - if len(errors) > 0 { - return BrokenSetMultiError(errors) - } - - return nil -} - -// BrokenSetMultiError is an error wrapping multiple validation errors returned -// by BrokenSet.ValidateAll() if the designated constraints aren't met. -type BrokenSetMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m BrokenSetMultiError) Error() string { - msgs := make([]string, 0, len(m)) - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m BrokenSetMultiError) AllErrors() []error { return m } - -// BrokenSetValidationError is the validation error returned by -// BrokenSet.Validate if the designated constraints aren't met. -type BrokenSetValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e BrokenSetValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e BrokenSetValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e BrokenSetValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e BrokenSetValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e BrokenSetValidationError) ErrorName() string { return "BrokenSetValidationError" } - -// Error satisfies the builtin error interface -func (e BrokenSetValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sBrokenSet.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = BrokenSetValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = BrokenSetValidationError{} - -// Validate checks the field values on ReadBrokenSetsResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *ReadBrokenSetsResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ReadBrokenSetsResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// ReadBrokenSetsResponseMultiError, or nil if none found. -func (m *ReadBrokenSetsResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ReadBrokenSetsResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetBrokenSets() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ReadBrokenSetsResponseValidationError{ - field: fmt.Sprintf("BrokenSets[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReadBrokenSetsResponseValidationError{ - field: fmt.Sprintf("BrokenSets[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ReadBrokenSetsResponseValidationError{ - field: fmt.Sprintf("BrokenSets[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetRevision()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ReadBrokenSetsResponseValidationError{ - field: "Revision", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ReadBrokenSetsResponseValidationError{ - field: "Revision", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRevision()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ReadBrokenSetsResponseValidationError{ - field: "Revision", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ReadBrokenSetsResponseMultiError(errors) - } - - return nil -} - -// ReadBrokenSetsResponseMultiError is an error wrapping multiple validation -// errors returned by ReadBrokenSetsResponse.ValidateAll() if the designated -// constraints aren't met. -type ReadBrokenSetsResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ReadBrokenSetsResponseMultiError) Error() string { - msgs := make([]string, 0, len(m)) - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ReadBrokenSetsResponseMultiError) AllErrors() []error { return m } - -// ReadBrokenSetsResponseValidationError is the validation error returned by -// ReadBrokenSetsResponse.Validate if the designated constraints aren't met. -type ReadBrokenSetsResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ReadBrokenSetsResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ReadBrokenSetsResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ReadBrokenSetsResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ReadBrokenSetsResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ReadBrokenSetsResponseValidationError) ErrorName() string { - return "ReadBrokenSetsResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ReadBrokenSetsResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sReadBrokenSetsResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ReadBrokenSetsResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ReadBrokenSetsResponseValidationError{} diff --git a/proto/authzed/api/materialize/v0/brokensets_service_grpc.pb.go b/proto/authzed/api/materialize/v0/brokensets_service_grpc.pb.go deleted file mode 100644 index a83ab34..0000000 --- a/proto/authzed/api/materialize/v0/brokensets_service_grpc.pb.go +++ /dev/null @@ -1,136 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: authzed/api/materialize/v0/brokensets_service.proto - -package v0 - -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.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - BrokenSetsService_ReadBrokenSets_FullMethodName = "/authzed.api.materialize.v0.BrokenSetsService/ReadBrokenSets" -) - -// BrokenSetsServiceClient is the client API for BrokenSetsService 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 BrokenSetsServiceClient interface { - // ReadBrokenSets returns all broken sets detected during - // the hydration process. - // - // Each broken set represents a circular dependency in the permission - // graph. The response includes the sets involved in each cycle, - // along with their associated resources. - ReadBrokenSets(ctx context.Context, in *ReadBrokenSetsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadBrokenSetsResponse], error) -} - -type brokenSetsServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewBrokenSetsServiceClient(cc grpc.ClientConnInterface) BrokenSetsServiceClient { - return &brokenSetsServiceClient{cc} -} - -func (c *brokenSetsServiceClient) ReadBrokenSets(ctx context.Context, in *ReadBrokenSetsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadBrokenSetsResponse], error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &BrokenSetsService_ServiceDesc.Streams[0], BrokenSetsService_ReadBrokenSets_FullMethodName, cOpts...) - if err != nil { - return nil, err - } - x := &grpc.GenericClientStream[ReadBrokenSetsRequest, ReadBrokenSetsResponse]{ClientStream: stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type BrokenSetsService_ReadBrokenSetsClient = grpc.ServerStreamingClient[ReadBrokenSetsResponse] - -// BrokenSetsServiceServer is the server API for BrokenSetsService service. -// All implementations must embed UnimplementedBrokenSetsServiceServer -// for forward compatibility. -type BrokenSetsServiceServer interface { - // ReadBrokenSets returns all broken sets detected during - // the hydration process. - // - // Each broken set represents a circular dependency in the permission - // graph. The response includes the sets involved in each cycle, - // along with their associated resources. - ReadBrokenSets(*ReadBrokenSetsRequest, grpc.ServerStreamingServer[ReadBrokenSetsResponse]) error - mustEmbedUnimplementedBrokenSetsServiceServer() -} - -// UnimplementedBrokenSetsServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedBrokenSetsServiceServer struct{} - -func (UnimplementedBrokenSetsServiceServer) ReadBrokenSets(*ReadBrokenSetsRequest, grpc.ServerStreamingServer[ReadBrokenSetsResponse]) error { - return status.Errorf(codes.Unimplemented, "method ReadBrokenSets not implemented") -} -func (UnimplementedBrokenSetsServiceServer) mustEmbedUnimplementedBrokenSetsServiceServer() {} -func (UnimplementedBrokenSetsServiceServer) testEmbeddedByValue() {} - -// UnsafeBrokenSetsServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to BrokenSetsServiceServer will -// result in compilation errors. -type UnsafeBrokenSetsServiceServer interface { - mustEmbedUnimplementedBrokenSetsServiceServer() -} - -func RegisterBrokenSetsServiceServer(s grpc.ServiceRegistrar, srv BrokenSetsServiceServer) { - // If the following call pancis, it indicates UnimplementedBrokenSetsServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&BrokenSetsService_ServiceDesc, srv) -} - -func _BrokenSetsService_ReadBrokenSets_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(ReadBrokenSetsRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(BrokenSetsServiceServer).ReadBrokenSets(m, &grpc.GenericServerStream[ReadBrokenSetsRequest, ReadBrokenSetsResponse]{ServerStream: stream}) -} - -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type BrokenSetsService_ReadBrokenSetsServer = grpc.ServerStreamingServer[ReadBrokenSetsResponse] - -// BrokenSetsService_ServiceDesc is the grpc.ServiceDesc for BrokenSetsService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var BrokenSetsService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "authzed.api.materialize.v0.BrokenSetsService", - HandlerType: (*BrokenSetsServiceServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "ReadBrokenSets", - Handler: _BrokenSetsService_ReadBrokenSets_Handler, - ServerStreams: true, - }, - }, - Metadata: "authzed/api/materialize/v0/brokensets_service.proto", -} From 250ce278d7c7396c0a3a37fde21edb6cd84f20ae Mon Sep 17 00:00:00 2001 From: Stefano Scafiti Date: Fri, 14 Nov 2025 09:40:34 +0100 Subject: [PATCH 3/3] Update proto --- proto/apidocs.swagger.json | 25 +- .../materialize/v0/brokenpermissions.pb.go | 104 ++++++-- .../v0/brokenpermissions.pb.validate.go | 106 +++++++++ .../v0/brokenpermissions_vtproto.pb.go | 222 +++++++++++++++++- 4 files changed, 427 insertions(+), 30 deletions(-) diff --git a/proto/apidocs.swagger.json b/proto/apidocs.swagger.json index c567be4..106bb70 100644 --- a/proto/apidocs.swagger.json +++ b/proto/apidocs.swagger.json @@ -14,9 +14,6 @@ } }, "tags": [ - { - "name": "WatchPermissionsService" - }, { "name": "BrokenPermissionsService" }, @@ -26,6 +23,9 @@ { "name": "RelationshipsService" }, + { + "name": "WatchPermissionsService" + }, { "name": "WatchPermissionSetsService" }, @@ -1175,6 +1175,19 @@ }, "description": "BreakingSchemaChange is used to signal a breaking schema change has happened, and that the consumer should\nexpect delays in the ingestion of new changes, because the permission set snapshot needs to be rebuilt from scratch.\nOnce the snapshot is ready, the consumer will receive a LookupPermissionSetsRequired event." }, + "v0BrokenWatchedPermission": { + "type": "object", + "properties": { + "resourceType": { + "type": "string", + "description": "resource_type is the type of the resource to watch for changes." + }, + "permission": { + "type": "string", + "description": "permission is the permission to watch for changes." + } + } + }, "v0DownloadPermissionSetsResponse": { "type": "object", "properties": { @@ -1320,10 +1333,10 @@ "properties": { "revision": { "$ref": "#/definitions/v1ZedToken", - "description": "revision is the ZedToken at which the response was evaluated." + "description": "revision is the ZedToken at which the request was evaluated." }, "watchedPermission": { - "$ref": "#/definitions/v0WatchedPermission", + "$ref": "#/definitions/v0BrokenWatchedPermission", "description": "The watched permission that broke." }, "cycle": { @@ -1332,7 +1345,7 @@ "type": "object", "$ref": "#/definitions/v0Resource" }, - "description": "The resources involved in the cycle." + "description": "The resources involved in the cycle. The resource order does not represent the cycle traversal order." } } }, diff --git a/proto/authzed/api/materialize/v0/brokenpermissions.pb.go b/proto/authzed/api/materialize/v0/brokenpermissions.pb.go index a7d94a0..9a862ee 100644 --- a/proto/authzed/api/materialize/v0/brokenpermissions.pb.go +++ b/proto/authzed/api/materialize/v0/brokenpermissions.pb.go @@ -24,7 +24,7 @@ const ( type ReadBrokenWatchedPermissionsRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - // optional_at_revision defines the specific revision at which the broken sets should be evaluated. + // optional_at_revision defines the specific revision at which the broken watched permissions should be evaluated. // At this time, it is only compared against the revision of the provided backing store snapshot. OptionalAtRevision *v1.ZedToken `protobuf:"bytes,2,opt,name=optional_at_revision,json=optionalAtRevision,proto3" json:"optional_at_revision,omitempty"` unknownFields protoimpl.UnknownFields @@ -70,11 +70,11 @@ func (x *ReadBrokenWatchedPermissionsRequest) GetOptionalAtRevision() *v1.ZedTok type ReadBrokenWatchedPermissionsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - // revision is the ZedToken at which the response was evaluated. + // revision is the ZedToken at which the request was evaluated. Revision *v1.ZedToken `protobuf:"bytes,1,opt,name=revision,proto3" json:"revision,omitempty"` // The watched permission that broke. - WatchedPermission *WatchedPermission `protobuf:"bytes,2,opt,name=watched_permission,json=watchedPermission,proto3" json:"watched_permission,omitempty"` - // The resources involved in the cycle. + WatchedPermission *BrokenWatchedPermission `protobuf:"bytes,2,opt,name=watched_permission,json=watchedPermission,proto3" json:"watched_permission,omitempty"` + // The resources involved in the cycle. The resource order does not represent the cycle traversal order. Cycle []*Resource `protobuf:"bytes,3,rep,name=cycle,proto3" json:"cycle,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -117,7 +117,7 @@ func (x *ReadBrokenWatchedPermissionsResponse) GetRevision() *v1.ZedToken { return nil } -func (x *ReadBrokenWatchedPermissionsResponse) GetWatchedPermission() *WatchedPermission { +func (x *ReadBrokenWatchedPermissionsResponse) GetWatchedPermission() *BrokenWatchedPermission { if x != nil { return x.WatchedPermission } @@ -131,6 +131,60 @@ func (x *ReadBrokenWatchedPermissionsResponse) GetCycle() []*Resource { return nil } +type BrokenWatchedPermission struct { + state protoimpl.MessageState `protogen:"open.v1"` + // resource_type is the type of the resource to watch for changes. + ResourceType string `protobuf:"bytes,1,opt,name=resource_type,json=resourceType,proto3" json:"resource_type,omitempty"` + // permission is the permission to watch for changes. + Permission string `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BrokenWatchedPermission) Reset() { + *x = BrokenWatchedPermission{} + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BrokenWatchedPermission) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BrokenWatchedPermission) ProtoMessage() {} + +func (x *BrokenWatchedPermission) ProtoReflect() protoreflect.Message { + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BrokenWatchedPermission.ProtoReflect.Descriptor instead. +func (*BrokenWatchedPermission) Descriptor() ([]byte, []int) { + return file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescGZIP(), []int{2} +} + +func (x *BrokenWatchedPermission) GetResourceType() string { + if x != nil { + return x.ResourceType + } + return "" +} + +func (x *BrokenWatchedPermission) GetPermission() string { + if x != nil { + return x.Permission + } + return "" +} + type Resource struct { state protoimpl.MessageState `protogen:"open.v1"` // object_type is the type of the resource. @@ -145,7 +199,7 @@ type Resource struct { func (x *Resource) Reset() { *x = Resource{} - mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[2] + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -157,7 +211,7 @@ func (x *Resource) String() string { func (*Resource) ProtoMessage() {} func (x *Resource) ProtoReflect() protoreflect.Message { - mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[2] + mi := &file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -170,7 +224,7 @@ func (x *Resource) ProtoReflect() protoreflect.Message { // Deprecated: Use Resource.ProtoReflect.Descriptor instead. func (*Resource) Descriptor() ([]byte, []int) { - return file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescGZIP(), []int{2} + return file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescGZIP(), []int{3} } func (x *Resource) GetObjectType() string { @@ -198,13 +252,18 @@ var File_authzed_api_materialize_v0_brokenpermissions_proto protoreflect.FileDes const file_authzed_api_materialize_v0_brokenpermissions_proto_rawDesc = "" + "\n" + - "2authzed/api/materialize/v0/brokenpermissions.proto\x12\x1aauthzed.api.materialize.v0\x1a1authzed/api/materialize/v0/watchpermissions.proto\x1a\x19authzed/api/v1/core.proto\"q\n" + + "2authzed/api/materialize/v0/brokenpermissions.proto\x12\x1aauthzed.api.materialize.v0\x1a\x19authzed/api/v1/core.proto\"q\n" + "#ReadBrokenWatchedPermissionsRequest\x12J\n" + - "\x14optional_at_revision\x18\x02 \x01(\v2\x18.authzed.api.v1.ZedTokenR\x12optionalAtRevision\"\xf6\x01\n" + + "\x14optional_at_revision\x18\x02 \x01(\v2\x18.authzed.api.v1.ZedTokenR\x12optionalAtRevision\"\xfc\x01\n" + "$ReadBrokenWatchedPermissionsResponse\x124\n" + - "\brevision\x18\x01 \x01(\v2\x18.authzed.api.v1.ZedTokenR\brevision\x12\\\n" + - "\x12watched_permission\x18\x02 \x01(\v2-.authzed.api.materialize.v0.WatchedPermissionR\x11watchedPermission\x12:\n" + - "\x05cycle\x18\x03 \x03(\v2$.authzed.api.materialize.v0.ResourceR\x05cycle\"~\n" + + "\brevision\x18\x01 \x01(\v2\x18.authzed.api.v1.ZedTokenR\brevision\x12b\n" + + "\x12watched_permission\x18\x02 \x01(\v23.authzed.api.materialize.v0.BrokenWatchedPermissionR\x11watchedPermission\x12:\n" + + "\x05cycle\x18\x03 \x03(\v2$.authzed.api.materialize.v0.ResourceR\x05cycle\"^\n" + + "\x17BrokenWatchedPermission\x12#\n" + + "\rresource_type\x18\x01 \x01(\tR\fresourceType\x12\x1e\n" + + "\n" + + "permission\x18\x02 \x01(\tR\n" + + "permission\"~\n" + "\bResource\x12\x1f\n" + "\vobject_type\x18\x01 \x01(\tR\n" + "objectType\x12\x1b\n" + @@ -226,19 +285,19 @@ func file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescGZIP() []byt return file_authzed_api_materialize_v0_brokenpermissions_proto_rawDescData } -var file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_authzed_api_materialize_v0_brokenpermissions_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_authzed_api_materialize_v0_brokenpermissions_proto_goTypes = []any{ (*ReadBrokenWatchedPermissionsRequest)(nil), // 0: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsRequest (*ReadBrokenWatchedPermissionsResponse)(nil), // 1: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse - (*Resource)(nil), // 2: authzed.api.materialize.v0.Resource - (*v1.ZedToken)(nil), // 3: authzed.api.v1.ZedToken - (*WatchedPermission)(nil), // 4: authzed.api.materialize.v0.WatchedPermission + (*BrokenWatchedPermission)(nil), // 2: authzed.api.materialize.v0.BrokenWatchedPermission + (*Resource)(nil), // 3: authzed.api.materialize.v0.Resource + (*v1.ZedToken)(nil), // 4: authzed.api.v1.ZedToken } var file_authzed_api_materialize_v0_brokenpermissions_proto_depIdxs = []int32{ - 3, // 0: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsRequest.optional_at_revision:type_name -> authzed.api.v1.ZedToken - 3, // 1: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.revision:type_name -> authzed.api.v1.ZedToken - 4, // 2: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.watched_permission:type_name -> authzed.api.materialize.v0.WatchedPermission - 2, // 3: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.cycle:type_name -> authzed.api.materialize.v0.Resource + 4, // 0: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsRequest.optional_at_revision:type_name -> authzed.api.v1.ZedToken + 4, // 1: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.revision:type_name -> authzed.api.v1.ZedToken + 2, // 2: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.watched_permission:type_name -> authzed.api.materialize.v0.BrokenWatchedPermission + 3, // 3: authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse.cycle:type_name -> authzed.api.materialize.v0.Resource 0, // 4: authzed.api.materialize.v0.BrokenPermissionsService.ReadBrokenWatchedPermissions:input_type -> authzed.api.materialize.v0.ReadBrokenWatchedPermissionsRequest 1, // 5: authzed.api.materialize.v0.BrokenPermissionsService.ReadBrokenWatchedPermissions:output_type -> authzed.api.materialize.v0.ReadBrokenWatchedPermissionsResponse 5, // [5:6] is the sub-list for method output_type @@ -253,14 +312,13 @@ func file_authzed_api_materialize_v0_brokenpermissions_proto_init() { if File_authzed_api_materialize_v0_brokenpermissions_proto != nil { return } - file_authzed_api_materialize_v0_watchpermissions_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_authzed_api_materialize_v0_brokenpermissions_proto_rawDesc), len(file_authzed_api_materialize_v0_brokenpermissions_proto_rawDesc)), NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/authzed/api/materialize/v0/brokenpermissions.pb.validate.go b/proto/authzed/api/materialize/v0/brokenpermissions.pb.validate.go index a8a4947..6fd66af 100644 --- a/proto/authzed/api/materialize/v0/brokenpermissions.pb.validate.go +++ b/proto/authzed/api/materialize/v0/brokenpermissions.pb.validate.go @@ -366,6 +366,112 @@ var _ interface { ErrorName() string } = ReadBrokenWatchedPermissionsResponseValidationError{} +// Validate checks the field values on BrokenWatchedPermission with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *BrokenWatchedPermission) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on BrokenWatchedPermission with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// BrokenWatchedPermissionMultiError, or nil if none found. +func (m *BrokenWatchedPermission) ValidateAll() error { + return m.validate(true) +} + +func (m *BrokenWatchedPermission) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for ResourceType + + // no validation rules for Permission + + if len(errors) > 0 { + return BrokenWatchedPermissionMultiError(errors) + } + + return nil +} + +// BrokenWatchedPermissionMultiError is an error wrapping multiple validation +// errors returned by BrokenWatchedPermission.ValidateAll() if the designated +// constraints aren't met. +type BrokenWatchedPermissionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m BrokenWatchedPermissionMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m BrokenWatchedPermissionMultiError) AllErrors() []error { return m } + +// BrokenWatchedPermissionValidationError is the validation error returned by +// BrokenWatchedPermission.Validate if the designated constraints aren't met. +type BrokenWatchedPermissionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e BrokenWatchedPermissionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e BrokenWatchedPermissionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e BrokenWatchedPermissionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e BrokenWatchedPermissionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e BrokenWatchedPermissionValidationError) ErrorName() string { + return "BrokenWatchedPermissionValidationError" +} + +// Error satisfies the builtin error interface +func (e BrokenWatchedPermissionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sBrokenWatchedPermission.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = BrokenWatchedPermissionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = BrokenWatchedPermissionValidationError{} + // Validate checks the field values on Resource with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. diff --git a/proto/authzed/api/materialize/v0/brokenpermissions_vtproto.pb.go b/proto/authzed/api/materialize/v0/brokenpermissions_vtproto.pb.go index dd94705..e720a4c 100644 --- a/proto/authzed/api/materialize/v0/brokenpermissions_vtproto.pb.go +++ b/proto/authzed/api/materialize/v0/brokenpermissions_vtproto.pb.go @@ -74,6 +74,24 @@ func (m *ReadBrokenWatchedPermissionsResponse) CloneMessageVT() proto.Message { return m.CloneVT() } +func (m *BrokenWatchedPermission) CloneVT() *BrokenWatchedPermission { + if m == nil { + return (*BrokenWatchedPermission)(nil) + } + r := new(BrokenWatchedPermission) + r.ResourceType = m.ResourceType + r.Permission = m.Permission + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *BrokenWatchedPermission) CloneMessageVT() proto.Message { + return m.CloneVT() +} + func (m *Resource) CloneVT() *Resource { if m == nil { return (*Resource)(nil) @@ -159,6 +177,28 @@ func (this *ReadBrokenWatchedPermissionsResponse) EqualMessageVT(thatMsg proto.M } return this.EqualVT(that) } +func (this *BrokenWatchedPermission) EqualVT(that *BrokenWatchedPermission) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.ResourceType != that.ResourceType { + return false + } + if this.Permission != that.Permission { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *BrokenWatchedPermission) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*BrokenWatchedPermission) + if !ok { + return false + } + return this.EqualVT(that) +} func (this *Resource) EqualVT(that *Resource) bool { if this == that { return true @@ -316,6 +356,53 @@ func (m *ReadBrokenWatchedPermissionsResponse) MarshalToSizedBufferVT(dAtA []byt return len(dAtA) - i, nil } +func (m *BrokenWatchedPermission) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BrokenWatchedPermission) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *BrokenWatchedPermission) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Permission) > 0 { + i -= len(m.Permission) + copy(dAtA[i:], m.Permission) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Permission))) + i-- + dAtA[i] = 0x12 + } + if len(m.ResourceType) > 0 { + i -= len(m.ResourceType) + copy(dAtA[i:], m.ResourceType) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Resource) MarshalVT() (dAtA []byte, err error) { if m == nil { return nil, nil @@ -420,6 +507,24 @@ func (m *ReadBrokenWatchedPermissionsResponse) SizeVT() (n int) { return n } +func (m *BrokenWatchedPermission) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ResourceType) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Permission) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + func (m *Resource) SizeVT() (n int) { if m == nil { return 0 @@ -640,7 +745,7 @@ func (m *ReadBrokenWatchedPermissionsResponse) UnmarshalVT(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.WatchedPermission == nil { - m.WatchedPermission = &WatchedPermission{} + m.WatchedPermission = &BrokenWatchedPermission{} } if err := m.WatchedPermission.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { return err @@ -702,6 +807,121 @@ func (m *ReadBrokenWatchedPermissionsResponse) UnmarshalVT(dAtA []byte) error { } return nil } +func (m *BrokenWatchedPermission) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BrokenWatchedPermission: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BrokenWatchedPermission: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Permission = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Resource) UnmarshalVT(dAtA []byte) error { l := len(dAtA) iNdEx := 0