github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/log_condition_template/log_condition_template.pb.access.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: LogConditionTemplate 3 // DO NOT EDIT!!! 4 5 package log_condition_template 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 policy_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy_template" 23 meta "github.com/cloudwan/goten-sdk/types/meta" 24 ) 25 26 // ensure the imports are used 27 var ( 28 _ = new(context.Context) 29 30 _ = codes.Internal 31 _ = status.Status{} 32 33 _ = watch_type.WatchType_STATEFUL 34 _ = new(gotenobject.FieldPath) 35 _ = new(gotenresource.ListQuery) 36 ) 37 38 // make sure we're using proto imports 39 var ( 40 _ = &document.Document{} 41 _ = &policy_template.PolicyTemplate{} 42 _ = &rcommon.LogCndSpec{} 43 _ = &meta.Meta{} 44 ) 45 46 type LogConditionTemplateAccess interface { 47 GetLogConditionTemplate(context.Context, *GetQuery, ...gotenresource.GetOption) (*LogConditionTemplate, error) 48 BatchGetLogConditionTemplates(context.Context, []*Reference, ...gotenresource.BatchGetOption) error 49 QueryLogConditionTemplates(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 50 SearchLogConditionTemplates(context.Context, *SearchQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 51 WatchLogConditionTemplate(context.Context, *GetQuery, func(*LogConditionTemplateChange) error) error 52 WatchLogConditionTemplates(context.Context, *WatchQuery, func(*QueryResultChange) error) error 53 SaveLogConditionTemplate(context.Context, *LogConditionTemplate, ...gotenresource.SaveOption) error 54 DeleteLogConditionTemplate(context.Context, *Reference, ...gotenresource.DeleteOption) error 55 } 56 57 type anyCastAccess struct { 58 LogConditionTemplateAccess 59 } 60 61 func AsAnyCastAccess(access LogConditionTemplateAccess) gotenresource.Access { 62 return &anyCastAccess{LogConditionTemplateAccess: access} 63 } 64 65 func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) { 66 if asLogConditionTemplateQuery, ok := q.(*GetQuery); ok { 67 return a.GetLogConditionTemplate(ctx, asLogConditionTemplateQuery, opts...) 68 } 69 return nil, status.Errorf(codes.Internal, 70 "Unrecognized descriptor, expected LogConditionTemplate, got: %s", 71 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 72 } 73 74 func (a *anyCastAccess) Query(ctx context.Context, q gotenresource.ListQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 75 if asLogConditionTemplateQuery, ok := q.(*ListQuery); ok { 76 return a.QueryLogConditionTemplates(ctx, asLogConditionTemplateQuery, opts...) 77 } 78 return nil, status.Errorf(codes.Internal, 79 "Unrecognized descriptor, expected LogConditionTemplate, got: %s", 80 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 81 } 82 83 func (a *anyCastAccess) Search(ctx context.Context, q gotenresource.SearchQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 84 if asLogConditionTemplateQuery, ok := q.(*SearchQuery); ok { 85 return a.SearchLogConditionTemplates(ctx, asLogConditionTemplateQuery, opts...) 86 } 87 return nil, status.Errorf(codes.Internal, 88 "Unrecognized descriptor, expected LogConditionTemplate, got: %s", 89 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 90 } 91 92 func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error { 93 if asLogConditionTemplateQuery, ok := q.(*GetQuery); ok { 94 return a.WatchLogConditionTemplate(ctx, asLogConditionTemplateQuery, func(change *LogConditionTemplateChange) error { 95 return cb(change) 96 }) 97 } 98 return status.Errorf(codes.Internal, 99 "Unrecognized descriptor, expected LogConditionTemplate, got: %s", 100 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 101 } 102 103 func (a *anyCastAccess) WatchQuery(ctx context.Context, q gotenresource.WatchQuery, cb func(ch gotenresource.QueryResultChange) error) error { 104 if asLogConditionTemplateQuery, ok := q.(*WatchQuery); ok { 105 return a.WatchLogConditionTemplates(ctx, asLogConditionTemplateQuery, func(change *QueryResultChange) error { 106 return cb(change) 107 }) 108 } 109 return status.Errorf(codes.Internal, 110 "Unrecognized descriptor, expected LogConditionTemplate, got: %s", 111 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 112 } 113 114 func (a *anyCastAccess) Save(ctx context.Context, res gotenresource.Resource, opts ...gotenresource.SaveOption) error { 115 if asLogConditionTemplateRes, ok := res.(*LogConditionTemplate); ok { 116 return a.SaveLogConditionTemplate(ctx, asLogConditionTemplateRes, opts...) 117 } 118 return status.Errorf(codes.Internal, 119 "Unrecognized descriptor, expected LogConditionTemplate, got: %s", 120 res.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 121 } 122 123 func (a *anyCastAccess) Delete(ctx context.Context, ref gotenresource.Reference, opts ...gotenresource.DeleteOption) error { 124 if asLogConditionTemplateRef, ok := ref.(*Reference); ok { 125 return a.DeleteLogConditionTemplate(ctx, asLogConditionTemplateRef, opts...) 126 } 127 return status.Errorf(codes.Internal, 128 "Unrecognized descriptor, expected LogConditionTemplate, got: %s", 129 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 130 } 131 132 func (a *anyCastAccess) BatchGet(ctx context.Context, toGet []gotenresource.Reference, opts ...gotenresource.BatchGetOption) error { 133 logConditionTemplateRefs := make([]*Reference, 0, len(toGet)) 134 for _, ref := range toGet { 135 if asLogConditionTemplateRef, ok := ref.(*Reference); !ok { 136 return status.Errorf(codes.Internal, 137 "Unrecognized descriptor, expected LogConditionTemplate, got: %s", 138 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 139 } else { 140 logConditionTemplateRefs = append(logConditionTemplateRefs, asLogConditionTemplateRef) 141 } 142 } 143 return a.BatchGetLogConditionTemplates(ctx, logConditionTemplateRefs, opts...) 144 } 145 146 func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor { 147 return []gotenresource.Descriptor{ 148 GetDescriptor(), 149 } 150 }