Skip to content

Commit

Permalink
Merge pull request #316 from ctreminiom/fk_error_naming
Browse files Browse the repository at this point in the history
Removed duplicate Error in name
  • Loading branch information
ctreminiom authored Sep 16, 2024
2 parents eb0e7aa + 72d553b commit 7989fbb
Show file tree
Hide file tree
Showing 267 changed files with 1,797 additions and 1,793 deletions.
6 changes: 3 additions & 3 deletions admin/api_client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ func (c *Client) processResponse(response *http.Response, structure interface{})
return res, model.ErrUnauthorized

case http.StatusInternalServerError:
return res, model.ErrInternalError
return res, model.ErrInternal

case http.StatusBadRequest:
return res, model.ErrBadRequestError
return res, model.ErrBadRequest

default:
return res, model.ErrInvalidStatusCodeError
return res, model.ErrInvalidStatusCode
}
}

Expand Down
4 changes: 2 additions & 2 deletions admin/api_client_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestClient_Call(t *testing.T) {
Bytes: *bytes.NewBufferString("Hello, world!"),
},
wantErr: true,
Err: model.ErrBadRequestError,
Err: model.ErrBadRequest,
},

{
Expand All @@ -152,7 +152,7 @@ func TestClient_Call(t *testing.T) {
Bytes: *bytes.NewBufferString("Hello, world!"),
},
wantErr: true,
Err: model.ErrInternalError,
Err: model.ErrInternal,
},

{
Expand Down
16 changes: 8 additions & 8 deletions admin/internal/organization_directory_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ type internalOrganizationDirectoryServiceImpl struct {
func (i *internalOrganizationDirectoryServiceImpl) Activity(ctx context.Context, organizationID, accountID string) (*model.UserProductAccessScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

if accountID == "" {
return nil, nil, model.ErrNoAdminAccountIDError
return nil, nil, model.ErrNoAdminAccountID
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/directory/users/%v/last-active-dates", organizationID, accountID)
Expand All @@ -110,11 +110,11 @@ func (i *internalOrganizationDirectoryServiceImpl) Activity(ctx context.Context,
func (i *internalOrganizationDirectoryServiceImpl) Remove(ctx context.Context, organizationID, accountID string) (*model.ResponseScheme, error) {

if organizationID == "" {
return nil, model.ErrNoAdminOrganizationError
return nil, model.ErrNoAdminOrganization
}

if accountID == "" {
return nil, model.ErrNoAdminAccountIDError
return nil, model.ErrNoAdminAccountID
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/directory/users/%v", organizationID, accountID)
Expand All @@ -130,11 +130,11 @@ func (i *internalOrganizationDirectoryServiceImpl) Remove(ctx context.Context, o
func (i *internalOrganizationDirectoryServiceImpl) Suspend(ctx context.Context, organizationID, accountID string) (*model.GenericActionSuccessScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

if accountID == "" {
return nil, nil, model.ErrNoAdminAccountIDError
return nil, nil, model.ErrNoAdminAccountID
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/directory/users/%v/suspend-access", organizationID, accountID)
Expand All @@ -156,11 +156,11 @@ func (i *internalOrganizationDirectoryServiceImpl) Suspend(ctx context.Context,
func (i *internalOrganizationDirectoryServiceImpl) Restore(ctx context.Context, organizationID, accountID string) (*model.GenericActionSuccessScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

if accountID == "" {
return nil, nil, model.ErrNoAdminAccountIDError
return nil, nil, model.ErrNoAdminAccountID
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/directory/users/%v/restore-access", organizationID, accountID)
Expand Down
16 changes: 8 additions & 8 deletions admin/internal/organization_directory_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Test_internalOrganizationDirectoryServiceImpl_Activity(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand All @@ -76,7 +76,7 @@ func Test_internalOrganizationDirectoryServiceImpl_Activity(t *testing.T) {
organizationID: "organization-id-sample",
},
wantErr: true,
Err: model.ErrNoAdminAccountIDError,
Err: model.ErrNoAdminAccountID,
},

{
Expand Down Expand Up @@ -192,7 +192,7 @@ func Test_internalOrganizationDirectoryServiceImpl_Remove(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand All @@ -202,7 +202,7 @@ func Test_internalOrganizationDirectoryServiceImpl_Remove(t *testing.T) {
organizationID: "organization-id-sample",
},
wantErr: true,
Err: model.ErrNoAdminAccountIDError,
Err: model.ErrNoAdminAccountID,
},

{
Expand Down Expand Up @@ -317,7 +317,7 @@ func Test_internalOrganizationDirectoryServiceImpl_Suspend(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand All @@ -327,7 +327,7 @@ func Test_internalOrganizationDirectoryServiceImpl_Suspend(t *testing.T) {
organizationID: "organization-id-sample",
},
wantErr: true,
Err: model.ErrNoAdminAccountIDError,
Err: model.ErrNoAdminAccountID,
},

{
Expand Down Expand Up @@ -443,7 +443,7 @@ func Test_internalOrganizationDirectoryServiceImpl_Restore(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand All @@ -453,7 +453,7 @@ func Test_internalOrganizationDirectoryServiceImpl_Restore(t *testing.T) {
organizationID: "organization-id-sample",
},
wantErr: true,
Err: model.ErrNoAdminAccountIDError,
Err: model.ErrNoAdminAccountID,
},

{
Expand Down
18 changes: 9 additions & 9 deletions admin/internal/organization_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (i *internalOrganizationImpl) Gets(ctx context.Context, cursor string) (*mo
func (i *internalOrganizationImpl) Get(ctx context.Context, organizationID string) (*model.AdminOrganizationScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v", organizationID)
Expand All @@ -152,7 +152,7 @@ func (i *internalOrganizationImpl) Get(ctx context.Context, organizationID strin
func (i *internalOrganizationImpl) Users(ctx context.Context, organizationID, cursor string) (*model.OrganizationUserPageScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

var endpoint strings.Builder
Expand Down Expand Up @@ -182,7 +182,7 @@ func (i *internalOrganizationImpl) Users(ctx context.Context, organizationID, cu
func (i *internalOrganizationImpl) Domains(ctx context.Context, organizationID, cursor string) (*model.OrganizationDomainPageScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

var endpoint strings.Builder
Expand Down Expand Up @@ -212,11 +212,11 @@ func (i *internalOrganizationImpl) Domains(ctx context.Context, organizationID,
func (i *internalOrganizationImpl) Domain(ctx context.Context, organizationID, domainID string) (*model.OrganizationDomainScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

if domainID == "" {
return nil, nil, model.ErrNoAdminDomainIDError
return nil, nil, model.ErrNoAdminDomainID
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/domains/%v", organizationID, domainID)
Expand All @@ -238,7 +238,7 @@ func (i *internalOrganizationImpl) Domain(ctx context.Context, organizationID, d
func (i *internalOrganizationImpl) Events(ctx context.Context, organizationID string, options *model.OrganizationEventOptScheme, cursor string) (*model.OrganizationEventPageScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

params := url.Values{}
Expand Down Expand Up @@ -291,11 +291,11 @@ func (i *internalOrganizationImpl) Events(ctx context.Context, organizationID st
func (i *internalOrganizationImpl) Event(ctx context.Context, organizationID, eventID string) (*model.OrganizationEventScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

if eventID == "" {
return nil, nil, model.ErrNoEventIDError
return nil, nil, model.ErrNoEventID
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/events/%v", organizationID, eventID)
Expand All @@ -317,7 +317,7 @@ func (i *internalOrganizationImpl) Event(ctx context.Context, organizationID, ev
func (i *internalOrganizationImpl) Actions(ctx context.Context, organizationID string) (*model.OrganizationEventActionScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/event-actions", organizationID)
Expand Down
16 changes: 8 additions & 8 deletions admin/internal/organization_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func Test_internalOrganizationImpl_Get(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand Down Expand Up @@ -283,7 +283,7 @@ func Test_internalOrganizationImpl_Users(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand Down Expand Up @@ -398,7 +398,7 @@ func Test_internalOrganizationImpl_Domains(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand Down Expand Up @@ -513,7 +513,7 @@ func Test_internalOrganizationImpl_Domain(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand All @@ -523,7 +523,7 @@ func Test_internalOrganizationImpl_Domain(t *testing.T) {
organizationID: "organization-sample-uuid",
},
wantErr: true,
Err: model.ErrNoAdminDomainIDError,
Err: model.ErrNoAdminDomainID,
},

{
Expand Down Expand Up @@ -656,7 +656,7 @@ func Test_internalOrganizationImpl_Events(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand Down Expand Up @@ -778,7 +778,7 @@ func Test_internalOrganizationImpl_Event(t *testing.T) {
organizationID: "",
},
wantErr: true,
Err: model.ErrNoAdminOrganizationError,
Err: model.ErrNoAdminOrganization,
},

{
Expand All @@ -788,7 +788,7 @@ func Test_internalOrganizationImpl_Event(t *testing.T) {
organizationID: "organization-sample-uuid",
},
wantErr: true,
Err: model.ErrNoEventIDError,
Err: model.ErrNoEventID,
},

{
Expand Down
16 changes: 8 additions & 8 deletions admin/internal/organization_policy_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type internalOrganizationPolicyImpl struct {
func (i *internalOrganizationPolicyImpl) Gets(ctx context.Context, organizationID, policyType, cursor string) (*model.OrganizationPolicyPageScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

params := url.Values{}
Expand Down Expand Up @@ -111,11 +111,11 @@ func (i *internalOrganizationPolicyImpl) Gets(ctx context.Context, organizationI
func (i *internalOrganizationPolicyImpl) Get(ctx context.Context, organizationID, policyID string) (*model.OrganizationPolicyScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

if policyID == "" {
return nil, nil, model.ErrNoAdminPolicyError
return nil, nil, model.ErrNoAdminPolicy
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/policies/%v", organizationID, policyID)
Expand All @@ -137,7 +137,7 @@ func (i *internalOrganizationPolicyImpl) Get(ctx context.Context, organizationID
func (i *internalOrganizationPolicyImpl) Create(ctx context.Context, organizationID string, payload *model.OrganizationPolicyData) (*model.OrganizationPolicyScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/policies", organizationID)
Expand All @@ -159,11 +159,11 @@ func (i *internalOrganizationPolicyImpl) Create(ctx context.Context, organizatio
func (i *internalOrganizationPolicyImpl) Update(ctx context.Context, organizationID, policyID string, payload *model.OrganizationPolicyData) (*model.OrganizationPolicyScheme, *model.ResponseScheme, error) {

if organizationID == "" {
return nil, nil, model.ErrNoAdminOrganizationError
return nil, nil, model.ErrNoAdminOrganization
}

if policyID == "" {
return nil, nil, model.ErrNoAdminPolicyError
return nil, nil, model.ErrNoAdminPolicy
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/policies/%v", organizationID, policyID)
Expand All @@ -185,11 +185,11 @@ func (i *internalOrganizationPolicyImpl) Update(ctx context.Context, organizatio
func (i *internalOrganizationPolicyImpl) Delete(ctx context.Context, organizationID, policyID string) (*model.ResponseScheme, error) {

if organizationID == "" {
return nil, model.ErrNoAdminOrganizationError
return nil, model.ErrNoAdminOrganization
}

if policyID == "" {
return nil, model.ErrNoAdminPolicyError
return nil, model.ErrNoAdminPolicy
}

endpoint := fmt.Sprintf("admin/v1/orgs/%v/policies/%v", organizationID, policyID)
Expand Down
Loading

0 comments on commit 7989fbb

Please sign in to comment.