-
Notifications
You must be signed in to change notification settings - Fork 53
breaking: define CustomData as interface{} in Device and IPAddressCommon #225
base: master
Are you sure you want to change the base?
breaking: define CustomData as interface{} in Device and IPAddressCommon #225
Conversation
The API will accept and return CustomData with any JSON value or structure. The previous type (map[string]interface{}) did not allow for string only values, which are acceptable, as are ints, bools, and null. Signed-off-by: Marques Johansson <[email protected]>
Signed-off-by: Tomas Karasek <[email protected]>
I've jsut realized that it's not easy to unset the custom_data if we keep it interface{} and omitempty. If you set nil in the the DeviceUpdateRequests, the field will not be present in the HTTP PUT. If you put there updateCustomData = nil
_, _, err = c.Devices.Update(dID, &DeviceUpdateRequest{
CustomData: &updateCustomData,
}) then on the wires it will look as Funnily enough, when I try to update the device with updateCustomData = map[string]interface{}{}
_, _, err = c.Devices.Update(dID, &DeviceUpdateRequest{
CustomData: &updateCustomData,
}) .. which serializes to |
Signed-off-by: Tomas Karasek <[email protected]>
Outside of this patch, on the Device I was using 0.5.1 of packngo. I want to confirm this behavior (for this data type and others) because it is unexpected and changes how I would want to interact with this field.
It may also be helpful to verify that Metadata customdata can be fetched with This PR should include a table of tests for the values described here. |
@t0mk definitely a concern. We would need for |
I compiled following table where the columns are
.. I only tried with Device and only did the update (HTTP PUT). |
Cool! I’ve tried to submit more raw like data but didn’t mind needing to make a full object. None of these comments seem concerning to me 🙂
…On Mon, Dec 14, 2020, at 10:42 PM, Marques Johansson wrote:
Thanks, @t0mk <https://github.com/t0mk>. I think we'll be able to refer to this table as we continue to build CustomData support and we can certainly refer users here for specific needs.
I believe @grahamc <https://github.com/grahamc> has been using customdata, I'm curious if he's run into any of these edge cases.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#225 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAASXLDTLREKAAPVPZACP6TSU3LKPANCNFSM4UY3MPYA>.
|
@grahamc as @displague probably foresees as well, the fact that EM API will return different value than you store for the It might still be possible to make it a parameter with Optional: true, and ForceNew: false; but it would be more clean to try to fix it from the API side. It's not too likely though IMO. |
Noting that this is related to #221 which added CustomData for IPReservation resources. |
I stumbled upon https://golang.org/pkg/encoding/json/#RawMessage and wondered if this might be a type to use in our CustomData fields. |
Project.CustomData should also be exposed. Upon revisiting this issue, |
The API will accept and return CustomData with any JSON value or
structure. The previous type (map[string]interface{}) did not allow for
string only values, which are acceptable, as are ints, bools, and null.
Signed-off-by: Marques Johansson [email protected]