Documentation ¶
Index ¶
- Constants
- type ApprovalReqType
- type Controller
- type Permit
- type Service
- func (s Service) CreatePermit(ctx context.Context, req *pb.CreatePermitRequest) (*pb.CreatePermitResponse, error)
- func (s Service) GetPermitByFileID(ctx context.Context, req *pb.GetPermitByFileIDRequest) (*pb.GetPermitByFileIDResponse, error)
- func (s Service) HasPermit(ctx context.Context, req *pb.HasPermitRequest) (*pb.HasPermitResponse, error)
- func (s *Service) HealthCheck(mongoClientPingTimeout time.Duration) bool
- func (s Service) UpdatePermitStatus(ctx context.Context, req *pb.UpdatePermitStatusRequest) (*pb.UpdatePermitStatusResponse, error)
- type Store
- type UserType
Constants ¶
const (
// StatusPending is the status of a pending request
StatusPending = "pending"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalReqType ¶
type ApprovalReqType struct { ID string `json:"id"` From string `json:"from"` Approvers []string `json:"approvers"` To []UserType `json:"to"` FileID string `json:"fileId"` FileName string `json:"fileName"` Info string `json:"info"` Classification string `json:"classification"` }
ApprovalReqType is the struct sent as json to the approval service
type Controller ¶
type Controller interface { CreatePermit(ctx context.Context, reqID string, fileID string, userID string, status string) (Permit, error) GetPermitsByFileID(ctx context.Context, fileID string) ([]*pb.UserStatus, error) HasPermit(ctx context.Context, fileID string, userID string) (bool, error) UpdatePermitStatus(ctx context.Context, reqID string, status string) (bool, error) HealthCheck(ctx context.Context) (bool, error) }
Controller is an interface for the business logic of the permit.Service which uses a Store.
type Permit ¶
type Permit interface { GetID() string SetID(id string) error GetReqID() string SetReqID(reqID string) error GetFileID() string SetFileID(fileID string) error GetUserID() string SetUserID(userID string) error GetStatus() string SetStatus(status string) error MarshalProto(permit *pb.PermitObject) error }
Permit is an interface of a permit object.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the structure used for handling
func NewService ¶
func NewService(controller Controller, logger *logrus.Logger, spikeConn *grpc.ClientConn, grantType string, audience string, approvalURL string) Service
NewService creates a Service and returns it.
func (Service) CreatePermit ¶
func (s Service) CreatePermit(ctx context.Context, req *pb.CreatePermitRequest) (*pb.CreatePermitResponse, error)
CreatePermit is the request handler for creating a permit of a file to user.
func (Service) GetPermitByFileID ¶
func (s Service) GetPermitByFileID(ctx context.Context, req *pb.GetPermitByFileIDRequest) (*pb.GetPermitByFileIDResponse, error)
GetPermitByFileID is the request handler for getting a permit (user, status) by file id.
func (Service) HasPermit ¶
func (s Service) HasPermit(ctx context.Context, req *pb.HasPermitRequest) (*pb.HasPermitResponse, error)
HasPermit is the request handler for checking if a permit exists for fileID and userID.
func (*Service) HealthCheck ¶
HealthCheck checks the health of the service, and returns a boolean accordingly.
func (Service) UpdatePermitStatus ¶
func (s Service) UpdatePermitStatus(ctx context.Context, req *pb.UpdatePermitStatusRequest) (*pb.UpdatePermitStatusResponse, error)
UpdatePermitStatus is the request handler for updating the status of a given permit.
type Store ¶
type Store interface { Create(ctx context.Context, permit Permit) (Permit, error) Get(ctx context.Context, filter interface{}) (Permit, error) GetAll(ctx context.Context, filter interface{}) ([]Permit, error) Delete(ctx context.Context, filter interface{}) (Permit, error) HealthCheck(ctx context.Context) (bool, error) }
Store is an interface for handling the storing of permissions.