2023-02-15 01:52:11 +00:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
|
|
|
"github.com/zitadel/zitadel/pkg/grpc/system"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) AddQuota(ctx context.Context, req *system.AddQuotaRequest) (*system.AddQuotaResponse, error) {
|
|
|
|
details, err := s.command.AddQuota(
|
|
|
|
ctx,
|
|
|
|
instanceQuotaPbToCommand(req),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-09-22 09:37:16 +00:00
|
|
|
return &system.AddQuotaResponse{
|
|
|
|
Details: object.AddToDetailsPb(details.Sequence, details.EventDate, details.ResourceOwner),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) SetQuota(ctx context.Context, req *system.SetQuotaRequest) (*system.SetQuotaResponse, error) {
|
|
|
|
details, err := s.command.SetQuota(
|
|
|
|
ctx,
|
|
|
|
instanceQuotaPbToCommand(req),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &system.SetQuotaResponse{
|
2023-02-15 01:52:11 +00:00
|
|
|
Details: object.AddToDetailsPb(details.Sequence, details.EventDate, details.ResourceOwner),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RemoveQuota(ctx context.Context, req *system.RemoveQuotaRequest) (*system.RemoveQuotaResponse, error) {
|
|
|
|
details, err := s.command.RemoveQuota(ctx, instanceQuotaUnitPbToCommand(req.Unit))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-09-22 09:37:16 +00:00
|
|
|
return &system.RemoveQuotaResponse{
|
2023-02-15 01:52:11 +00:00
|
|
|
Details: object.ChangeToDetailsPb(details.Sequence, details.EventDate, details.ResourceOwner),
|
|
|
|
}, nil
|
|
|
|
}
|