From 87c4f15acfae111481f366f607371d6c73e4e18c Mon Sep 17 00:00:00 2001 From: Ahmad Nurjalal Date: Thu, 14 Oct 2021 16:22:46 +0700 Subject: [PATCH] refactor: group sdk wrapper --- .../configuration.go} | 90 +++------- .../{groupService.go => group/group.go} | 148 +++++------------ .../groupMember.go} | 154 +++++------------- .../groupRoles.go} | 102 ++++-------- 4 files changed, 143 insertions(+), 351 deletions(-) rename services-api/pkg/service/{groupConfigurationService.go => group/configuration.go} (65%) rename services-api/pkg/service/{groupService.go => group/group.go} (68%) rename services-api/pkg/service/{groupMemberService.go => group/groupMember.go} (69%) rename services-api/pkg/service/{groupRoleService.go => group/groupRoles.go} (66%) diff --git a/services-api/pkg/service/groupConfigurationService.go b/services-api/pkg/service/group/configuration.go similarity index 65% rename from services-api/pkg/service/groupConfigurationService.go rename to services-api/pkg/service/group/configuration.go index 335715492..9951b3f8e 100644 --- a/services-api/pkg/service/groupConfigurationService.go +++ b/services-api/pkg/service/group/configuration.go @@ -1,4 +1,4 @@ -package service +package group import ( "encoding/json" @@ -11,23 +11,18 @@ import ( "github.com/sirupsen/logrus" ) -type GroupConfigService struct { - GroupClient *groupclient.JusticeGroupService +type ConfigurationService struct { + Client *groupclient.JusticeGroupService TokenRepository repository.TokenRepository } -func (s *GroupConfigService) ListGroupConfigurationAdminV1(namespace string, limit, offset *int64) (*groupclientmodels.ModelsListConfigurationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (c *ConfigurationService) ListGroupConfigurationAdminV1(input *configuration.ListGroupConfigurationAdminV1Params) (*groupclientmodels.ModelsListConfigurationResponseV1, error) { + token, err := c.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &configuration.ListGroupConfigurationAdminV1Params{ - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Configuration.ListGroupConfigurationAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := c.Client.Configuration.ListGroupConfigurationAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -60,17 +55,13 @@ func (s *GroupConfigService) ListGroupConfigurationAdminV1(namespace string, lim return ok.GetPayload(), nil } -func (s *GroupConfigService) CreateGroupConfigurationAdminV1(namespace string, body *groupclientmodels.ModelsCreateGroupConfigurationRequestV1) (*groupclientmodels.ModelsCreateGroupConfigurationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (c *ConfigurationService) CreateGroupConfigurationAdminV1(input *configuration.CreateGroupConfigurationAdminV1Params) (*groupclientmodels.ModelsCreateGroupConfigurationResponseV1, error) { + token, err := c.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &configuration.CreateGroupConfigurationAdminV1Params{ - Body: body, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Configuration.CreateGroupConfigurationAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := c.Client.Configuration.CreateGroupConfigurationAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -103,16 +94,13 @@ func (s *GroupConfigService) CreateGroupConfigurationAdminV1(namespace string, b return ok.GetPayload(), nil } -func (s *GroupConfigService) InitiateGroupConfigurationAdminV1(namespace string) (*groupclientmodels.ModelsCreateGroupConfigurationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (c *ConfigurationService) InitiateGroupConfigurationAdminV1(input *configuration.InitiateGroupConfigurationAdminV1Params) (*groupclientmodels.ModelsCreateGroupConfigurationResponseV1, error) { + token, err := c.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &configuration.InitiateGroupConfigurationAdminV1Params{ - Namespace: namespace, - } - created, unauthorized, forbidden, conflict, internalServerError, err := s.GroupClient.Configuration.InitiateGroupConfigurationAdminV1(params, client.BearerToken(*token.AccessToken)) + created, unauthorized, forbidden, conflict, internalServerError, err := c.Client.Configuration.InitiateGroupConfigurationAdminV1(input, client.BearerToken(*token.AccessToken)) if unauthorized != nil { errorMsg, _ := json.Marshal(*unauthorized.GetPayload()) logrus.Error(string(errorMsg)) @@ -140,17 +128,13 @@ func (s *GroupConfigService) InitiateGroupConfigurationAdminV1(namespace string) return created.GetPayload(), nil } -func (s *GroupConfigService) GetGroupConfigurationAdminV1(namespace, configCode string) (*groupclientmodels.ModelsGetGroupConfigurationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (c *ConfigurationService) GetGroupConfigurationAdminV1(input *configuration.GetGroupConfigurationAdminV1Params) (*groupclientmodels.ModelsGetGroupConfigurationResponseV1, error) { + token, err := c.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &configuration.GetGroupConfigurationAdminV1Params{ - ConfigurationCode: configCode, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Configuration.GetGroupConfigurationAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := c.Client.Configuration.GetGroupConfigurationAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -183,17 +167,13 @@ func (s *GroupConfigService) GetGroupConfigurationAdminV1(namespace, configCode return ok.GetPayload(), nil } -func (s *GroupConfigService) DeleteGroupConfigurationV1(namespace, configCode string) error { - token, err := s.TokenRepository.GetToken() +func (c *ConfigurationService) DeleteGroupConfigurationV1(input *configuration.DeleteGroupConfigurationV1Params) error { + token, err := c.TokenRepository.GetToken() if err != nil { logrus.Error(err) return err } - params := &configuration.DeleteGroupConfigurationV1Params{ - ConfigurationCode: configCode, - Namespace: namespace, - } - _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Configuration.DeleteGroupConfigurationV1(params, client.BearerToken(*token.AccessToken)) + _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := c.Client.Configuration.DeleteGroupConfigurationV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -226,18 +206,13 @@ func (s *GroupConfigService) DeleteGroupConfigurationV1(namespace, configCode st return nil } -func (s *GroupConfigService) UpdateGroupConfigurationAdminV1(namespace, configCode string, content *groupclientmodels.ModelsUpdateGroupConfigurationRequestV1) (*groupclientmodels.ModelsUpdateGroupConfigurationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (c *ConfigurationService) UpdateGroupConfigurationAdminV1(input *configuration.UpdateGroupConfigurationAdminV1Params) (*groupclientmodels.ModelsUpdateGroupConfigurationResponseV1, error) { + token, err := c.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &configuration.UpdateGroupConfigurationAdminV1Params{ - Body: content, - ConfigurationCode: configCode, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Configuration.UpdateGroupConfigurationAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := c.Client.Configuration.UpdateGroupConfigurationAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -270,19 +245,13 @@ func (s *GroupConfigService) UpdateGroupConfigurationAdminV1(namespace, configCo return ok.GetPayload(), nil } -func (s *GroupConfigService) UpdateGroupConfigurationGlobalRuleAdminV1(namespace, configCode, allowedAction string, content *groupclientmodels.ModelsUpdateGroupConfigurationGlobalRulesRequestV1) (*groupclientmodels.ModelsUpdateGroupConfigurationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (c *ConfigurationService) UpdateGroupConfigurationGlobalRuleAdminV1(input *configuration.UpdateGroupConfigurationGlobalRuleAdminV1Params) (*groupclientmodels.ModelsUpdateGroupConfigurationResponseV1, error) { + token, err := c.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &configuration.UpdateGroupConfigurationGlobalRuleAdminV1Params{ - AllowedAction: allowedAction, - Body: content, - ConfigurationCode: configCode, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Configuration.UpdateGroupConfigurationGlobalRuleAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := c.Client.Configuration.UpdateGroupConfigurationGlobalRuleAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -315,18 +284,13 @@ func (s *GroupConfigService) UpdateGroupConfigurationGlobalRuleAdminV1(namespace return ok.GetPayload(), nil } -func (s *GroupConfigService) DeleteGroupConfigurationGlobalRuleAdminV1(namespace, configCode, allowedAction string) (*groupclientmodels.ModelsUpdateGroupConfigurationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (c *ConfigurationService) DeleteGroupConfigurationGlobalRuleAdminV1(input *configuration.DeleteGroupConfigurationGlobalRuleAdminV1Params) (*groupclientmodels.ModelsUpdateGroupConfigurationResponseV1, error) { + token, err := c.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &configuration.DeleteGroupConfigurationGlobalRuleAdminV1Params{ - AllowedAction: allowedAction, - ConfigurationCode: configCode, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Configuration.DeleteGroupConfigurationGlobalRuleAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := c.Client.Configuration.DeleteGroupConfigurationGlobalRuleAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) diff --git a/services-api/pkg/service/groupService.go b/services-api/pkg/service/group/group.go similarity index 68% rename from services-api/pkg/service/groupService.go rename to services-api/pkg/service/group/group.go index 65524aec3..9a6d9099d 100644 --- a/services-api/pkg/service/groupService.go +++ b/services-api/pkg/service/group/group.go @@ -1,4 +1,4 @@ -package service +package group import ( "encoding/json" @@ -12,21 +12,17 @@ import ( ) type GroupService struct { - GroupClient *groupclient.JusticeGroupService + Client *groupclient.JusticeGroupService TokenRepository repository.TokenRepository } -func (s *GroupService) CreateNewGroupPublicV1(namespace string, content *groupclientmodels.ModelsPublicCreateNewGroupRequestV1) (*groupclientmodels.ModelsGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) CreateNewGroupPublicV1(input *group.CreateNewGroupPublicV1Params) (*groupclientmodels.ModelsGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.CreateNewGroupPublicV1Params{ - Body: content, - Namespace: namespace, - } - created, badRequest, unauthorized, forbidden, conflict, internalServerError, err := s.GroupClient.Group.CreateNewGroupPublicV1(params, client.BearerToken(*token.AccessToken)) + created, badRequest, unauthorized, forbidden, conflict, internalServerError, err := g.Client.Group.CreateNewGroupPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -59,17 +55,13 @@ func (s *GroupService) CreateNewGroupPublicV1(namespace string, content *groupcl return created.GetPayload(), nil } -func (s *GroupService) DeleteGroupAdminV1(namespace, groupId string) error { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) DeleteGroupAdminV1(input *group.DeleteGroupAdminV1Params) error { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return err } - params := &group.DeleteGroupAdminV1Params{ - GroupID: groupId, - Namespace: namespace, - } - _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.DeleteGroupAdminV1(params, client.BearerToken(*token.AccessToken)) + _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.DeleteGroupAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -102,18 +94,13 @@ func (s *GroupService) DeleteGroupAdminV1(namespace, groupId string) error { return nil } -func (s *GroupService) DeleteGroupPredefinedRulePublicV1(namespace, groupId, allowedAction string) error { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) DeleteGroupPredefinedRulePublicV1(input *group.DeleteGroupPredefinedRulePublicV1Params) error { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return err } - params := &group.DeleteGroupPredefinedRulePublicV1Params{ - AllowedAction: allowedAction, - GroupID: groupId, - Namespace: namespace, - } - _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.DeleteGroupPredefinedRulePublicV1(params, client.BearerToken(*token.AccessToken)) + _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.DeleteGroupPredefinedRulePublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -146,17 +133,13 @@ func (s *GroupService) DeleteGroupPredefinedRulePublicV1(namespace, groupId, all return nil } -func (s *GroupService) DeleteGroupPublicV1(namespace, groupId string) error { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) DeleteGroupPublicV1(input *group.DeleteGroupPublicV1Params) error { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return err } - params := &group.DeleteGroupPublicV1Params{ - GroupID: groupId, - Namespace: namespace, - } - _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.DeleteGroupPublicV1(params, client.BearerToken(*token.AccessToken)) + _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.DeleteGroupPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -189,21 +172,13 @@ func (s *GroupService) DeleteGroupPublicV1(namespace, groupId string) error { return nil } -func (s *GroupService) GetGroupListAdminV1(namespace string, groupName, groupRegion, configCode *string, limit, offset *int64) (*groupclientmodels.ModelsGetGroupsListResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) GetGroupListAdminV1(input *group.GetGroupListAdminV1Params) (*groupclientmodels.ModelsGetGroupsListResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.GetGroupListAdminV1Params{ - ConfigurationCode: configCode, - GroupName: groupName, - GroupRegion: groupRegion, - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, badRequest, unauthorized, forbidden, internalServerError, err := s.GroupClient.Group.GetGroupListAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, internalServerError, err := g.Client.Group.GetGroupListAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -231,20 +206,13 @@ func (s *GroupService) GetGroupListAdminV1(namespace string, groupName, groupReg return ok.GetPayload(), nil } -func (s *GroupService) GetGroupListPublicV1(namespace string, groupName, groupRegion *string, limit, offset *int64) (*groupclientmodels.ModelsGetGroupsListResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) GetGroupListPublicV1(input *group.GetGroupListPublicV1Params) (*groupclientmodels.ModelsGetGroupsListResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.GetGroupListPublicV1Params{ - GroupName: groupName, - GroupRegion: groupRegion, - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, badRequest, unauthorized, forbidden, internalServerError, err := s.GroupClient.Group.GetGroupListPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, internalServerError, err := g.Client.Group.GetGroupListPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -272,17 +240,13 @@ func (s *GroupService) GetGroupListPublicV1(namespace string, groupName, groupRe return ok.GetPayload(), nil } -func (s *GroupService) GetSingleGroupAdminV1(namespace, groupId string) (*groupclientmodels.ModelsGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) GetSingleGroupAdminV1(input *group.GetSingleGroupAdminV1Params) (*groupclientmodels.ModelsGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.GetSingleGroupAdminV1Params{ - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.GetSingleGroupAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.GetSingleGroupAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -315,17 +279,13 @@ func (s *GroupService) GetSingleGroupAdminV1(namespace, groupId string) (*groupc return ok.GetPayload(), nil } -func (s *GroupService) GetSingleGroupPublicV1(namespace, groupId string) (*groupclientmodels.ModelsGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) GetSingleGroupPublicV1(input *group.GetSingleGroupPublicV1Params) (*groupclientmodels.ModelsGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.GetSingleGroupPublicV1Params{ - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.GetSingleGroupPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.GetSingleGroupPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -358,18 +318,13 @@ func (s *GroupService) GetSingleGroupPublicV1(namespace, groupId string) (*group return ok.GetPayload(), nil } -func (s *GroupService) UpdateGroupCustomAttributesPublicV1(namespace, groupId string, body *groupclientmodels.ModelsUpdateGroupCustomAttributesRequestV1) (*groupclientmodels.ModelsGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) UpdateGroupCustomAttributesPublicV1(input *group.UpdateGroupCustomAttributesPublicV1Params) (*groupclientmodels.ModelsGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.UpdateGroupCustomAttributesPublicV1Params{ - Body: body, - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.UpdateGroupCustomAttributesPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.UpdateGroupCustomAttributesPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -402,18 +357,13 @@ func (s *GroupService) UpdateGroupCustomAttributesPublicV1(namespace, groupId st return ok.GetPayload(), nil } -func (s *GroupService) UpdateGroupCustomRulePublicV1(namespace, groupId string, body *groupclientmodels.ModelsUpdateGroupCustomRuleRequestV1) (*groupclientmodels.ModelsGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) UpdateGroupCustomRulePublicV1(input *group.UpdateGroupCustomRulePublicV1Params) (*groupclientmodels.ModelsGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.UpdateGroupCustomRulePublicV1Params{ - Body: body, - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.UpdateGroupCustomRulePublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.UpdateGroupCustomRulePublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -446,19 +396,13 @@ func (s *GroupService) UpdateGroupCustomRulePublicV1(namespace, groupId string, return ok.GetPayload(), nil } -func (s *GroupService) UpdateGroupPredefinedRulePublicV1(namespace, groupId, allowedAction string, body *groupclientmodels.ModelsUpdateGroupPredefinedRuleRequestV1) (*groupclientmodels.ModelsGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) UpdateGroupPredefinedRulePublicV1(input *group.UpdateGroupPredefinedRulePublicV1Params) (*groupclientmodels.ModelsGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.UpdateGroupPredefinedRulePublicV1Params{ - AllowedAction: allowedAction, - Body: body, - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.UpdateGroupPredefinedRulePublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.UpdateGroupPredefinedRulePublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -491,18 +435,13 @@ func (s *GroupService) UpdateGroupPredefinedRulePublicV1(namespace, groupId, all return ok.GetPayload(), nil } -func (s *GroupService) UpdateSingleGroupPublicV1(namespace, groupId string, content *groupclientmodels.ModelsUpdateGroupRequestV1) (*groupclientmodels.ModelsGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) UpdateSingleGroupPublicV1(input *group.UpdateSingleGroupPublicV1Params) (*groupclientmodels.ModelsGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.UpdateSingleGroupPublicV1Params{ - Body: content, - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.UpdateSingleGroupPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.UpdateSingleGroupPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -535,18 +474,13 @@ func (s *GroupService) UpdateSingleGroupPublicV1(namespace, groupId string, cont return ok.GetPayload(), nil } -func (s *GroupService) UpdateSingleGroupV1(namespace, groupId string, content *groupclientmodels.ModelsUpdateGroupRequestV1) (*groupclientmodels.ModelsGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupService) UpdateSingleGroupV1(input *group.UpdateSingleGroupV1Params) (*groupclientmodels.ModelsGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group.UpdateSingleGroupV1Params{ - Body: content, - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.Group.UpdateSingleGroupV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.Group.UpdateSingleGroupV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) diff --git a/services-api/pkg/service/groupMemberService.go b/services-api/pkg/service/group/groupMember.go similarity index 69% rename from services-api/pkg/service/groupMemberService.go rename to services-api/pkg/service/group/groupMember.go index 0aac03d1d..cb2396f41 100644 --- a/services-api/pkg/service/groupMemberService.go +++ b/services-api/pkg/service/group/groupMember.go @@ -1,4 +1,4 @@ -package service +package group import ( "encoding/json" @@ -12,22 +12,18 @@ import ( "github.com/sirupsen/logrus" ) -type GroupMemberConfigService struct { - GroupClient *groupclient.JusticeGroupService +type GroupMemberService struct { + Client *groupclient.JusticeGroupService TokenRepository repository.TokenRepository } -func (s *GroupMemberConfigService) CancelGroupJoinRequestV1(namespace, groupId string) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) CancelGroupJoinRequestV1(input *group_member.CancelGroupJoinRequestV1Params) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.CancelGroupJoinRequestV1Params{ - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupMember.CancelGroupJoinRequestV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupMember.CancelGroupJoinRequestV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -60,17 +56,13 @@ func (s *GroupMemberConfigService) CancelGroupJoinRequestV1(namespace, groupId s return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) JoinGroupV1(namespace, groupId string) (*groupclientmodels.ModelsJoinGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) JoinGroupV1(input *group_member.JoinGroupV1Params) (*groupclientmodels.ModelsJoinGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.JoinGroupV1Params{ - GroupID: groupId, - Namespace: namespace, - } - created, badRequest, unauthorized, forbidden, conflict, internalServerError, err := s.GroupClient.GroupMember.JoinGroupV1(params, client.BearerToken(*token.AccessToken)) + created, badRequest, unauthorized, forbidden, conflict, internalServerError, err := g.Client.GroupMember.JoinGroupV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -103,17 +95,13 @@ func (s *GroupMemberConfigService) JoinGroupV1(namespace, groupId string) (*grou return created.GetPayload(), nil } -func (s *GroupMemberConfigService) AcceptGroupInvitationPublicV1(namespace, groupId string) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) AcceptGroupInvitationPublicV1(input *group_member.AcceptGroupInvitationPublicV1Params) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.AcceptGroupInvitationPublicV1Params{ - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := s.GroupClient.GroupMember.AcceptGroupInvitationPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := g.Client.GroupMember.AcceptGroupInvitationPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -151,17 +139,13 @@ func (s *GroupMemberConfigService) AcceptGroupInvitationPublicV1(namespace, grou return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) AcceptGroupJoinRequestPublicV1(namespace, userId string) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) AcceptGroupJoinRequestPublicV1(input *group_member.AcceptGroupJoinRequestPublicV1Params) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.AcceptGroupJoinRequestPublicV1Params{ - Namespace: namespace, - UserID: userId, - } - ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := s.GroupClient.GroupMember.AcceptGroupJoinRequestPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := g.Client.GroupMember.AcceptGroupJoinRequestPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -199,20 +183,13 @@ func (s *GroupMemberConfigService) AcceptGroupJoinRequestPublicV1(namespace, use return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) GetGroupMembersListAdminV1(namespace, groupId string, order *string, limit, offset *int64) (*groupclientmodels.ModelsGetGroupMemberListResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) GetGroupMembersListAdminV1(input *group_member.GetGroupMembersListAdminV1Params) (*groupclientmodels.ModelsGetGroupMemberListResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.GetGroupMembersListAdminV1Params{ - GroupID: groupId, - Limit: limit, - Namespace: namespace, - Offset: offset, - Order: order, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupMember.GetGroupMembersListAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupMember.GetGroupMembersListAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -245,20 +222,13 @@ func (s *GroupMemberConfigService) GetGroupMembersListAdminV1(namespace, groupId return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) GetGroupMembersListPublicV1(namespace, groupId string, order *string, limit, offset *int64) (*groupclientmodels.ModelsGetGroupMemberListResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) GetGroupMembersListPublicV1(input *group_member.GetGroupMembersListPublicV1Params) (*groupclientmodels.ModelsGetGroupMemberListResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.GetGroupMembersListPublicV1Params{ - GroupID: groupId, - Limit: limit, - Namespace: namespace, - Offset: offset, - Order: order, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupMember.GetGroupMembersListPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupMember.GetGroupMembersListPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -291,17 +261,13 @@ func (s *GroupMemberConfigService) GetGroupMembersListPublicV1(namespace, groupI return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) GetUserGroupInformationPublicV1(namespace, userId string) (*groupclientmodels.ModelsGetUserGroupInformationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) GetUserGroupInformationPublicV1(input *group_member.GetUserGroupInformationPublicV1Params) (*groupclientmodels.ModelsGetUserGroupInformationResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.GetUserGroupInformationPublicV1Params{ - Namespace: namespace, - UserID: userId, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupMember.GetUserGroupInformationPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupMember.GetUserGroupInformationPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -334,17 +300,13 @@ func (s *GroupMemberConfigService) GetUserGroupInformationPublicV1(namespace, us return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) InviteGroupPublicV1(namespace, userId string) (*groupclientmodels.ModelsUserInvitationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) InviteGroupPublicV1(input *group_member.InviteGroupPublicV1Params) (*groupclientmodels.ModelsUserInvitationResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.InviteGroupPublicV1Params{ - Namespace: namespace, - UserID: userId, - } - ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := s.GroupClient.GroupMember.InviteGroupPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := g.Client.GroupMember.InviteGroupPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -382,17 +344,13 @@ func (s *GroupMemberConfigService) InviteGroupPublicV1(namespace, userId string) return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) KickGroupMemberPublicV1(namespace, userId string) (*groupclientmodels.ModelsKickGroupMemberResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) KickGroupMemberPublicV1(input *group_member.KickGroupMemberPublicV1Params) (*groupclientmodels.ModelsKickGroupMemberResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.KickGroupMemberPublicV1Params{ - Namespace: namespace, - UserID: userId, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupMember.KickGroupMemberPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupMember.KickGroupMemberPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -425,16 +383,13 @@ func (s *GroupMemberConfigService) KickGroupMemberPublicV1(namespace, userId str return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) LeaveGroupPublicV1(namespace string) (*groupclientmodels.ModelsLeaveGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) LeaveGroupPublicV1(input *group_member.LeaveGroupPublicV1Params) (*groupclientmodels.ModelsLeaveGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.LeaveGroupPublicV1Params{ - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupMember.LeaveGroupPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupMember.LeaveGroupPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -467,17 +422,13 @@ func (s *GroupMemberConfigService) LeaveGroupPublicV1(namespace string) (*groupc return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) RejectGroupInvitationPublicV1(namespace, groupId string) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) RejectGroupInvitationPublicV1(input *group_member.RejectGroupInvitationPublicV1Params) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.RejectGroupInvitationPublicV1Params{ - GroupID: groupId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := s.GroupClient.GroupMember.RejectGroupInvitationPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := g.Client.GroupMember.RejectGroupInvitationPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -515,17 +466,13 @@ func (s *GroupMemberConfigService) RejectGroupInvitationPublicV1(namespace, grou return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) RejectGroupJoinRequestPublicV1(namespace, userId string) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) RejectGroupJoinRequestPublicV1(input *group_member.RejectGroupJoinRequestPublicV1Params) (*groupclientmodels.ModelsMemberRequestGroupResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_member.RejectGroupJoinRequestPublicV1Params{ - Namespace: namespace, - UserID: userId, - } - ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := s.GroupClient.GroupMember.RejectGroupJoinRequestPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, conflict, internalServerError, err := g.Client.GroupMember.RejectGroupJoinRequestPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -563,18 +510,13 @@ func (s *GroupMemberConfigService) RejectGroupJoinRequestPublicV1(namespace, use return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) GetGroupInvitationRequestPublicV1(namespace string, limit, offset *int64) (*groupclientmodels.ModelsGetMemberRequestsListResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) GetGroupInvitationRequestPublicV1(input *member_request.GetGroupInvitationRequestPublicV1Params) (*groupclientmodels.ModelsGetMemberRequestsListResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &member_request.GetGroupInvitationRequestPublicV1Params{ - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, badRequest, unauthorized, forbidden, internalServerError, err := s.GroupClient.MemberRequest.GetGroupInvitationRequestPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, internalServerError, err := g.Client.MemberRequest.GetGroupInvitationRequestPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -602,19 +544,13 @@ func (s *GroupMemberConfigService) GetGroupInvitationRequestPublicV1(namespace s return ok.GetPayload(), nil } -func (s *GroupMemberConfigService) GetGroupJoinRequestPublicV1(namespace, groupId string, limit, offset *int64) (*groupclientmodels.ModelsGetMemberRequestsListResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupMemberService) GetGroupJoinRequestPublicV1(input *member_request.GetGroupJoinRequestPublicV1Params) (*groupclientmodels.ModelsGetMemberRequestsListResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &member_request.GetGroupJoinRequestPublicV1Params{ - GroupID: groupId, - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, badRequest, unauthorized, forbidden, internalServerError, err := s.GroupClient.MemberRequest.GetGroupJoinRequestPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, internalServerError, err := g.Client.MemberRequest.GetGroupJoinRequestPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) diff --git a/services-api/pkg/service/groupRoleService.go b/services-api/pkg/service/group/groupRoles.go similarity index 66% rename from services-api/pkg/service/groupRoleService.go rename to services-api/pkg/service/group/groupRoles.go index 37ac8987f..9db1c7489 100644 --- a/services-api/pkg/service/groupRoleService.go +++ b/services-api/pkg/service/group/groupRoles.go @@ -1,4 +1,4 @@ -package service +package group import ( "encoding/json" @@ -11,22 +11,18 @@ import ( "github.com/sirupsen/logrus" ) -type GroupRoleConfigService struct { - GroupClient *groupclient.JusticeGroupService +type GroupRolesService struct { + Client *groupclient.JusticeGroupService TokenRepository repository.TokenRepository } -func (s *GroupRoleConfigService) CreateMemberRoleAdminV1(namespace string, body *groupclientmodels.ModelsCreateMemberRoleRequestV1) (*groupclientmodels.ModelsCreateMemberRoleResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) CreateMemberRoleAdminV1(input *group_roles.CreateMemberRoleAdminV1Params) (*groupclientmodels.ModelsCreateMemberRoleResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_roles.CreateMemberRoleAdminV1Params{ - Body: body, - Namespace: namespace, - } - created, badRequest, unauthorized, forbidden, internalServerError, err := s.GroupClient.GroupRoles.CreateMemberRoleAdminV1(params, client.BearerToken(*token.AccessToken)) + created, badRequest, unauthorized, forbidden, internalServerError, err := g.Client.GroupRoles.CreateMemberRoleAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -54,17 +50,13 @@ func (s *GroupRoleConfigService) CreateMemberRoleAdminV1(namespace string, body return created.GetPayload(), nil } -func (s *GroupRoleConfigService) DeleteMemberRoleAdminV1(namespace, memberRoleId string) error { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) DeleteMemberRoleAdminV1(input *group_roles.DeleteMemberRoleAdminV1Params) error { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return err } - params := &group_roles.DeleteMemberRoleAdminV1Params{ - MemberRoleID: memberRoleId, - Namespace: namespace, - } - _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupRoles.DeleteMemberRoleAdminV1(params, client.BearerToken(*token.AccessToken)) + _, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupRoles.DeleteMemberRoleAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -97,18 +89,13 @@ func (s *GroupRoleConfigService) DeleteMemberRoleAdminV1(namespace, memberRoleId return nil } -func (s *GroupRoleConfigService) DeleteMemberRolePublicV1(namespace, memberRoleId string, content *groupclientmodels.ModelsRemoveRoleFromMemberRequestV1) (*groupclientmodels.ModelsUpdateMemberRoleResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) DeleteMemberRolePublicV1(input *group_roles.DeleteMemberRolePublicV1Params) (*groupclientmodels.ModelsUpdateMemberRoleResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_roles.DeleteMemberRolePublicV1Params{ - Body: content, - MemberRoleID: memberRoleId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, unprocessableEntity, internalServerError, err := s.GroupClient.GroupRoles.DeleteMemberRolePublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, unprocessableEntity, internalServerError, err := g.Client.GroupRoles.DeleteMemberRolePublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -146,18 +133,13 @@ func (s *GroupRoleConfigService) DeleteMemberRolePublicV1(namespace, memberRoleI return ok.GetPayload(), nil } -func (s *GroupRoleConfigService) GetMemberRolesListAdminV1(namespace string, limit, offset *int64) (*groupclientmodels.ModelsGetMemberRolesListResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) GetMemberRolesListAdminV1(input *group_roles.GetMemberRolesListAdminV1Params) (*groupclientmodels.ModelsGetMemberRolesListResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_roles.GetMemberRolesListAdminV1Params{ - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, badRequest, unauthorized, forbidden, internalServerError, err := s.GroupClient.GroupRoles.GetMemberRolesListAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, internalServerError, err := g.Client.GroupRoles.GetMemberRolesListAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -185,18 +167,13 @@ func (s *GroupRoleConfigService) GetMemberRolesListAdminV1(namespace string, lim return ok.GetPayload(), nil } -func (s *GroupRoleConfigService) GetMemberRolesListPublicV1(namespace string, limit, offset *int64) (*groupclientmodels.ModelsGetMemberRolesListResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) GetMemberRolesListPublicV1(input *group_roles.GetMemberRolesListPublicV1Params) (*groupclientmodels.ModelsGetMemberRolesListResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_roles.GetMemberRolesListPublicV1Params{ - Limit: limit, - Namespace: namespace, - Offset: offset, - } - ok, badRequest, unauthorized, forbidden, internalServerError, err := s.GroupClient.GroupRoles.GetMemberRolesListPublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, internalServerError, err := g.Client.GroupRoles.GetMemberRolesListPublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -224,17 +201,13 @@ func (s *GroupRoleConfigService) GetMemberRolesListPublicV1(namespace string, li return ok.GetPayload(), nil } -func (s *GroupRoleConfigService) GetSingleMemberRoleAdminV1(namespace, memberRoleId string) (*groupclientmodels.ModelsGetMemberRoleResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) GetSingleMemberRoleAdminV1(input *group_roles.GetSingleMemberRoleAdminV1Params) (*groupclientmodels.ModelsGetMemberRoleResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_roles.GetSingleMemberRoleAdminV1Params{ - MemberRoleID: memberRoleId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupRoles.GetSingleMemberRoleAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupRoles.GetSingleMemberRoleAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -267,18 +240,13 @@ func (s *GroupRoleConfigService) GetSingleMemberRoleAdminV1(namespace, memberRol return ok.GetPayload(), nil } -func (s *GroupRoleConfigService) UpdateMemberRoleAdminV1(namespace, memberRoleId string, body *groupclientmodels.ModelsUpdateMemberRoleRequestV1) (*groupclientmodels.ModelsUpdateMemberRoleResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) UpdateMemberRoleAdminV1(input *group_roles.UpdateMemberRoleAdminV1Params) (*groupclientmodels.ModelsUpdateMemberRoleResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_roles.UpdateMemberRoleAdminV1Params{ - Body: body, - MemberRoleID: memberRoleId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupRoles.UpdateMemberRoleAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupRoles.UpdateMemberRoleAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -311,18 +279,13 @@ func (s *GroupRoleConfigService) UpdateMemberRoleAdminV1(namespace, memberRoleId return ok.GetPayload(), nil } -func (s *GroupRoleConfigService) UpdateMemberRolePermissionAdminV1(namespace, memberRoleId string, body *groupclientmodels.ModelsUpdateMemberRolePermissionsRequestV1) (*groupclientmodels.ModelsUpdateMemberRoleResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) UpdateMemberRolePermissionAdminV1(input *group_roles.UpdateMemberRolePermissionAdminV1Params) (*groupclientmodels.ModelsUpdateMemberRoleResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_roles.UpdateMemberRolePermissionAdminV1Params{ - Body: body, - MemberRoleID: memberRoleId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupRoles.UpdateMemberRolePermissionAdminV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupRoles.UpdateMemberRolePermissionAdminV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg)) @@ -355,18 +318,13 @@ func (s *GroupRoleConfigService) UpdateMemberRolePermissionAdminV1(namespace, me return ok.GetPayload(), nil } -func (s *GroupRoleConfigService) UpdateMemberRolePublicV1(namespace, memberRoleId string, content *groupclientmodels.ModelsAssignRoleToMemberRequestV1) (*groupclientmodels.ModelsGetUserGroupInformationResponseV1, error) { - token, err := s.TokenRepository.GetToken() +func (g *GroupRolesService) UpdateMemberRolePublicV1(input *group_roles.UpdateMemberRolePublicV1Params) (*groupclientmodels.ModelsGetUserGroupInformationResponseV1, error) { + token, err := g.TokenRepository.GetToken() if err != nil { logrus.Error(err) return nil, err } - params := &group_roles.UpdateMemberRolePublicV1Params{ - Body: content, - MemberRoleID: memberRoleId, - Namespace: namespace, - } - ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := s.GroupClient.GroupRoles.UpdateMemberRolePublicV1(params, client.BearerToken(*token.AccessToken)) + ok, badRequest, unauthorized, forbidden, notFound, internalServerError, err := g.Client.GroupRoles.UpdateMemberRolePublicV1(input, client.BearerToken(*token.AccessToken)) if badRequest != nil { errorMsg, _ := json.Marshal(*badRequest.GetPayload()) logrus.Error(string(errorMsg))