func (es *EventService) DeleteSubscriberIdSubscriptionsSubscriptionId(ctx echo.Context, subscriberId string, subscriptionId string) error {
es.lock.Lock()
- defer es.lock.Unlock()
log.Debug(es.subscriptions)
if _, ok := es.subscriptions[subscriptionId]; ok {
log.Debug("Deleting subscription", subscriptionId)
delete(es.subscriptions, subscriptionId)
}
+ es.lock.Unlock()
return ctx.NoContent(http.StatusNoContent)
}
return coreError
}
- im.lock.Lock()
- defer im.lock.Unlock()
-
- newInvoker.ApiInvokerId = im.getId(newInvoker.ApiInvokerInformation)
- onboardingSecret := "onboarding_secret_"
- if newInvoker.ApiInvokerInformation != nil {
- onboardingSecret = onboardingSecret + strings.ReplaceAll(*newInvoker.ApiInvokerInformation, " ", "_")
- } else {
- onboardingSecret = onboardingSecret + *newInvoker.ApiInvokerId
- }
- newInvoker.OnboardingInformation.OnboardingSecret = &onboardingSecret
+ im.prepareNewInvoker(&newInvoker)
- var apiList invokerapi.APIList = im.publishRegister.GetAllPublishedServices()
- newInvoker.ApiList = &apiList
-
- im.onboardedInvokers[*newInvoker.ApiInvokerId] = newInvoker
go im.sendEvent(*newInvoker.ApiInvokerId, eventsapi.CAPIFEventAPIINVOKERONBOARDED)
uri := ctx.Request().Host + ctx.Request().URL.String()
return nil
}
-// Deletes an individual API Invoker.
-func (im *InvokerManager) DeleteOnboardedInvokersOnboardingId(ctx echo.Context, onboardingId string) error {
+func (im *InvokerManager) prepareNewInvoker(newInvoker *invokerapi.APIInvokerEnrolmentDetails) {
im.lock.Lock()
defer im.lock.Unlock()
+ newInvoker.ApiInvokerId = im.getId(newInvoker.ApiInvokerInformation)
+ newInvoker.OnboardingInformation.OnboardingSecret = getOnboardingSecret(*newInvoker)
+
+ var apiList invokerapi.APIList = im.publishRegister.GetAllPublishedServices()
+ newInvoker.ApiList = &apiList
+
+ im.onboardedInvokers[*newInvoker.ApiInvokerId] = *newInvoker
+}
+
+func getOnboardingSecret(newInvoker invokerapi.APIInvokerEnrolmentDetails) *string {
+ onboardingSecret := "onboarding_secret_"
+ if newInvoker.ApiInvokerInformation != nil {
+ onboardingSecret = onboardingSecret + strings.ReplaceAll(*newInvoker.ApiInvokerInformation, " ", "_")
+ } else {
+ onboardingSecret = onboardingSecret + *newInvoker.ApiInvokerId
+ }
+ return &onboardingSecret
+}
+
+// Deletes an individual API Invoker.
+func (im *InvokerManager) DeleteOnboardedInvokersOnboardingId(ctx echo.Context, onboardingId string) error {
+ im.lock.Lock()
delete(im.onboardedInvokers, onboardingId)
+ im.lock.Unlock()
+
go im.sendEvent(onboardingId, eventsapi.CAPIFEventAPIINVOKEROFFBOARDED)
return ctx.NoContent(http.StatusNoContent)
return coreError
}
- im.lock.Lock()
- defer im.lock.Unlock()
-
if _, ok := im.onboardedInvokers[onboardingId]; ok {
+ im.lock.Lock()
im.onboardedInvokers[*invoker.ApiInvokerId] = invoker
+ im.lock.Unlock()
} else {
return sendCoreError(ctx, http.StatusNotFound, "The invoker to update has not been onboarded")
}
return sendCoreError(ctx, http.StatusBadRequest, "Provider missing required ApiProvDomInfo")
}
- pm.lock.Lock()
- defer pm.lock.Unlock()
-
- newProvider.ApiProvDomId = pm.getDomainId(newProvider.ApiProvDomInfo)
-
- pm.registerFunctions(newProvider.ApiProvFuncs)
- pm.onboardedProviders[*newProvider.ApiProvDomId] = newProvider
+ pm.prepareNewProvider(&newProvider)
uri := ctx.Request().Host + ctx.Request().URL.String()
ctx.Response().Header().Set(echo.HeaderLocation, ctx.Scheme()+`://`+path.Join(uri, *newProvider.ApiProvDomId))
return nil
}
-func (pm *ProviderManager) DeleteRegistrationsRegistrationId(ctx echo.Context, registrationId string) error {
+func (pm *ProviderManager) prepareNewProvider(newProvider *provapi.APIProviderEnrolmentDetails) {
pm.lock.Lock()
defer pm.lock.Unlock()
+ newProvider.ApiProvDomId = pm.getDomainId(newProvider.ApiProvDomInfo)
+
+ pm.registerFunctions(newProvider.ApiProvFuncs)
+ pm.onboardedProviders[*newProvider.ApiProvDomId] = *newProvider
+}
+
+func (pm *ProviderManager) DeleteRegistrationsRegistrationId(ctx echo.Context, registrationId string) error {
+
log.Debug(pm.onboardedProviders)
if _, ok := pm.onboardedProviders[registrationId]; ok {
log.Debug("Deleting provider", registrationId)
+ pm.lock.Lock()
delete(pm.onboardedProviders, registrationId)
+ pm.lock.Unlock()
}
return ctx.NoContent(http.StatusNoContent)
log.Debug("Deleted service: ", serviceApiId)
}
ps.lock.Lock()
- defer ps.lock.Unlock()
ps.publishedServices[string(apfId)] = removeServiceDescription(pos, serviceDescriptions)
+ ps.lock.Unlock()
go ps.sendEvent(*description, eventsapi.CAPIFEventSERVICEAPIUNAVAILABLE)
}
}
// Retrieve a published service API.
func (ps *PublishService) GetApfIdServiceApisServiceApiId(ctx echo.Context, apfId string, serviceApiId string) error {
ps.lock.Lock()
- defer ps.lock.Unlock()
-
serviceDescriptions, ok := ps.publishedServices[apfId]
+ ps.lock.Unlock()
+
if ok {
_, serviceDescription := getServiceDescription(serviceApiId, serviceDescriptions)
if serviceDescription == nil {