mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-04 18:08:50 +00:00
feat: instance domain APIs with relational tables (#11051)
# Which Problems Are Solved This PR implements the endpoints listed in https://github.com/zitadel/zitadel/issues/10444 . # How the Problems Are Solved The implementation follows the same pattern as the Instance one. The `Add` and `Remove` are implementing the `Commander` interface, while `List` Domains endpoints are implementing the `Querier` interace. The PR adds also some forgotten calls to the relational logic for the Instance API. The commits are identifiable by the label `instance:` prepended to them. This is the complete list: bafce01b0 , 6fe7257ab , e27bc9c34 , 8133ede73 , fde667953 , a3e1135ed , ee1a6f9c1 # Additional Context - Closes #10444 --------- Co-authored-by: Elio Bischof <[email protected]> Co-authored-by: Lebogang Phoshoko <[email protected]> Co-authored-by: Wim Van Laer <[email protected]> Co-authored-by: Max Peintner <[email protected]> Co-authored-by: Gayathri Vijayan <[email protected]>
This commit is contained in:
co-authored by
Elio Bischof
Lebogang Phoshoko
Wim Van Laer
Max Peintner
Gayathri Vijayan
parent
d79bfe6eba
commit
b339a3e696
@@ -2,6 +2,7 @@ package domain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/zitadel/zitadel/backend/v3/storage/database"
|
||||
@@ -29,7 +30,10 @@ func (g *GetInstanceQuery) Execute(ctx context.Context, opts *InvokeOpts) (err e
|
||||
|
||||
instance, err := instanceRepo.Get(ctx, opts.DB(), database.WithCondition(instanceRepo.IDCondition(g.ID)))
|
||||
if err != nil {
|
||||
return err
|
||||
if errors.Is(err, &database.NoRowFoundError{}) {
|
||||
return zerrors.ThrowNotFound(err, "DOM-QVrUwc", "Errors.Instance.NotFound")
|
||||
}
|
||||
return zerrors.ThrowInternal(err, "DOM-lvsRce", "Errors.Instance.Get")
|
||||
}
|
||||
|
||||
g.returnedInstance = instance
|
||||
@@ -45,14 +49,14 @@ func (g *GetInstanceQuery) String() string {
|
||||
func (g *GetInstanceQuery) Validate(ctx context.Context, opts *InvokeOpts) (err error) {
|
||||
g.ID = strings.TrimSpace(g.ID)
|
||||
if g.ID == "" {
|
||||
return zerrors.ThrowInvalidArgument(nil, "DOM-32a0o2", "invalid instance ID")
|
||||
return zerrors.ThrowInvalidArgument(nil, "DOM-32a0o2", "Errors.Instance.ID")
|
||||
}
|
||||
if g.ID != authz.GetInstance(ctx).InstanceID() {
|
||||
return zerrors.ThrowPermissionDenied(nil, "DOM-n0SvVB", "input instance ID doesn't match context instance")
|
||||
}
|
||||
|
||||
if authZErr := opts.Permissions.CheckInstancePermission(ctx, InstanceReadPermission); authZErr != nil {
|
||||
return zerrors.ThrowPermissionDenied(authZErr, "DOM-Uq6b00", "permission denied")
|
||||
return zerrors.ThrowPermissionDenied(authZErr, "DOM-Uq6b00", "Errors.PermissionDenied")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user