github.com/cloudwan/edgelq-sdk@v1.15.4/devices/resources/v1alpha2/os_version/os_version.pb.access.go (about) 1 // Code generated by protoc-gen-goten-resource 2 // Resource: OsVersion 3 // DO NOT EDIT!!! 4 5 package os_version 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 device_type "github.com/cloudwan/edgelq-sdk/devices/resources/v1alpha2/device_type" 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 _ = &device_type.DeviceType{} 39 _ = &meta.Meta{} 40 ) 41 42 type OsVersionAccess interface { 43 GetOsVersion(context.Context, *GetQuery, ...gotenresource.GetOption) (*OsVersion, error) 44 BatchGetOsVersions(context.Context, []*Reference, ...gotenresource.BatchGetOption) error 45 QueryOsVersions(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error) 46 WatchOsVersion(context.Context, *GetQuery, func(*OsVersionChange) error) error 47 WatchOsVersions(context.Context, *WatchQuery, func(*QueryResultChange) error) error 48 SaveOsVersion(context.Context, *OsVersion, ...gotenresource.SaveOption) error 49 DeleteOsVersion(context.Context, *Reference, ...gotenresource.DeleteOption) error 50 } 51 52 type anyCastAccess struct { 53 OsVersionAccess 54 } 55 56 func AsAnyCastAccess(access OsVersionAccess) gotenresource.Access { 57 return &anyCastAccess{OsVersionAccess: access} 58 } 59 60 func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) { 61 if asOsVersionQuery, ok := q.(*GetQuery); ok { 62 return a.GetOsVersion(ctx, asOsVersionQuery, opts...) 63 } 64 return nil, status.Errorf(codes.Internal, 65 "Unrecognized descriptor, expected OsVersion, 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 asOsVersionQuery, ok := q.(*ListQuery); ok { 71 return a.QueryOsVersions(ctx, asOsVersionQuery, opts...) 72 } 73 return nil, status.Errorf(codes.Internal, 74 "Unrecognized descriptor, expected OsVersion, 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 OsVersion") 80 } 81 82 func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error { 83 if asOsVersionQuery, ok := q.(*GetQuery); ok { 84 return a.WatchOsVersion(ctx, asOsVersionQuery, func(change *OsVersionChange) error { 85 return cb(change) 86 }) 87 } 88 return status.Errorf(codes.Internal, 89 "Unrecognized descriptor, expected OsVersion, 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 asOsVersionQuery, ok := q.(*WatchQuery); ok { 95 return a.WatchOsVersions(ctx, asOsVersionQuery, func(change *QueryResultChange) error { 96 return cb(change) 97 }) 98 } 99 return status.Errorf(codes.Internal, 100 "Unrecognized descriptor, expected OsVersion, 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 asOsVersionRes, ok := res.(*OsVersion); ok { 106 return a.SaveOsVersion(ctx, asOsVersionRes, opts...) 107 } 108 return status.Errorf(codes.Internal, 109 "Unrecognized descriptor, expected OsVersion, 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 asOsVersionRef, ok := ref.(*Reference); ok { 115 return a.DeleteOsVersion(ctx, asOsVersionRef, opts...) 116 } 117 return status.Errorf(codes.Internal, 118 "Unrecognized descriptor, expected OsVersion, 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 osVersionRefs := make([]*Reference, 0, len(toGet)) 124 for _, ref := range toGet { 125 if asOsVersionRef, ok := ref.(*Reference); !ok { 126 return status.Errorf(codes.Internal, 127 "Unrecognized descriptor, expected OsVersion, got: %s", 128 ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName()) 129 } else { 130 osVersionRefs = append(osVersionRefs, asOsVersionRef) 131 } 132 } 133 return a.BatchGetOsVersions(ctx, osVersionRefs, opts...) 134 } 135 136 func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor { 137 return []gotenresource.Descriptor{ 138 GetDescriptor(), 139 } 140 }