github.com/cloudwan/edgelq-sdk@v1.15.4/limits/resources/v1alpha2/accepted_plan/accepted_plan.pb.access.go (about)

     1  // Code generated by protoc-gen-goten-resource
     2  // Resource: AcceptedPlan
     3  // DO NOT EDIT!!!
     4  
     5  package accepted_plan
     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  	iam_organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/organization"
    21  	iam_project "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/project"
    22  	common "github.com/cloudwan/edgelq-sdk/limits/resources/v1alpha2/common"
    23  	plan "github.com/cloudwan/edgelq-sdk/limits/resources/v1alpha2/plan"
    24  	meta_service "github.com/cloudwan/edgelq-sdk/meta/resources/v1alpha2/service"
    25  	meta "github.com/cloudwan/goten-sdk/types/meta"
    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  	_ = &iam_organization.Organization{}
    43  	_ = &iam_project.Project{}
    44  	_ = &common.Allowance{}
    45  	_ = &plan.Plan{}
    46  	_ = &meta_service.Service{}
    47  	_ = &meta.Meta{}
    48  )
    49  
    50  type AcceptedPlanAccess interface {
    51  	GetAcceptedPlan(context.Context, *GetQuery, ...gotenresource.GetOption) (*AcceptedPlan, error)
    52  	BatchGetAcceptedPlans(context.Context, []*Reference, ...gotenresource.BatchGetOption) error
    53  	QueryAcceptedPlans(context.Context, *ListQuery, ...gotenresource.QueryOption) (*QueryResultSnapshot, error)
    54  	WatchAcceptedPlan(context.Context, *GetQuery, func(*AcceptedPlanChange) error) error
    55  	WatchAcceptedPlans(context.Context, *WatchQuery, func(*QueryResultChange) error) error
    56  	SaveAcceptedPlan(context.Context, *AcceptedPlan, ...gotenresource.SaveOption) error
    57  	DeleteAcceptedPlan(context.Context, *Reference, ...gotenresource.DeleteOption) error
    58  }
    59  
    60  type anyCastAccess struct {
    61  	AcceptedPlanAccess
    62  }
    63  
    64  func AsAnyCastAccess(access AcceptedPlanAccess) gotenresource.Access {
    65  	return &anyCastAccess{AcceptedPlanAccess: access}
    66  }
    67  
    68  func (a *anyCastAccess) Get(ctx context.Context, q gotenresource.GetQuery, opts ...gotenresource.GetOption) (gotenresource.Resource, error) {
    69  	if asAcceptedPlanQuery, ok := q.(*GetQuery); ok {
    70  		return a.GetAcceptedPlan(ctx, asAcceptedPlanQuery, opts...)
    71  	}
    72  	return nil, status.Errorf(codes.Internal,
    73  		"Unrecognized descriptor, expected AcceptedPlan, got: %s",
    74  		q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName())
    75  }
    76  
    77  func (a *anyCastAccess) Query(ctx context.Context, q gotenresource.ListQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) {
    78  	if asAcceptedPlanQuery, ok := q.(*ListQuery); ok {
    79  		return a.QueryAcceptedPlans(ctx, asAcceptedPlanQuery, opts...)
    80  	}
    81  	return nil, status.Errorf(codes.Internal,
    82  		"Unrecognized descriptor, expected AcceptedPlan, got: %s",
    83  		q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName())
    84  }
    85  
    86  func (a *anyCastAccess) Search(ctx context.Context, q gotenresource.SearchQuery, opts ...gotenresource.QueryOption) (gotenresource.QueryResultSnapshot, error) {
    87  	return nil, status.Errorf(codes.Internal, "Search is not available for AcceptedPlan")
    88  }
    89  
    90  func (a *anyCastAccess) Watch(ctx context.Context, q gotenresource.GetQuery, cb func(ch gotenresource.ResourceChange) error) error {
    91  	if asAcceptedPlanQuery, ok := q.(*GetQuery); ok {
    92  		return a.WatchAcceptedPlan(ctx, asAcceptedPlanQuery, func(change *AcceptedPlanChange) error {
    93  			return cb(change)
    94  		})
    95  	}
    96  	return status.Errorf(codes.Internal,
    97  		"Unrecognized descriptor, expected AcceptedPlan, got: %s",
    98  		q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName())
    99  }
   100  
   101  func (a *anyCastAccess) WatchQuery(ctx context.Context, q gotenresource.WatchQuery, cb func(ch gotenresource.QueryResultChange) error) error {
   102  	if asAcceptedPlanQuery, ok := q.(*WatchQuery); ok {
   103  		return a.WatchAcceptedPlans(ctx, asAcceptedPlanQuery, func(change *QueryResultChange) error {
   104  			return cb(change)
   105  		})
   106  	}
   107  	return status.Errorf(codes.Internal,
   108  		"Unrecognized descriptor, expected AcceptedPlan, got: %s",
   109  		q.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName())
   110  }
   111  
   112  func (a *anyCastAccess) Save(ctx context.Context, res gotenresource.Resource, opts ...gotenresource.SaveOption) error {
   113  	if asAcceptedPlanRes, ok := res.(*AcceptedPlan); ok {
   114  		return a.SaveAcceptedPlan(ctx, asAcceptedPlanRes, opts...)
   115  	}
   116  	return status.Errorf(codes.Internal,
   117  		"Unrecognized descriptor, expected AcceptedPlan, got: %s",
   118  		res.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName())
   119  }
   120  
   121  func (a *anyCastAccess) Delete(ctx context.Context, ref gotenresource.Reference, opts ...gotenresource.DeleteOption) error {
   122  	if asAcceptedPlanRef, ok := ref.(*Reference); ok {
   123  		return a.DeleteAcceptedPlan(ctx, asAcceptedPlanRef, opts...)
   124  	}
   125  	return status.Errorf(codes.Internal,
   126  		"Unrecognized descriptor, expected AcceptedPlan, got: %s",
   127  		ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName())
   128  }
   129  
   130  func (a *anyCastAccess) BatchGet(ctx context.Context, toGet []gotenresource.Reference, opts ...gotenresource.BatchGetOption) error {
   131  	acceptedPlanRefs := make([]*Reference, 0, len(toGet))
   132  	for _, ref := range toGet {
   133  		if asAcceptedPlanRef, ok := ref.(*Reference); !ok {
   134  			return status.Errorf(codes.Internal,
   135  				"Unrecognized descriptor, expected AcceptedPlan, got: %s",
   136  				ref.GetResourceDescriptor().GetResourceTypeName().FullyQualifiedTypeName())
   137  		} else {
   138  			acceptedPlanRefs = append(acceptedPlanRefs, asAcceptedPlanRef)
   139  		}
   140  	}
   141  	return a.BatchGetAcceptedPlans(ctx, acceptedPlanRefs, opts...)
   142  }
   143  
   144  func (a *anyCastAccess) GetResourceDescriptors() []gotenresource.Descriptor {
   145  	return []gotenresource.Descriptor{
   146  		GetDescriptor(),
   147  	}
   148  }