// Gets all published APIs.
// Returns a list of all APIs that has been published.
GetAllPublishedServices() []publishapi.ServiceAPIDescription
+ GetAllowedPublishedServices(invokerApiList []publishapi.ServiceAPIDescription) []publishapi.ServiceAPIDescription
}
type PublishService struct {
return publishedDescriptions
}
+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
+}
+
// Retrieve all published APIs.
func (ps *PublishService) GetApfIdServiceApis(ctx echo.Context, apfId string) error {
if !ps.serviceRegister.IsPublishingFunctionRegistered(apfId) {