You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to unmarshal a json file containing an ISM policy into the ism.Policy struct. The documentation for the allocation action specifies that the require value be of type string. This is also the type that the go struct'srequire value is.
However in the example in the docs, it shows that the value really should be an object.
"allocation": {
"require": { "temp": "warm" }
}
and this is also what is expected by the Opensearch server.
If I encode the json as a string, i.e. "{ \"temp\": \"warm\" }", I can then marshal it into the go struct, but the server will then throw a parsing error saying that it expects an Object, not a String.
A similar thing happens with the wait_for field. The docs and go struct specify it needs to be a string, but the server expects a bool.
How can one reproduce the bug?
Attempt to json marshal the below json into an ism.Policy struct.
The above json is what the opensearch server expects. If you directly send the above json to the server like so, it will succeed.
// create ism client, open policy json file above and load policyContentsreq, err:=opensearch.BuildRequest(http.MethodPut,
"/_plugins/_ism/policies/myindex_policy",
strings.NewReader(policyContents),
nil, nil)
iferr!=nil {
returnfmt.Errorf("failed to create ISM policy request for myindex: %w", err)
}
resp, err:=ismClient.Client.Perform(req)
iferr!=nil {
returnfmt.Errorf("failed to create ISM policy for myindex: %w", err)
}
ifresp.StatusCode==http.StatusCreated {
returnnil
}
I think the documentation needs to be updated to say that it accepts an object, which would allow the go struct value to be a type of map[string]string or json.RawMessage or whatever is deemed fit.
What is your host/environment?
Operating system, version.
Do you have any screenshots?
If applicable, add screenshots to help explain your problem.
Do you have any additional context?
Add any other context about the problem.
The text was updated successfully, but these errors were encountered:
There's an effort to generate some of this from spec @kellen-miller, see #284. Would be helpful if you want to ensure these APIs are present and properly documented in the spec itself?
What is the bug?
I'm attempting to unmarshal a json file containing an ISM policy into the ism.Policy struct. The documentation for the allocation action specifies that the
require
value be of type string. This is also the type that the go struct'srequire
value is.However in the example in the docs, it shows that the value really should be an object.
and this is also what is expected by the Opensearch server.
If I encode the json as a string, i.e.
"{ \"temp\": \"warm\" }"
, I can then marshal it into the go struct, but the server will then throw a parsing error saying that it expects an Object, not a String.A similar thing happens with the wait_for field. The docs and go struct specify it needs to be a string, but the server expects a bool.
How can one reproduce the bug?
Attempt to json marshal the below json into an ism.Policy struct.
policyContent
What is the expected behavior?
The above json is what the opensearch server expects. If you directly send the above json to the server like so, it will succeed.
I think the documentation needs to be updated to say that it accepts an object, which would allow the go struct value to be a type of
map[string]string
orjson.RawMessage
or whatever is deemed fit.What is your host/environment?
Operating system, version.
Do you have any screenshots?
If applicable, add screenshots to help explain your problem.
Do you have any additional context?
Add any other context about the problem.
The text was updated successfully, but these errors were encountered: