github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/log_condition/log_condition.pb.access.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: LogCondition 3 // DO NOT EDIT!!! 4 5 package log_condition 6 7 import ( 8 "context" 9 10 "google.golang.org/grpc/codes" 11 "google.golang.org/grpc/status" 12 13 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 14 gotenresource "github.com/cloudwan/goten-sdk/runtime/resource" 15 "github.com/cloudwan/goten-sdk/types/watch_type" 16 ) 17 18 // proto imports 19 import ( 20 rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common" 21 document "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/document" 22 log_condition_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/log_condition_template" 23 policy "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy" 24 meta "github.com/cloudwan/goten-sdk/types/meta" 25 fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 26 ) 27 28 // ensure the imports are used 29 var ( 30 _ = new(context.Context) 31 32 _ = codes.Internal 33 _ = status.Status{} 34 35 _ = watch_type.WatchType_STATEFUL 36 _ = new(gotenobject.FieldPath) 37 _ = new(gotenresource.ListQuery) 38 ) 39 40 // make sure we're using proto imports 41 var ( 42 _ = &document.Document{} 43 _ = &log_condition_template.LogConditionTemplate{} 44 _ = &policy.Policy{} 45 _ = &rcommon.LogCndSpec{} 46 _ = &fieldmaskpb.FieldMask{} 47 _ = &meta.Meta{} 48 ) 49 50 type LogConditionAccess interface { 51 GetLogCondition(context.Context, *GetQuery, ...gotenresource.GetOption) (*LogCondition, error) 52 BatchGetLogConditions(context.Context, []*Reference, ...gotenresource.BatchGetOption) error 53 QueryLogConditions(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 54 SearchLogConditions(context.Context, *SearchQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 55 WatchLogCondition(context.Context, *GetQuery, func(*LogConditionChange) error) error 56 WatchLogConditions(context.Context, *WatchQuery, func(*QueryResultChange) error) error 57 SaveLogCondition(context.Context, *LogCondition, ...gotenresource.SaveOption) error 58 DeleteLogCondition(context.Context, *Reference, ...gotenresource.DeleteOption) error 59 } 60 61 type anyCastAccess struct { 62 LogConditionAccess 63 } 64 65 func AsAnyCastAccess(access LogConditionAccess) gotenresource.Access { 66 return &anyCastAccess{LogConditionAccess: access} 67 } 68 69 func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) { 70 if asLogConditionQuery, ok := q.(*GetQuery); ok { 71 return a.GetLogCondition(ctx, asLogConditionQuery, opts...) 72 } 73 return nil, status.Errorf(codes.Internal, 74 "Unrecognized descriptor, expected LogCondition, got: %s", 75 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 76 } 77 78 func (a *anyCastAccess) Query(ctx context.Context, q gotenresource.ListQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 79 if asLogConditionQuery, ok := q.(*ListQuery); ok { 80 return a.QueryLogConditions(ctx, asLogConditionQuery, opts...) 81 } 82 return nil, status.Errorf(codes.Internal, 83 "Unrecognized descriptor, expected LogCondition, got: %s", 84 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 85 } 86 87 func (a *anyCastAccess) Search(ctx context.Context, q gotenresource.SearchQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 88 if asLogConditionQuery, ok := q.(*SearchQuery); ok { 89 return a.SearchLogConditions(ctx, asLogConditionQuery, opts...) 90 } 91 return nil, status.Errorf(codes.Internal, 92 "Unrecognized descriptor, expected LogCondition, got: %s", 93 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 94 } 95 96 func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error { 97 if asLogConditionQuery, ok := q.(*GetQuery); ok { 98 return a.WatchLogCondition(ctx, asLogConditionQuery, func(change *LogConditionChange) error { 99 return cb(change) 100 }) 101 } 102 return status.Errorf(codes.Internal, 103 "Unrecognized descriptor, expected LogCondition, got: %s", 104 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 105 } 106 107 func (a *anyCastAccess) WatchQuery(ctx context.Context, q gotenresource.WatchQuery, cb func(ch gotenresource.QueryResultChange) error) error { 108 if asLogConditionQuery, ok := q.(*WatchQuery); ok { 109 return a.WatchLogConditions(ctx, asLogConditionQuery, func(change *QueryResultChange) error { 110 return cb(change) 111 }) 112 } 113 return status.Errorf(codes.Internal, 114 "Unrecognized descriptor, expected LogCondition, got: %s", 115 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 116 } 117 118 func (a *anyCastAccess) Save(ctx context.Context, res gotenresource.Resource, opts ...gotenresource.SaveOption) error { 119 if asLogConditionRes, ok := res.(*LogCondition); ok { 120 return a.SaveLogCondition(ctx, asLogConditionRes, opts...) 121 } 122 return status.Errorf(codes.Internal, 123 "Unrecognized descriptor, expected LogCondition, got: %s", 124 res.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 125 } 126 127 func (a *anyCastAccess) Delete(ctx context.Context, ref gotenresource.Reference, opts ...gotenresource.DeleteOption) error { 128 if asLogConditionRef, ok := ref.(*Reference); ok { 129 return a.DeleteLogCondition(ctx, asLogConditionRef, opts...) 130 } 131 return status.Errorf(codes.Internal, 132 "Unrecognized descriptor, expected LogCondition, got: %s", 133 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 134 } 135 136 func (a *anyCastAccess) BatchGet(ctx context.Context, toGet []gotenresource.Reference, opts ...gotenresource.BatchGetOption) error { 137 logConditionRefs := make([]*Reference, 0, len(toGet)) 138 for _, ref := range toGet { 139 if asLogConditionRef, ok := ref.(*Reference); !ok { 140 return status.Errorf(codes.Internal, 141 "Unrecognized descriptor, expected LogCondition, got: %s", 142 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 143 } else { 144 logConditionRefs = append(logConditionRefs, asLogConditionRef) 145 } 146 } 147 return a.BatchGetLogConditions(ctx, logConditionRefs, opts...) 148 } 149 150 func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor { 151 return []gotenresource.Descriptor{ 152 GetDescriptor(), 153 } 154 }