github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/ts_condition/ts_condition.pb.access.go (about)

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