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