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