How to: Implement Custom Code in Container Services
- The pre-configured Custom Code URL is available for each API that supports Custom Code. The Custom Code will be registered and configured for a type - Like containerTypeId.
- Developers can configure the Custom Code for - Create Instance, Update Instance, and Apply Event.
- It can be used for creating, updating, and applying requests.
To add custom code in the Container service add the following values in the request body:
Request URL for the Custom Code API call.
Default headers for Custom Code API call.
HTTP method - Type of API request for custom code (POST/PUT/GET)
Wait for the response from the API call
Acceptable status codes.
Raise an error if the status code returned doesn’t match acceptableStatusCodes.
Type of action (for create, update, or apply) and onRequest or onError
📘 **methodNames allowed are - create:OnRequest, create:OnError, update:OnRequest, update:OnError, apply_event:OnRequest, apply_event:OnError
Here is a sample payload of Custom Code with methodName apply_event:OnRequest :
Expected Response From Custom Code
Data is expected in response to the Custom Code with the existing payload in the data fields.
Data Formation from Custom Code Response
The fields returned from Custom Code inside the data field are replaced with the existing payload as shown below.
The Payload in Request Body
Payload from Custom Code returned
Final Payload that is used to register an instance
Restriction on Fields in Custom Code ResponseFor different APIs in Custom Code, there are few restrictions as to what Data keys are not acceptable for particular API types. We have provided the list below for the developers to know more.
Values not accepted in Data keys
Values accepted in Data keys