github.com/cloudwan/edgelq-sdk@v1.15.4/monitoring/resources/v4/notification_channel/notification_channel.pb.access.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: NotificationChannel 3 // DO NOT EDIT!!! 4 5 package notification_channel 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 project "github.com/cloudwan/edgelq-sdk/monitoring/resources/v4/project" 21 meta "github.com/cloudwan/goten-sdk/types/meta" 22 fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 23 timestamppb "google.golang.org/protobuf/types/known/timestamppb" 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 _ = &project.Project{} 41 _ = &fieldmaskpb.FieldMask{} 42 _ = ×tamppb.Timestamp{} 43 _ = &meta.Meta{} 44 ) 45 46 type NotificationChannelAccess interface { 47 GetNotificationChannel(context.Context, *GetQuery, ...gotenresource.GetOption) (*NotificationChannel, error) 48 BatchGetNotificationChannels(context.Context, []*Reference, ...gotenresource.BatchGetOption) error 49 QueryNotificationChannels(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 50 WatchNotificationChannel(context.Context, *GetQuery, func(*NotificationChannelChange) error) error 51 WatchNotificationChannels(context.Context, *WatchQuery, func(*QueryResultChange) error) error 52 SaveNotificationChannel(context.Context, *NotificationChannel, ...gotenresource.SaveOption) error 53 DeleteNotificationChannel(context.Context, *Reference, ...gotenresource.DeleteOption) error 54 } 55 56 type anyCastAccess struct { 57 NotificationChannelAccess 58 } 59 60 func AsAnyCastAccess(access NotificationChannelAccess) gotenresource.Access { 61 return &anyCastAccess{NotificationChannelAccess: access} 62 } 63 64 func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) { 65 if asNotificationChannelQuery, ok := q.(*GetQuery); ok { 66 return a.GetNotificationChannel(ctx, asNotificationChannelQuery, opts...) 67 } 68 return nil, status.Errorf(codes.Internal, 69 "Unrecognized descriptor, expected NotificationChannel, got: %s", 70 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 71 } 72 73 func (a *anyCastAccess) Query(ctx context.Context, q gotenresource.ListQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 74 if asNotificationChannelQuery, ok := q.(*ListQuery); ok { 75 return a.QueryNotificationChannels(ctx, asNotificationChannelQuery, opts...) 76 } 77 return nil, status.Errorf(codes.Internal, 78 "Unrecognized descriptor, expected NotificationChannel, got: %s", 79 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 80 } 81 82 func (a *anyCastAccess) Search(ctx context.Context, q gotenresource.SearchQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) { 83 return nil, status.Errorf(codes.Internal, "Search is not available for NotificationChannel") 84 } 85 86 func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error { 87 if asNotificationChannelQuery, ok := q.(*GetQuery); ok { 88 return a.WatchNotificationChannel(ctx, asNotificationChannelQuery, func(change *NotificationChannelChange) error { 89 return cb(change) 90 }) 91 } 92 return status.Errorf(codes.Internal, 93 "Unrecognized descriptor, expected NotificationChannel, got: %s", 94 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 95 } 96 97 func (a *anyCastAccess) WatchQuery(ctx context.Context, q gotenresource.WatchQuery, cb func(ch gotenresource.QueryResultChange) error) error { 98 if asNotificationChannelQuery, ok := q.(*WatchQuery); ok { 99 return a.WatchNotificationChannels(ctx, asNotificationChannelQuery, func(change *QueryResultChange) error { 100 return cb(change) 101 }) 102 } 103 return status.Errorf(codes.Internal, 104 "Unrecognized descriptor, expected NotificationChannel, got: %s", 105 q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 106 } 107 108 func (a *anyCastAccess) Save(ctx context.Context, res gotenresource.Resource, opts ...gotenresource.SaveOption) error { 109 if asNotificationChannelRes, ok := res.(*NotificationChannel); ok { 110 return a.SaveNotificationChannel(ctx, asNotificationChannelRes, opts...) 111 } 112 return status.Errorf(codes.Internal, 113 "Unrecognized descriptor, expected NotificationChannel, got: %s", 114 res.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 115 } 116 117 func (a *anyCastAccess) Delete(ctx context.Context, ref gotenresource.Reference, opts ...gotenresource.DeleteOption) error { 118 if asNotificationChannelRef, ok := ref.(*Reference); ok { 119 return a.DeleteNotificationChannel(ctx, asNotificationChannelRef, opts...) 120 } 121 return status.Errorf(codes.Internal, 122 "Unrecognized descriptor, expected NotificationChannel, got: %s", 123 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 124 } 125 126 func (a *anyCastAccess) BatchGet(ctx context.Context, toGet []gotenresource.Reference, opts ...gotenresource.BatchGetOption) error { 127 notificationChannelRefs := make([]*Reference, 0, len(toGet)) 128 for _, ref := range toGet { 129 if asNotificationChannelRef, ok := ref.(*Reference); !ok { 130 return status.Errorf(codes.Internal, 131 "Unrecognized descriptor, expected NotificationChannel, got: %s", 132 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 133 } else { 134 notificationChannelRefs = append(notificationChannelRefs, asNotificationChannelRef) 135 } 136 } 137 return a.BatchGetNotificationChannels(ctx, notificationChannelRefs, opts...) 138 } 139 140 func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor { 141 return []gotenresource.Descriptor{ 142 GetDescriptor(), 143 } 144 }