Hi Tanuja,
Catalog properties are only known to the API Manager, so there is nothing you can do that wouldn't require a publish to update your APIs that use this catalog property when you change the value. As for changing "code", I don't like seeing GatewayScript code as you have above, specifically var toggle = "$(counterapi-toggle)";
The API Manager on publish is modifying your code upon publish. What I'd prefer to see in this case as having a set variable policy prior to your GatewayScript policy that would set a variable named counterapi-toggle with a type of any and a value of $(conterapi-toggle). Then you GatewayScript would use
var toggle = apim.getvariable('counterapi-toggle');
apim.setvariable('enableCounter',toggle);
Now your GatewayScript is always the same, but the set-variable will create a Gateway property in context with the value of your catalog property so the GatewayScript can access that value using a context get function instead of having your code changed with a variable substitution every publish. Perhaps this is a subtle difference in that you still need to do the publish to get the updated value in place, but the update impacts the set variable policy configuration, not the GatewayScript code. Also, as for your example, I would suggest using the API Gateway native context object (assuming you're not using a v5 compatible gateway), ie
var toggle = context.get('counterapi-toggle');
context.set('enableCounter',toggle);
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
------------------------------
Original Message:
Sent: Mon September 16, 2024 01:28 AM
From: Tanuja Ede
Subject: Catalog Properties usage in catalog settings
Hi Steve,
Thanks so much for the response. But do you think there is any way to configure a flag and make use of it without touching the code each time there are minor changes in the API related to flag's value?
Thanks,
Tanuja.
------------------------------
Tanuja Ede
Original Message:
Sent: Fri September 13, 2024 01:48 PM
From: Steve Linn
Subject: Catalog Properties usage in catalog settings
Hi Tanjja,
A catalog property is substituted by the API Manager at time of publish. If you change a catalog property value, those already published APIs will maintain the old value until they are republished which is where the substitution of the new catalog property value would happen. As far as the Gateway is concerned, it knows nothing about a catalog property. What is deployed to the Gateway would have the actual current value.
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Fri September 13, 2024 03:52 AM
From: Tanuja Ede
Subject: Catalog Properties usage in catalog settings
Hi,
We're trying to use Catalog Properties in the "Catalog Settings" section. Using the below statement to get the value of the property in the API.
var toggle = "$(counterapi-toggle)";
apim.setvariable('enableCounter',toggle);
The extraction of the value is working but when the value is changed to another - the updated value is not being set to the variable. Instead, the older value itself is being fetched. Cloud anyone please help us understand if we're missing something and also, how long it ideally takes to fetch the updated value.
Thanks, Tanuja
@Steve Linn - Could you please help me with this?
------------------------------
Tanuja Ede
------------------------------