Skip to content

Commit

Permalink
feat(grant): add restore grant API
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmatrhd committed Feb 16, 2024
1 parent 607e725 commit 63865f6
Show file tree
Hide file tree
Showing 47 changed files with 2,798 additions and 1,815 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COMMIT := $(shell git rev-parse --short HEAD)
TAG := "$(shell git rev-list --tags --max-count=1)"
VERSION := "$(shell git describe --tags ${TAG})-next"
BUILD_DIR=dist
PROTON_COMMIT := "1c64ba440874a73eddba40c77c79ff30a11347de"
PROTON_COMMIT := "d30147a7ca98e51e3d0da2a6379f0db09e22ebfb"

.PHONY: all build clean test tidy vet proto setup format generate

Expand Down
16 changes: 16 additions & 0 deletions api/handler/v1beta1/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,22 @@ func (s *GRPCServer) RevokeGrants(ctx context.Context, req *guardianv1beta1.Revo
}, nil
}

func (s *GRPCServer) RestoreGrant(ctx context.Context, req *guardianv1beta1.RestoreGrantRequest) (*guardianv1beta1.RestoreGrantResponse, error) {
g, err := s.grantService.Restore(ctx, req.GetId())
if err != nil {
return nil, s.internalError(ctx, "failed to restore grant: %v", err)
}

grantProto, err := s.adapter.ToGrantProto(g)
if err != nil {
return nil, s.internalError(ctx, "failed to parse grant: %v", err)
}

return &guardianv1beta1.RestoreGrantResponse{
Grant: grantProto,
}, nil
}

func (s *GRPCServer) listGrants(ctx context.Context, filter domain.ListGrantsFilter) ([]*guardianv1beta1.Grant, int64, error) {
eg, ctx := errgroup.WithContext(ctx)
var grants []domain.Grant
Expand Down
1 change: 1 addition & 0 deletions api/handler/v1beta1/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type grantService interface {
List(context.Context, domain.ListGrantsFilter) ([]domain.Grant, error)
GetByID(context.Context, string) (*domain.Grant, error)
Update(context.Context, *domain.Grant) error
Restore(ctx context.Context, id string) (*domain.Grant, error)
Revoke(ctx context.Context, id, actor, reason string, opts ...grant.Option) (*domain.Grant, error)
BulkRevoke(ctx context.Context, filter domain.RevokeGrantsFilter, actor, reason string) ([]*domain.Grant, error)
ImportFromProvider(ctx context.Context, criteria grant.ImportFromProviderCriteria) ([]*domain.Grant, error)
Expand Down
11 changes: 6 additions & 5 deletions api/handler/v1beta1/mocks/activityService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions api/handler/v1beta1/mocks/appealService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions api/handler/v1beta1/mocks/approvalService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 61 additions & 5 deletions api/handler/v1beta1/mocks/grantService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions api/handler/v1beta1/mocks/policyService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions api/handler/v1beta1/mocks/providerService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions api/handler/v1beta1/mocks/resourceService.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 63865f6

Please sign in to comment.