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