Don't return an empty resource if there was an apiErr (#294)
This commit is contained in:
1 parent
b24fc185a7
commit
627a353ccb
11 files changed
+198
-66
No files matched your search
@@ -58,7 +58,9 @@ func (c *AccountsClient) Create(ctx context.Context, authMethodId string, opt ..
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -92,7 +94,9 @@ func (c *AccountsClient) Read(ctx context.Context, authMethodId string, accountI
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -143,7 +147,9 @@ func (c *AccountsClient) Update(ctx context.Context, authMethodId string, accoun
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -180,7 +186,9 @@ func (c *AccountsClient) Delete(ctx context.Context, authMethodId string, accoun
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -213,6 +221,8 @@ func (c *AccountsClient) List(ctx context.Context, authMethodId string, opt ...O
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
@@ -59,7 +59,9 @@ func (c *AuthMethodsClient) Create(ctx context.Context, resourceType string, opt
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -89,7 +91,9 @@ func (c *AuthMethodsClient) Read(ctx context.Context, authMethodId string, opt .
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -137,7 +141,9 @@ func (c *AuthMethodsClient) Update(ctx context.Context, authMethodId string, ver
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -170,7 +176,9 @@ func (c *AuthMethodsClient) Delete(ctx context.Context, authMethodId string, opt
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -199,6 +207,8 @@ func (c *AuthMethodsClient) List(ctx context.Context, opt ...Option) ([]*AuthMet
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
@@ -56,7 +56,9 @@ func (c *AuthTokensClient) Read(ctx context.Context, authTokenId string, opt ...
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -89,7 +91,9 @@ func (c *AuthTokensClient) Delete(ctx context.Context, authTokenId string, opt .
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -118,6 +122,8 @@ func (c *AuthTokensClient) List(ctx context.Context, opt ...Option) ([]*AuthToke
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
+24
-8
@@ -54,7 +54,9 @@ func (c *GroupsClient) Create(ctx context.Context, opt ...Option) (*Group, *api.
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -84,7 +86,9 @@ func (c *GroupsClient) Read(ctx context.Context, groupId string, opt ...Option)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -132,7 +136,9 @@ func (c *GroupsClient) Update(ctx context.Context, groupId string, version uint3
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -165,7 +171,9 @@ func (c *GroupsClient) Delete(ctx context.Context, groupId string, opt ...Option
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -194,7 +202,9 @@ func (c *GroupsClient) List(ctx context.Context, opt ...Option) ([]*Group, *api.
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -246,7 +256,9 @@ func (c *GroupsClient) AddMembers(ctx context.Context, groupId string, version u
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding AddMembers response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -301,7 +313,9 @@ func (c *GroupsClient) SetMembers(ctx context.Context, groupId string, version u
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding SetMembers response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -353,6 +367,8 @@ func (c *GroupsClient) RemoveMembers(ctx context.Context, groupId string, versio
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding RemoveMembers response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
+15
-5
@@ -59,7 +59,9 @@ func (c *HostsClient) Create(ctx context.Context, hostCatalogId string, opt ...O
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -93,7 +95,9 @@ func (c *HostsClient) Read(ctx context.Context, hostCatalogId string, hostId str
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -144,7 +148,9 @@ func (c *HostsClient) Update(ctx context.Context, hostCatalogId string, hostId s
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -181,7 +187,9 @@ func (c *HostsClient) Delete(ctx context.Context, hostCatalogId string, hostId s
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -214,6 +222,8 @@ func (c *HostsClient) List(ctx context.Context, hostCatalogId string, opt ...Opt
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
@@ -59,7 +59,9 @@ func (c *HostCatalogsClient) Create(ctx context.Context, resourceType string, op
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -89,7 +91,9 @@ func (c *HostCatalogsClient) Read(ctx context.Context, hostCatalogId string, opt
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -137,7 +141,9 @@ func (c *HostCatalogsClient) Update(ctx context.Context, hostCatalogId string, v
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -170,7 +176,9 @@ func (c *HostCatalogsClient) Delete(ctx context.Context, hostCatalogId string, o
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -199,6 +207,8 @@ func (c *HostCatalogsClient) List(ctx context.Context, opt ...Option) ([]*HostCa
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
@@ -58,7 +58,9 @@ func (c *HostSetsClient) Create(ctx context.Context, hostCatalogId string, opt .
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -92,7 +94,9 @@ func (c *HostSetsClient) Read(ctx context.Context, hostCatalogId string, hostSet
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -143,7 +147,9 @@ func (c *HostSetsClient) Update(ctx context.Context, hostCatalogId string, hostS
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -180,7 +186,9 @@ func (c *HostSetsClient) Delete(ctx context.Context, hostCatalogId string, hostS
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -213,7 +221,9 @@ func (c *HostSetsClient) List(ctx context.Context, hostCatalogId string, opt ...
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -268,7 +278,9 @@ func (c *HostSetsClient) AddHosts(ctx context.Context, hostCatalogId string, hos
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding AddHosts response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -326,7 +338,9 @@ func (c *HostSetsClient) SetHosts(ctx context.Context, hostCatalogId string, hos
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding SetHosts response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -381,6 +395,8 @@ func (c *HostSetsClient) RemoveHosts(ctx context.Context, hostCatalogId string,
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding RemoveHosts response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
@@ -221,7 +221,9 @@ func (c *{{ .ClientName }}Client) List(ctx context.Context, {{ range .Collection
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
`))
|
||||
@@ -253,7 +255,9 @@ func (c *{{ .ClientName }}Client) Read(ctx context.Context, {{ range .ResourceFu
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
`))
|
||||
@@ -288,7 +292,9 @@ func (c *{{ .ClientName }}Client) Delete(ctx context.Context, {{ range .Resource
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
`))
|
||||
@@ -328,7 +334,9 @@ func (c *{{ .ClientName }}Client) Create(ctx context.Context, {{ if .TypeOnCreat
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
`))
|
||||
@@ -380,7 +388,9 @@ func (c *{{ .ClientName }}Client) Update(ctx context.Context, {{ range .Resource
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
`))
|
||||
@@ -452,7 +462,9 @@ func (c *{{ $input.ClientName }}Client) {{ $fullName }}(ctx context.Context, {{
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding {{ $fullName }} response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
+33
-11
@@ -57,7 +57,9 @@ func (c *RolesClient) Create(ctx context.Context, opt ...Option) (*Role, *api.Er
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -87,7 +89,9 @@ func (c *RolesClient) Read(ctx context.Context, roleId string, opt ...Option) (*
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -135,7 +139,9 @@ func (c *RolesClient) Update(ctx context.Context, roleId string, version uint32,
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -168,7 +174,9 @@ func (c *RolesClient) Delete(ctx context.Context, roleId string, opt ...Option)
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -197,7 +205,9 @@ func (c *RolesClient) List(ctx context.Context, opt ...Option) ([]*Role, *api.Er
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -249,7 +259,9 @@ func (c *RolesClient) AddGrants(ctx context.Context, roleId string, version uint
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding AddGrants response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -301,7 +313,9 @@ func (c *RolesClient) AddPrincipals(ctx context.Context, roleId string, version
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding AddPrincipals response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -356,7 +370,9 @@ func (c *RolesClient) SetGrants(ctx context.Context, roleId string, version uint
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding SetGrants response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -411,7 +427,9 @@ func (c *RolesClient) SetPrincipals(ctx context.Context, roleId string, version
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding SetPrincipals response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -463,7 +481,9 @@ func (c *RolesClient) RemoveGrants(ctx context.Context, roleId string, version u
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding RemoveGrants response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -515,6 +535,8 @@ func (c *RolesClient) RemovePrincipals(ctx context.Context, roleId string, versi
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding RemovePrincipals response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
+15
-5
@@ -59,7 +59,9 @@ func (c *ScopesClient) Create(ctx context.Context, scopeId string, opt ...Option
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -89,7 +91,9 @@ func (c *ScopesClient) Read(ctx context.Context, scopeId string, opt ...Option)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -137,7 +141,9 @@ func (c *ScopesClient) Update(ctx context.Context, scopeId string, version uint3
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -170,7 +176,9 @@ func (c *ScopesClient) Delete(ctx context.Context, scopeId string, opt ...Option
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -207,6 +215,8 @@ func (c *ScopesClient) List(ctx context.Context, scopeId string, opt ...Option)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
+15
-5
@@ -52,7 +52,9 @@ func (c *UsersClient) Create(ctx context.Context, opt ...Option) (*User, *api.Er
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Create response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -82,7 +84,9 @@ func (c *UsersClient) Read(ctx context.Context, userId string, opt ...Option) (*
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Read response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -130,7 +134,9 @@ func (c *UsersClient) Update(ctx context.Context, userId string, version uint32,
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding Update response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -163,7 +169,9 @@ func (c *UsersClient) Delete(ctx context.Context, userId string, opt ...Option)
|
||||
if err != nil {
|
||||
return false, nil, fmt.Errorf("error decoding Delete response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return false, apiErr, nil
|
||||
}
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
@@ -192,6 +200,8 @@ func (c *UsersClient) List(ctx context.Context, opt ...Option) ([]*User, *api.Er
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("error decoding List response: %w", err)
|
||||
}
|
||||
|
||||
if apiErr != nil {
|
||||
return nil, apiErr, nil
|
||||
}
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
Reference in new issue
Block a user