All portal hooks will be after the artifact (app or sub) has already been created in apim. The only exception would be hook_form_alter which you could use to do something before the call is even made to api manager. But obviously you won't have anything like the app id or client id at that point because it hasn't been created yet.
Fundamentally the important point to remember is api manager owns these items and is the system or truth. That limits what you can do in the portal.
Original Message:
Sent: Wed March 20, 2024 05:11 PM
From: Syed Imtiyaz Alam
Subject: implementing hooks
another thought
During APP creation , we are adding some fields thus we can add some validation on those field to connect to internal DB and check few things and during this time submit button is not enabled for user. But yes this does not solve all the use case like connection failure. and during that time we roll back.
Can you please confirm at-least hooks are called only after actual application or subscription was successfully. ?
------------------------------
Syed Imtiyaz Alam
Original Message:
Sent: Wed March 13, 2024 10:42 AM
From: Anne Redwood
Subject: implementing hooks
Alteration of our source code is not supported i.e you cannot modify the code at the point of app creation or subscription.
Remember the portal doesn't directly create an application or subscribe an application to a product plan - this is done as consumer api call to the api manager. To have cannot have application credentials without an app being created.
To perform the kind of rollback you need to do you would need to perform the opposite action of what you have done i.e. delete or unsubscribe. This you would need to do in your own custom code using the hooks you have previously identified, attempt what you need to do on your internal DB/system and if it fails use the consumer api to perform that a delete or unsubscription of the app.
------------------------------
Anne Redwood
Original Message:
Sent: Wed March 13, 2024 10:04 AM
From: Syed Imtiyaz Alam
Subject: implementing hooks
So you are wanting some kind of rollback based on whether your internal Database has failed or not? >> YES rollback.
When you say "alteration of that is not supported." , do you mean this is not feasible via Drupal or IBM does not support.
Any suggestions how we can achieve this use case.
------------------------------
Syed Imtiyaz Alam
Original Message:
Sent: Tue March 12, 2024 05:59 AM
From: Anne Redwood
Subject: implementing hooks
So you are wanting some kind of rollback based on whether your internal Database has failed or not?
hook_form_alter is to use before app creation/ app subscription
hook_apic_app_subscribe is to use after app subsrciption
hook_apic_app_create is to use after app create
What you seem to be implying is that you want to customise the app creation and subscription as it happens, which is internal portal code and alteration of that is not supported.
------------------------------
Anne Redwood
Original Message:
Sent: Mon March 11, 2024 03:34 PM
From: Syed Imtiyaz Alam
Subject: implementing hooks
Hi Anne,
for App creation, yes we will alter the form to add few more custom field for consumer to enter but we would also need the credentials info like app name/app sub name or app id generated so we cant use before submit.
And for subscription , we will be using as it is i.e. after subscription request is made , internally we would also check our internal DB. There is no alteration on the page.
the above is my thought and as for both case hooks were available so wanted to understand how do make sure both are tied together.
thank you the feedback.
------------------------------
Syed Imtiyaz Alam
Original Message:
Sent: Fri March 08, 2024 05:23 AM
From: Anne Redwood
Subject: implementing hooks
The hooks hook_apic_app_create and hook_apic_app_subscribe are always called after the create or subscribe. You are wanting to alter the form so you will need to use the hook_form_alter to add pre submit validation to the form you are altering.
Hope this helps,
Anne
------------------------------
Anne Redwood
Original Message:
Sent: Thu March 07, 2024 11:04 PM
From: Syed Imtiyaz Alam
Subject: implementing hooks
- During App onboarding/creation: We will alter the form and add some more text field which we want to insert those data to our internal DB by implementing hook_apic_app_create and we want to make sure if for what ever reason inserting to DB fails , it should fail the creation of the credentials. This is applicable for all different operation i.e. any updates/delete, we want to update our internal DB and if that fails, then actual updates or deletes fails.
- Similar use case for subscription , when ever subscription is requested , we want to check our internal DB for some configuration and if that fails or based on some response then we want to fail the subscription also or proceed with the subscription.
I hope this helps.
------------------------------
Syed Imtiyaz Alam
Original Message:
Sent: Thu March 07, 2024 05:10 AM
From: Anne Redwood
Subject: implementing hooks
We have a sample module which demonstrates the use of the hooks you are interested in available on our sample module github repo .Can you clarify what you are trying to do? Are you attempting to create and app and subscribe to a product plan at the same time?
------------------------------
Anne Redwood
Original Message:
Sent: Wed March 06, 2024 02:59 PM
From: Syed Imtiyaz Alam
Subject: implementing hooks
Hi
I am doing some POC and trying to implement below hooks
hook_apic_app_subscribe
hook_apic_app_create
basically i want do something when app or subscription is created but I also want to make sure if there was any failure , original app should not be created or subscription should also fail.
Can you please suggest me how to implement that or this can be part of error handling of hook implementation.
Thank you,
Imtiyaz
------------------------------
Syed Imtiyaz Alam
------------------------------