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
import path of package in question, e.g. .../services/compute/mgmt/2018-06-01/compute /Azure/azure-sdk-for-go/services/network/mgmt/2020-07-01/network/
SDK version e.g. master, latest, 18.1.0
v50.1.0
output of go version go version go1.15.6 linux/amd64
What happened?
Breaking change.
In the API version 2020-07-01, InterfacePropertiesFormat and its MarshalJSON looks like this:
// InterfacePropertiesFormat networkInterface properties.
type InterfacePropertiesFormat struct {
// VirtualMachine - READ-ONLY; The reference to a virtual machine.
VirtualMachine *SubResource `json:"virtualMachine,omitempty"`
// NetworkSecurityGroup - The reference to the NetworkSecurityGroup resource.
NetworkSecurityGroup *SecurityGroup `json:"networkSecurityGroup,omitempty"`
// PrivateEndpoint - READ-ONLY; A reference to the private endpoint to which the network interface is linked.
PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"`
// IPConfigurations - A list of IPConfigurations of the network interface.
IPConfigurations *[]InterfaceIPConfiguration `json:"ipConfigurations,omitempty"`
// TapConfigurations - READ-ONLY; A list of TapConfigurations of the network interface.
TapConfigurations *[]InterfaceTapConfiguration `json:"tapConfigurations,omitempty"`
// DNSSettings - The DNS settings in network interface.
DNSSettings *InterfaceDNSSettings `json:"dnsSettings,omitempty"`
// MacAddress - READ-ONLY; The MAC address of the network interface.
MacAddress *string `json:"macAddress,omitempty"`
// Primary - READ-ONLY; Whether this is a primary network interface on a virtual machine.
Primary *bool `json:"primary,omitempty"`
// EnableAcceleratedNetworking - If the network interface is accelerated networking enabled.
EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"`
// EnableIPForwarding - Indicates whether IP forwarding is enabled on this network interface.
EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"`
// HostedWorkloads - READ-ONLY; A list of references to linked BareMetal resources.
HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"`
// DscpConfiguration - READ-ONLY; A reference to the dscp configuration to which the network interface is linked.
DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"`
// ResourceGUID - READ-ONLY; The resource GUID property of the network interface resource.
ResourceGUID *string `json:"resourceGuid,omitempty"`
// ProvisioningState - READ-ONLY; The provisioning state of the network interface resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed'
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
}
// MarshalJSON is the custom marshaler for InterfacePropertiesFormat.
func (ipf InterfacePropertiesFormat) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ipf.NetworkSecurityGroup != nil {
objectMap["networkSecurityGroup"] = ipf.NetworkSecurityGroup
}
if ipf.IPConfigurations != nil {
objectMap["ipConfigurations"] = ipf.IPConfigurations
}
if ipf.DNSSettings != nil {
objectMap["dnsSettings"] = ipf.DNSSettings
}
if ipf.EnableAcceleratedNetworking != nil {
objectMap["enableAcceleratedNetworking"] = ipf.EnableAcceleratedNetworking
}
if ipf.EnableIPForwarding != nil {
objectMap["enableIPForwarding"] = ipf.EnableIPForwarding
}
return json.Marshal(objectMap)
}
If you look at an older API version such as 2019-06-01, you will notice that the MarshalJSON for InterfacePropertiesFormat has a lot more fields that are being marshalled.
// MarshalJSON is the custom marshaler for InterfacePropertiesFormat.
func (ipf InterfacePropertiesFormat) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ipf.NetworkSecurityGroup != nil {
objectMap["networkSecurityGroup"] = ipf.NetworkSecurityGroup
}
if ipf.IPConfigurations != nil {
objectMap["ipConfigurations"] = ipf.IPConfigurations
}
if ipf.TapConfigurations != nil {
objectMap["tapConfigurations"] = ipf.TapConfigurations
}
if ipf.DNSSettings != nil {
objectMap["dnsSettings"] = ipf.DNSSettings
}
if ipf.MacAddress != nil {
objectMap["macAddress"] = ipf.MacAddress
}
if ipf.Primary != nil {
objectMap["primary"] = ipf.Primary
}
if ipf.EnableAcceleratedNetworking != nil {
objectMap["enableAcceleratedNetworking"] = ipf.EnableAcceleratedNetworking
}
if ipf.EnableIPForwarding != nil {
objectMap["enableIPForwarding"] = ipf.EnableIPForwarding
}
if ipf.ResourceGUID != nil {
objectMap["resourceGuid"] = ipf.ResourceGUID
}
if ipf.ProvisioningState != nil {
objectMap["provisioningState"] = ipf.ProvisioningState
}
return json.Marshal(objectMap)
}
ghost
removed
the
needs-triage
Workflow: This is a new issue that needs to be triaged to the appropriate team.
label
Feb 3, 2021
ArcturusZhang
added
the
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
label
Feb 3, 2021
Unfortunately I have to say this is by design. Internally the SDK relies on the marshalling functionality to transform a go SDK struct into the JSON body in a REST API request in which we cannot have the readOnly properties. Therefore you might notice those missing parts in the marshaller all correspond to a read only property (you could find the read only note in the comment of that property).
We have received an issue discussing about this problem which is more general, and we are planning to do something to improve this, please stay tuned.
In the meantime, I will close this issue in favor of #12227
Bug Report
.../services/compute/mgmt/2018-06-01/compute
/Azure/azure-sdk-for-go/services/network/mgmt/2020-07-01/network/
master
,latest
,18.1.0
v50.1.0
go version
go version go1.15.6 linux/amd64
Breaking change.
In the API version 2020-07-01,
InterfacePropertiesFormat
and itsMarshalJSON
looks like this:https://raw.githubusercontent.com/Azure/azure-sdk-for-go/master/services/network/mgmt/2020-07-01/network/models.go
If you look at an older API version such as 2019-06-01, you will notice that the
MarshalJSON
forInterfacePropertiesFormat
has a lot more fields that are being marshalled.https://raw.githubusercontent.com/Azure/azure-sdk-for-go/master/services/network/mgmt/2019-06-01/network/models.go
Looking at the swagger spec, nothing stands out so it is strange that these fields were left out.
https://github.com/Azure/azure-rest-api-specs/blob/d70b7cc88d45ef55484c26251f4d5497f12b5dad/specification/network/resource-manager/Microsoft.Network/stable/2020-07-01/networkInterface.json#L1160
Is this by design?
The text was updated successfully, but these errors were encountered: