Compile Dynamic Resource Doc (dry run)
POST /obp/v7.0.0/management/dynamic-resource-docs/compile
OBPv7.0.0-compileDynamicResourceDoc Roles: CanCreateDynamicResourceDoc Dynamic-Resource-DocDynamic
Compiles a Dynamic Resource Doc method body exactly as Create Dynamic Resource Doc would, and reports the result without storing anything.
Send the fields that shape the compiled code: request_verb, request_url, the URL-encoded method_body, and the optional
example_request_body and success_response_body (they become the generated RequestRootJsonClass / ResponseRootJsonClass).
programming_lang is the language of the method body, as on Create Dynamic Resource Doc: one of Scala, Java, Query.
It is optional and defaults to Scala. Any other value is rejected with OBP-40049.
A Java body is compiled as written, so example_request_body and success_response_body do not affect it. It must declare a public class
implementing Supplier<Function<Object[], Object>>; the function receives the raw request body, the path parameters and the CallContext.
A Query body is a Dynamic Query declaration, not code: nothing is compiled, and it is checked against the Dynamic Entity definitions
instead, with any problem reported in errors without a line number. A Dynamic Query only reads, so its request_verb must be GET,
and it does not need user-supplied code to be enabled. See the Glossary entry Dynamic Query.
errors carry the compiler's messages with line and column relative to the method body you sent (the server's added lines are
subtracted; 0 when the compiler gave no position). When the body compiles and dynamic_code_obp_calls_are_restricted is on,
the dependency validator runs too and any forbidden call is reported in dependency_error. compiles is true only when both pass.
The compiler diagnostics are produced without running anything. When the body compiles, the dependency check builds it as Create would,
so the same rules apply as for creating: the
allow_user_generated_scala_code kill switch, the create role, and at most 20 calls per minute per user.
Built for editors that let an author, or an assistant such as Opey, iterate on a body until it compiles before submitting it.
User Authentication is Required. The User must be logged in. The Application must also be authenticated.
JSON request body fields (5)
- method_body
- method_body
- request_url
- /my_user/MY_USER_ID
- request_verb
- POST
- programming_lang
- programming_lang
- success_response_body
- {"my_user_id": "some_id_value", "name": "Jhon", "age": 12, "hobby": ["coding"],"_optional_fields_": ["hobby"]}
JSON response body fields (7)
- column
- column
- compiles
- compiles
- duration_ms
- duration_ms
- errors
- errors
- line
- line
- message
- 123456
- severity
- severity
Example request body
{
"request_verb": "GET",
"request_url": "/hello/world",
"method_body": "Future.successful%28%28Map%28%22hello%22+-%3E+%22world%22%29%2C+HttpCode.%60200%60%28callContext%29%29%29",
"success_response_body": {
"hello": "world"
},
"programming_lang": "Scala"
}Example success response
{
"compiles": false,
"errors": [
{
"line": 1,
"column": 24,
"severity": "ERROR",
"message": "not found: value Full"
}
],
"duration_ms": 850
}Possible errors (8)
- OBP-20001: User not logged in. Authentication is required!
- OBP-10001: Incorrect json format.
- OBP-20006: User is missing one or more roles:
- OBP-50020: User-generated dynamic code execution is disabled on this API instance. Set allow_user_generated_scala_code=true to enable.
- OBP-40049: This language of dynamic code is not supported.
- OBP-40065: The Dynamic Query cannot be run as written.
- OBP-10018: Too Many Requests.
- OBP-50000: Unknown Error.