-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Add capability to add optional api path params #213
Comments
I've proposed a way to handle optional params in #234, which would not treat them any differently than any other params, they're just internally marked as required in the step. So you'd just have "deploy": "true" on the same level as description, etc. Set<String> requiredKeys = Set.of(NAME_FIELD, FUNCTION_NAME, CONNECTOR_ID);
Set<String> optionalKeys = Set.of(MODEL_GROUP_ID, DESCRIPTION_FIELD); Although I think @owaiskazi19 may have a competing implementation PR up later today.
Yep (or an equivalent hardcoded version that we export that from).
If they're optional they're not required, right? :-) |
@amitgalitz is this still something that needs to be done or does the existing required/optional keys satisfy it? |
I might be wrong but I think the optional keys satisfy almost all cases, for example if we want to add this API:
we would be able to add However I only really thought of this case now but I was wondering if we ever wanted to add an API like this: We currently don't have any API onboarded that uses this as its mostly for GET apis but we can either have a separate issue for that or utilize this one if we currently wont support this out of the block. Also fair to only really label this when we encounter such an API and not over-engineer |
We'd have to manually parse the param ( I think the biggest concern here is that if you look at the REST API docs corresponding to some of our steps there are a lot more params included, we only use a subset of them in many cases. |
@amitgalitz revisiting this in response to this comment
In the observability example we may want to perform the same workflow steps on multiple different workflows, so you'd have a setup where you'd create a workflow and when you provision it, you'd pass a parameter. So for example you'd call
Somewhere in the template you'd reference "index_name" somehow, likely as a substitution. Two main approaches I see.
{
"id": "reindex_old_otel_spans_index_to_new",
"type": "rest_api",
"previous_node_inputs": {
"http_client": "client"
},
"required_path_params" : ["index_name"]
"method": "POST",
"endpoint": "_reindex",
"body": {
"source": {
"index": "otel-v1-apm-span-*"
},
"dest": {
"index": "${{index_name}}"
},
"script": {
"source": "ctx._source['@timestamp'] = ctx._source.startTime;"
}
}
} The second option would allow us to validate the params in the call before executing the workflow (by including "required_path_params"). We already include the @amitgalitz, @YANG-DB, WDYT? |
@amitgalitz I see you proposed something similar to my above approach in #496 but with the key/value in the body rather than path. This could work but adds the complexity of parsing the body into a key-value map. |
@dbwiddis Adding optional parameters to the path can overload the path. I liked what @amitgalitz has proposed in the issue with the key/value pair
This way we can read any number of optional params and making the path looks much simpler. |
Why is this a problem?
This doesn't address the use case of a user creating a template with an arbitrary number of params we do not know in advance.
I can make path or body optional (with body style described in #496) but I don't want to prevent people from using whichever one they want. |
If we have a template with multiple steps, the question arises: How do we assign parameters for each workflow step? With the proposed implementation, is there a mechanism to designate an associated workflow step before the parameter? For example:
If we pass
wouldn't
In #496, the focus is on making our sample templates dynamic. Some fields can be made dynamic, necessitating user input. For the remaining fields, if the user provides input, we can update them; otherwise, we can use the default values. This way we can reduce the size of the payload for our create workflow API. It's fine we don't want to prevent people from using whichever they want, but that brings up the same question I stated above. |
Yes, if that's what's wanted. If not, then have the names be different, e.g.,
and call with
or
or
|
@amitgalitz I think between the use case templates with defaults and the substitutions, this has been completed, do you agree? |
Yes I believe so |
Is your feature request related to a problem?
Some APIs have optional additional params in there api path. For example:
POST /_plugins/_ml/models/_register
API has option to add?deploy=true
orGET _plugins/_anomaly_detection/detectors/<detectorId>/_profile?_all=true
API has the?_all=true
as an option.What solution would you like?
We should have a standard way of taking in this optional params as part of our template, whether it be designated in a workflow step like:
or some other mechanism to signify both that this is an optional parameter and that it is a part of the API path not the request payload.
We can also add this information on the workflow-step.json source of truth in the backend to register these optional params for the steps that require them.
The text was updated successfully, but these errors were encountered: