+func (ps *PublishService) GetAllowedPublishedServices(apiListRequestedServices []publishapi.ServiceAPIDescription) []publishapi.ServiceAPIDescription {
+ apiListAllPublished := ps.GetAllPublishedServices()
+ if apiListRequestedServices != nil {
+ allowedPublishedServices := intersection(apiListAllPublished, apiListRequestedServices)
+ return allowedPublishedServices
+ }
+ return []publishapi.ServiceAPIDescription{}
+}
+
+func intersection(a, b []publishapi.ServiceAPIDescription) []publishapi.ServiceAPIDescription {
+ var result []publishapi.ServiceAPIDescription
+
+ for _, itemA := range a {
+ for _, itemB := range b {
+ if *itemA.ApiId == *itemB.ApiId {
+ result = append(result, itemA)
+ break
+ }
+ }
+ }
+ return result
+}
+