MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / MyAPIKeys

Method MyAPIKeys

module/system-apikey/iml.go:161–203  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

159}
160
161func (i *imlAPIKeyModule) MyAPIKeys(ctx context.Context) ([]*system_apikey_dto.SimpleItem, error) {
162 members, err := i.teamMemberService.Members(ctx, nil, nil)
163 if err != nil {
164 return nil, err
165 }
166 if len(members) == 0 {
167 return nil, nil
168 }
169 teamIds := utils.SliceToSlice(members, func(m *team_member.Member) string {
170 return m.Come
171 })
172 apps, err := i.serviceService.AppListByTeam(ctx, teamIds...)
173 if err != nil {
174 return nil, err
175 }
176 appIds := utils.SliceToSlice(apps, func(a *service.Service) string {
177 return a.Id
178 })
179 auths, err := i.applicationAuthorizationService.ListByApp(ctx, appIds...)
180 if err != nil {
181 return nil, err
182 }
183 result := make([]*system_apikey_dto.SimpleItem, 0, len(auths))
184 for _, a := range auths {
185 if a.Type != "apikey" {
186 continue
187 }
188 m := make(map[string]string)
189 json.Unmarshal([]byte(a.Config), &m)
190 if m["apikey"] == "" {
191 continue
192 }
193 result = append(result, &system_apikey_dto.SimpleItem{
194 Id: a.UUID,
195 Name: a.Name,
196 Value: m["apikey"],
197 Expired: a.ExpireTime,
198 })
199
200 }
201 return result, nil
202
203}
204
205func (i *imlAPIKeyModule) Create(ctx context.Context, input *system_apikey_dto.Create) error {
206 if input.Id == "" {

Callers

nothing calls this directly

Calls 3

MembersMethod · 0.65
AppListByTeamMethod · 0.65
ListByAppMethod · 0.65

Tested by

no test coverage detected