sdk/resourcemanager/storsimple1200series/armstorsimple1200series/models_serde.go (3,683 lines of code) (raw):

//go:build go1.18 // +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. package armstorsimple1200series import ( "encoding/json" "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "reflect" ) // MarshalJSON implements the json.Marshaller interface for type AccessControlRecord. func (a AccessControlRecord) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) populate(objectMap, "type", a.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AccessControlRecord. func (a *AccessControlRecord) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &a.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AccessControlRecordList. func (a AccessControlRecordList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AccessControlRecordList. func (a *AccessControlRecordList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AccessControlRecordProperties. func (a AccessControlRecordProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "initiatorName", a.InitiatorName) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AccessControlRecordProperties. func (a *AccessControlRecordProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "initiatorName": err = unpopulate(val, "InitiatorName", &a.InitiatorName) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Alert. func (a Alert) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) populate(objectMap, "type", a.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Alert. func (a *Alert) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &a.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AlertErrorDetails. func (a AlertErrorDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "errorCode", a.ErrorCode) populate(objectMap, "errorMessage", a.ErrorMessage) populate(objectMap, "occurences", a.Occurences) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AlertErrorDetails. func (a *AlertErrorDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "errorCode": err = unpopulate(val, "ErrorCode", &a.ErrorCode) delete(rawMsg, key) case "errorMessage": err = unpopulate(val, "ErrorMessage", &a.ErrorMessage) delete(rawMsg, key) case "occurences": err = unpopulate(val, "Occurences", &a.Occurences) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AlertFilter. func (a AlertFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populateDateTimeRFC3339(objectMap, "appearedOnTime", a.AppearedOnTime) populate(objectMap, "severity", a.Severity) populate(objectMap, "sourceName", a.SourceName) populate(objectMap, "sourceType", a.SourceType) populate(objectMap, "status", a.Status) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AlertFilter. func (a *AlertFilter) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "appearedOnTime": err = unpopulateDateTimeRFC3339(val, "AppearedOnTime", &a.AppearedOnTime) delete(rawMsg, key) case "severity": err = unpopulate(val, "Severity", &a.Severity) delete(rawMsg, key) case "sourceName": err = unpopulate(val, "SourceName", &a.SourceName) delete(rawMsg, key) case "sourceType": err = unpopulate(val, "SourceType", &a.SourceType) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &a.Status) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AlertList. func (a AlertList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AlertList. func (a *AlertList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "nextLink": err = unpopulate(val, "NextLink", &a.NextLink) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AlertProperties. func (a AlertProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "alertType", a.AlertType) populateDateTimeRFC3339(objectMap, "appearedAtSourceTime", a.AppearedAtSourceTime) populateDateTimeRFC3339(objectMap, "appearedAtTime", a.AppearedAtTime) populateDateTimeRFC3339(objectMap, "clearedAtSourceTime", a.ClearedAtSourceTime) populateDateTimeRFC3339(objectMap, "clearedAtTime", a.ClearedAtTime) populate(objectMap, "detailedInformation", a.DetailedInformation) populate(objectMap, "errorDetails", a.ErrorDetails) populate(objectMap, "recommendation", a.Recommendation) populate(objectMap, "resolutionReason", a.ResolutionReason) populate(objectMap, "scope", a.Scope) populate(objectMap, "severity", a.Severity) populate(objectMap, "source", a.Source) populate(objectMap, "status", a.Status) populate(objectMap, "title", a.Title) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AlertProperties. func (a *AlertProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "alertType": err = unpopulate(val, "AlertType", &a.AlertType) delete(rawMsg, key) case "appearedAtSourceTime": err = unpopulateDateTimeRFC3339(val, "AppearedAtSourceTime", &a.AppearedAtSourceTime) delete(rawMsg, key) case "appearedAtTime": err = unpopulateDateTimeRFC3339(val, "AppearedAtTime", &a.AppearedAtTime) delete(rawMsg, key) case "clearedAtSourceTime": err = unpopulateDateTimeRFC3339(val, "ClearedAtSourceTime", &a.ClearedAtSourceTime) delete(rawMsg, key) case "clearedAtTime": err = unpopulateDateTimeRFC3339(val, "ClearedAtTime", &a.ClearedAtTime) delete(rawMsg, key) case "detailedInformation": err = unpopulate(val, "DetailedInformation", &a.DetailedInformation) delete(rawMsg, key) case "errorDetails": err = unpopulate(val, "ErrorDetails", &a.ErrorDetails) delete(rawMsg, key) case "recommendation": err = unpopulate(val, "Recommendation", &a.Recommendation) delete(rawMsg, key) case "resolutionReason": err = unpopulate(val, "ResolutionReason", &a.ResolutionReason) delete(rawMsg, key) case "scope": err = unpopulate(val, "Scope", &a.Scope) delete(rawMsg, key) case "severity": err = unpopulate(val, "Severity", &a.Severity) delete(rawMsg, key) case "source": err = unpopulate(val, "Source", &a.Source) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &a.Status) delete(rawMsg, key) case "title": err = unpopulate(val, "Title", &a.Title) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AlertSettings. func (a AlertSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) populate(objectMap, "type", a.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AlertSettings. func (a *AlertSettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &a.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AlertSettingsProperties. func (a AlertSettingsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "additionalRecipientEmailList", a.AdditionalRecipientEmailList) populate(objectMap, "alertNotificationCulture", a.AlertNotificationCulture) populate(objectMap, "emailNotification", a.EmailNotification) populate(objectMap, "notificationToServiceOwners", a.NotificationToServiceOwners) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AlertSettingsProperties. func (a *AlertSettingsProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "additionalRecipientEmailList": err = unpopulate(val, "AdditionalRecipientEmailList", &a.AdditionalRecipientEmailList) delete(rawMsg, key) case "alertNotificationCulture": err = unpopulate(val, "AlertNotificationCulture", &a.AlertNotificationCulture) delete(rawMsg, key) case "emailNotification": err = unpopulate(val, "EmailNotification", &a.EmailNotification) delete(rawMsg, key) case "notificationToServiceOwners": err = unpopulate(val, "NotificationToServiceOwners", &a.NotificationToServiceOwners) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AlertSource. func (a AlertSource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "alertSourceType", a.AlertSourceType) populate(objectMap, "name", a.Name) populate(objectMap, "timeZone", a.TimeZone) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AlertSource. func (a *AlertSource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "alertSourceType": err = unpopulate(val, "AlertSourceType", &a.AlertSourceType) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) case "timeZone": err = unpopulate(val, "TimeZone", &a.TimeZone) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AsymmetricEncryptedSecret. func (a AsymmetricEncryptedSecret) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "encryptionAlgorithm", a.EncryptionAlgorithm) populate(objectMap, "encryptionCertificateThumbprint", a.EncryptionCertificateThumbprint) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AsymmetricEncryptedSecret. func (a *AsymmetricEncryptedSecret) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "encryptionAlgorithm": err = unpopulate(val, "EncryptionAlgorithm", &a.EncryptionAlgorithm) delete(rawMsg, key) case "encryptionCertificateThumbprint": err = unpopulate(val, "EncryptionCertificateThumbprint", &a.EncryptionCertificateThumbprint) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AvailableProviderOperation. func (a AvailableProviderOperation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "display", a.Display) populate(objectMap, "name", a.Name) populate(objectMap, "origin", a.Origin) populateAny(objectMap, "properties", a.Properties) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AvailableProviderOperation. func (a *AvailableProviderOperation) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "display": err = unpopulate(val, "Display", &a.Display) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &a.Name) delete(rawMsg, key) case "origin": err = unpopulate(val, "Origin", &a.Origin) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AvailableProviderOperationDisplay. func (a AvailableProviderOperationDisplay) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "description", a.Description) populate(objectMap, "operation", a.Operation) populate(objectMap, "provider", a.Provider) populate(objectMap, "resource", a.Resource) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AvailableProviderOperationDisplay. func (a *AvailableProviderOperationDisplay) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "description": err = unpopulate(val, "Description", &a.Description) delete(rawMsg, key) case "operation": err = unpopulate(val, "Operation", &a.Operation) delete(rawMsg, key) case "provider": err = unpopulate(val, "Provider", &a.Provider) delete(rawMsg, key) case "resource": err = unpopulate(val, "Resource", &a.Resource) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type AvailableProviderOperations. func (a AvailableProviderOperations) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type AvailableProviderOperations. func (a *AvailableProviderOperations) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } for key, val := range rawMsg { var err error switch key { case "nextLink": err = unpopulate(val, "NextLink", &a.NextLink) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &a.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", a, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Backup. func (b Backup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", b.ID) populate(objectMap, "name", b.Name) populate(objectMap, "properties", b.Properties) populate(objectMap, "type", b.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Backup. func (b *Backup) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &b.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &b.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &b.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &b.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BackupElement. func (b BackupElement) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", b.ID) populate(objectMap, "name", b.Name) populate(objectMap, "properties", b.Properties) populate(objectMap, "type", b.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BackupElement. func (b *BackupElement) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &b.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &b.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &b.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &b.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BackupElementProperties. func (b BackupElementProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "dataPolicy", b.DataPolicy) populate(objectMap, "endpointName", b.EndpointName) populate(objectMap, "sizeInBytes", b.SizeInBytes) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BackupElementProperties. func (b *BackupElementProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "dataPolicy": err = unpopulate(val, "DataPolicy", &b.DataPolicy) delete(rawMsg, key) case "endpointName": err = unpopulate(val, "EndpointName", &b.EndpointName) delete(rawMsg, key) case "sizeInBytes": err = unpopulate(val, "SizeInBytes", &b.SizeInBytes) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BackupFilter. func (b BackupFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populateDateTimeRFC3339(objectMap, "createdTime", b.CreatedTime) populate(objectMap, "initiatedBy", b.InitiatedBy) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BackupFilter. func (b *BackupFilter) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "createdTime": err = unpopulateDateTimeRFC3339(val, "CreatedTime", &b.CreatedTime) delete(rawMsg, key) case "initiatedBy": err = unpopulate(val, "InitiatedBy", &b.InitiatedBy) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BackupList. func (b BackupList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", b.NextLink) populate(objectMap, "value", b.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BackupList. func (b *BackupList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "nextLink": err = unpopulate(val, "NextLink", &b.NextLink) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &b.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BackupProperties. func (b BackupProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populateDateTimeRFC3339(objectMap, "createdTime", b.CreatedTime) populate(objectMap, "deviceId", b.DeviceID) populate(objectMap, "elements", b.Elements) populateDateTimeRFC3339(objectMap, "expirationTime", b.ExpirationTime) populate(objectMap, "initiatedBy", b.InitiatedBy) populate(objectMap, "sizeInBytes", b.SizeInBytes) populate(objectMap, "targetId", b.TargetID) populate(objectMap, "targetType", b.TargetType) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BackupProperties. func (b *BackupProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "createdTime": err = unpopulateDateTimeRFC3339(val, "CreatedTime", &b.CreatedTime) delete(rawMsg, key) case "deviceId": err = unpopulate(val, "DeviceID", &b.DeviceID) delete(rawMsg, key) case "elements": err = unpopulate(val, "Elements", &b.Elements) delete(rawMsg, key) case "expirationTime": err = unpopulateDateTimeRFC3339(val, "ExpirationTime", &b.ExpirationTime) delete(rawMsg, key) case "initiatedBy": err = unpopulate(val, "InitiatedBy", &b.InitiatedBy) delete(rawMsg, key) case "sizeInBytes": err = unpopulate(val, "SizeInBytes", &b.SizeInBytes) delete(rawMsg, key) case "targetId": err = unpopulate(val, "TargetID", &b.TargetID) delete(rawMsg, key) case "targetType": err = unpopulate(val, "TargetType", &b.TargetType) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BackupScheduleGroup. func (b BackupScheduleGroup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", b.ID) populate(objectMap, "name", b.Name) populate(objectMap, "properties", b.Properties) populate(objectMap, "type", b.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BackupScheduleGroup. func (b *BackupScheduleGroup) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &b.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &b.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &b.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &b.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BackupScheduleGroupList. func (b BackupScheduleGroupList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", b.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BackupScheduleGroupList. func (b *BackupScheduleGroupList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &b.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BackupScheduleGroupProperties. func (b BackupScheduleGroupProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "startTime", b.StartTime) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BackupScheduleGroupProperties. func (b *BackupScheduleGroupProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "startTime": err = unpopulate(val, "StartTime", &b.StartTime) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type BaseModel. func (b BaseModel) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", b.ID) populate(objectMap, "name", b.Name) populate(objectMap, "type", b.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type BaseModel. func (b *BaseModel) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &b.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &b.Name) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &b.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", b, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ChapProperties. func (c ChapProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "password", c.Password) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ChapProperties. func (c *ChapProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { case "password": err = unpopulate(val, "Password", &c.Password) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ChapSettings. func (c ChapSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) populate(objectMap, "type", c.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ChapSettings. func (c *ChapSettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &c.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &c.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &c.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ChapSettingsList. func (c ChapSettingsList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ChapSettingsList. func (c *ChapSettingsList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &c.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ClearAlertRequest. func (c ClearAlertRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "alerts", c.Alerts) populate(objectMap, "resolutionMessage", c.ResolutionMessage) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ClearAlertRequest. func (c *ClearAlertRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { case "alerts": err = unpopulate(val, "Alerts", &c.Alerts) delete(rawMsg, key) case "resolutionMessage": err = unpopulate(val, "ResolutionMessage", &c.ResolutionMessage) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type CloneRequest. func (c CloneRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "properties", c.Properties) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type CloneRequest. func (c *CloneRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { case "properties": err = unpopulate(val, "Properties", &c.Properties) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type CloneRequestProperties. func (c CloneRequestProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "disk", c.Disk) populate(objectMap, "newEndpointName", c.NewEndpointName) populate(objectMap, "share", c.Share) populate(objectMap, "targetAccessPointId", c.TargetAccessPointID) populate(objectMap, "targetDeviceId", c.TargetDeviceID) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type CloneRequestProperties. func (c *CloneRequestProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } for key, val := range rawMsg { var err error switch key { case "disk": err = unpopulate(val, "Disk", &c.Disk) delete(rawMsg, key) case "newEndpointName": err = unpopulate(val, "NewEndpointName", &c.NewEndpointName) delete(rawMsg, key) case "share": err = unpopulate(val, "Share", &c.Share) delete(rawMsg, key) case "targetAccessPointId": err = unpopulate(val, "TargetAccessPointID", &c.TargetAccessPointID) delete(rawMsg, key) case "targetDeviceId": err = unpopulate(val, "TargetDeviceID", &c.TargetDeviceID) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Device. func (d Device) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "name", d.Name) populate(objectMap, "properties", d.Properties) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Device. func (d *Device) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &d.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &d.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &d.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type DeviceDetails. func (d DeviceDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "availableLocalStorageInBytes", d.AvailableLocalStorageInBytes) populate(objectMap, "availableStorageInBytes", d.AvailableStorageInBytes) populate(objectMap, "endpointCount", d.EndpointCount) populate(objectMap, "provisionedLocalStorageInBytes", d.ProvisionedLocalStorageInBytes) populate(objectMap, "provisionedStorageInBytes", d.ProvisionedStorageInBytes) populate(objectMap, "totalBackupSizeInBytes", d.TotalBackupSizeInBytes) populate(objectMap, "totalLocalStorageInBytes", d.TotalLocalStorageInBytes) populate(objectMap, "totalStorageInBytes", d.TotalStorageInBytes) populate(objectMap, "usingLocalStorageInBytes", d.UsingLocalStorageInBytes) populate(objectMap, "usingStorageInBytes", d.UsingStorageInBytes) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type DeviceDetails. func (d *DeviceDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { case "availableLocalStorageInBytes": err = unpopulate(val, "AvailableLocalStorageInBytes", &d.AvailableLocalStorageInBytes) delete(rawMsg, key) case "availableStorageInBytes": err = unpopulate(val, "AvailableStorageInBytes", &d.AvailableStorageInBytes) delete(rawMsg, key) case "endpointCount": err = unpopulate(val, "EndpointCount", &d.EndpointCount) delete(rawMsg, key) case "provisionedLocalStorageInBytes": err = unpopulate(val, "ProvisionedLocalStorageInBytes", &d.ProvisionedLocalStorageInBytes) delete(rawMsg, key) case "provisionedStorageInBytes": err = unpopulate(val, "ProvisionedStorageInBytes", &d.ProvisionedStorageInBytes) delete(rawMsg, key) case "totalBackupSizeInBytes": err = unpopulate(val, "TotalBackupSizeInBytes", &d.TotalBackupSizeInBytes) delete(rawMsg, key) case "totalLocalStorageInBytes": err = unpopulate(val, "TotalLocalStorageInBytes", &d.TotalLocalStorageInBytes) delete(rawMsg, key) case "totalStorageInBytes": err = unpopulate(val, "TotalStorageInBytes", &d.TotalStorageInBytes) delete(rawMsg, key) case "usingLocalStorageInBytes": err = unpopulate(val, "UsingLocalStorageInBytes", &d.UsingLocalStorageInBytes) delete(rawMsg, key) case "usingStorageInBytes": err = unpopulate(val, "UsingStorageInBytes", &d.UsingStorageInBytes) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type DeviceList. func (d DeviceList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type DeviceList. func (d *DeviceList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &d.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type DevicePatch. func (d DevicePatch) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "deviceDescription", d.DeviceDescription) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type DevicePatch. func (d *DevicePatch) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { case "deviceDescription": err = unpopulate(val, "DeviceDescription", &d.DeviceDescription) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type DeviceProperties. func (d DeviceProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populateDateTimeRFC3339(objectMap, "activationTime", d.ActivationTime) populate(objectMap, "allowedDeviceOperations", d.AllowedDeviceOperations) populate(objectMap, "culture", d.Culture) populate(objectMap, "details", d.Details) populate(objectMap, "deviceCapabilities", d.DeviceCapabilities) populate(objectMap, "deviceConfigurationStatus", d.DeviceConfigurationStatus) populate(objectMap, "deviceDescription", d.DeviceDescription) populate(objectMap, "deviceSoftwareVersion", d.DeviceSoftwareVersion) populate(objectMap, "domainName", d.DomainName) populate(objectMap, "friendlySoftwareName", d.FriendlySoftwareName) populate(objectMap, "modelDescription", d.ModelDescription) populate(objectMap, "status", d.Status) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type DeviceProperties. func (d *DeviceProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { case "activationTime": err = unpopulateDateTimeRFC3339(val, "ActivationTime", &d.ActivationTime) delete(rawMsg, key) case "allowedDeviceOperations": err = unpopulate(val, "AllowedDeviceOperations", &d.AllowedDeviceOperations) delete(rawMsg, key) case "culture": err = unpopulate(val, "Culture", &d.Culture) delete(rawMsg, key) case "details": err = unpopulate(val, "Details", &d.Details) delete(rawMsg, key) case "deviceCapabilities": err = unpopulate(val, "DeviceCapabilities", &d.DeviceCapabilities) delete(rawMsg, key) case "deviceConfigurationStatus": err = unpopulate(val, "DeviceConfigurationStatus", &d.DeviceConfigurationStatus) delete(rawMsg, key) case "deviceDescription": err = unpopulate(val, "DeviceDescription", &d.DeviceDescription) delete(rawMsg, key) case "deviceSoftwareVersion": err = unpopulate(val, "DeviceSoftwareVersion", &d.DeviceSoftwareVersion) delete(rawMsg, key) case "domainName": err = unpopulate(val, "DomainName", &d.DomainName) delete(rawMsg, key) case "friendlySoftwareName": err = unpopulate(val, "FriendlySoftwareName", &d.FriendlySoftwareName) delete(rawMsg, key) case "modelDescription": err = unpopulate(val, "ModelDescription", &d.ModelDescription) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &d.Status) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type EncryptionSettings. func (e EncryptionSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", e.ID) populate(objectMap, "name", e.Name) populate(objectMap, "properties", e.Properties) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionSettings. func (e *EncryptionSettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &e.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &e.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &e.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type EncryptionSettingsProperties. func (e EncryptionSettingsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "encryptionStatus", e.EncryptionStatus) populate(objectMap, "keyRolloverStatus", e.KeyRolloverStatus) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionSettingsProperties. func (e *EncryptionSettingsProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { case "encryptionStatus": err = unpopulate(val, "EncryptionStatus", &e.EncryptionStatus) delete(rawMsg, key) case "keyRolloverStatus": err = unpopulate(val, "KeyRolloverStatus", &e.KeyRolloverStatus) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Error. func (e Error) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "errorCode", e.ErrorCode) populate(objectMap, "message", e.Message) populate(objectMap, "values", e.Values) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Error. func (e *Error) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { case "errorCode": err = unpopulate(val, "ErrorCode", &e.ErrorCode) delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &e.Message) delete(rawMsg, key) case "values": err = unpopulate(val, "Values", &e.Values) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type FailoverRequest. func (f FailoverRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "accesspointIds", f.AccesspointIDs) populate(objectMap, "keepSourceDevice", f.KeepSourceDevice) populate(objectMap, "skipValidation", f.SkipValidation) populate(objectMap, "targetDeviceId", f.TargetDeviceID) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type FailoverRequest. func (f *FailoverRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { case "accesspointIds": err = unpopulate(val, "AccesspointIDs", &f.AccesspointIDs) delete(rawMsg, key) case "keepSourceDevice": err = unpopulate(val, "KeepSourceDevice", &f.KeepSourceDevice) delete(rawMsg, key) case "skipValidation": err = unpopulate(val, "SkipValidation", &f.SkipValidation) delete(rawMsg, key) case "targetDeviceId": err = unpopulate(val, "TargetDeviceID", &f.TargetDeviceID) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type FileServer. func (f FileServer) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", f.ID) populate(objectMap, "name", f.Name) populate(objectMap, "properties", f.Properties) populate(objectMap, "type", f.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type FileServer. func (f *FileServer) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &f.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &f.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &f.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &f.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type FileServerList. func (f FileServerList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", f.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type FileServerList. func (f *FileServerList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &f.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type FileServerProperties. func (f FileServerProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "backupScheduleGroupId", f.BackupScheduleGroupID) populate(objectMap, "description", f.Description) populate(objectMap, "domainName", f.DomainName) populate(objectMap, "storageDomainId", f.StorageDomainID) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type FileServerProperties. func (f *FileServerProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { case "backupScheduleGroupId": err = unpopulate(val, "BackupScheduleGroupID", &f.BackupScheduleGroupID) delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &f.Description) delete(rawMsg, key) case "domainName": err = unpopulate(val, "DomainName", &f.DomainName) delete(rawMsg, key) case "storageDomainId": err = unpopulate(val, "StorageDomainID", &f.StorageDomainID) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type FileShare. func (f FileShare) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", f.ID) populate(objectMap, "name", f.Name) populate(objectMap, "properties", f.Properties) populate(objectMap, "type", f.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type FileShare. func (f *FileShare) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &f.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &f.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &f.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &f.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type FileShareList. func (f FileShareList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", f.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type FileShareList. func (f *FileShareList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &f.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type FileShareProperties. func (f FileShareProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "adminUser", f.AdminUser) populate(objectMap, "dataPolicy", f.DataPolicy) populate(objectMap, "description", f.Description) populate(objectMap, "localUsedCapacityInBytes", f.LocalUsedCapacityInBytes) populate(objectMap, "monitoringStatus", f.MonitoringStatus) populate(objectMap, "provisionedCapacityInBytes", f.ProvisionedCapacityInBytes) populate(objectMap, "shareStatus", f.ShareStatus) populate(objectMap, "usedCapacityInBytes", f.UsedCapacityInBytes) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type FileShareProperties. func (f *FileShareProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } for key, val := range rawMsg { var err error switch key { case "adminUser": err = unpopulate(val, "AdminUser", &f.AdminUser) delete(rawMsg, key) case "dataPolicy": err = unpopulate(val, "DataPolicy", &f.DataPolicy) delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &f.Description) delete(rawMsg, key) case "localUsedCapacityInBytes": err = unpopulate(val, "LocalUsedCapacityInBytes", &f.LocalUsedCapacityInBytes) delete(rawMsg, key) case "monitoringStatus": err = unpopulate(val, "MonitoringStatus", &f.MonitoringStatus) delete(rawMsg, key) case "provisionedCapacityInBytes": err = unpopulate(val, "ProvisionedCapacityInBytes", &f.ProvisionedCapacityInBytes) delete(rawMsg, key) case "shareStatus": err = unpopulate(val, "ShareStatus", &f.ShareStatus) delete(rawMsg, key) case "usedCapacityInBytes": err = unpopulate(val, "UsedCapacityInBytes", &f.UsedCapacityInBytes) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", f, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type IPConfig. func (i IPConfig) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "gateway", i.Gateway) populate(objectMap, "ipAddress", i.IPAddress) populate(objectMap, "prefixLength", i.PrefixLength) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type IPConfig. func (i *IPConfig) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "gateway": err = unpopulate(val, "Gateway", &i.Gateway) delete(rawMsg, key) case "ipAddress": err = unpopulate(val, "IPAddress", &i.IPAddress) delete(rawMsg, key) case "prefixLength": err = unpopulate(val, "PrefixLength", &i.PrefixLength) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ISCSIDisk. func (i ISCSIDisk) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "name", i.Name) populate(objectMap, "properties", i.Properties) populate(objectMap, "type", i.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ISCSIDisk. func (i *ISCSIDisk) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &i.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &i.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &i.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &i.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ISCSIDiskList. func (i ISCSIDiskList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ISCSIDiskList. func (i *ISCSIDiskList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ISCSIDiskProperties. func (i ISCSIDiskProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "accessControlRecords", i.AccessControlRecords) populate(objectMap, "dataPolicy", i.DataPolicy) populate(objectMap, "description", i.Description) populate(objectMap, "diskStatus", i.DiskStatus) populate(objectMap, "localUsedCapacityInBytes", i.LocalUsedCapacityInBytes) populate(objectMap, "monitoringStatus", i.MonitoringStatus) populate(objectMap, "provisionedCapacityInBytes", i.ProvisionedCapacityInBytes) populate(objectMap, "usedCapacityInBytes", i.UsedCapacityInBytes) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ISCSIDiskProperties. func (i *ISCSIDiskProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "accessControlRecords": err = unpopulate(val, "AccessControlRecords", &i.AccessControlRecords) delete(rawMsg, key) case "dataPolicy": err = unpopulate(val, "DataPolicy", &i.DataPolicy) delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &i.Description) delete(rawMsg, key) case "diskStatus": err = unpopulate(val, "DiskStatus", &i.DiskStatus) delete(rawMsg, key) case "localUsedCapacityInBytes": err = unpopulate(val, "LocalUsedCapacityInBytes", &i.LocalUsedCapacityInBytes) delete(rawMsg, key) case "monitoringStatus": err = unpopulate(val, "MonitoringStatus", &i.MonitoringStatus) delete(rawMsg, key) case "provisionedCapacityInBytes": err = unpopulate(val, "ProvisionedCapacityInBytes", &i.ProvisionedCapacityInBytes) delete(rawMsg, key) case "usedCapacityInBytes": err = unpopulate(val, "UsedCapacityInBytes", &i.UsedCapacityInBytes) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ISCSIServer. func (i ISCSIServer) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "name", i.Name) populate(objectMap, "properties", i.Properties) populate(objectMap, "type", i.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ISCSIServer. func (i *ISCSIServer) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &i.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &i.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &i.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &i.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ISCSIServerList. func (i ISCSIServerList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ISCSIServerList. func (i *ISCSIServerList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ISCSIServerProperties. func (i ISCSIServerProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "backupScheduleGroupId", i.BackupScheduleGroupID) populate(objectMap, "chapId", i.ChapID) populate(objectMap, "description", i.Description) populate(objectMap, "reverseChapId", i.ReverseChapID) populate(objectMap, "storageDomainId", i.StorageDomainID) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ISCSIServerProperties. func (i *ISCSIServerProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "backupScheduleGroupId": err = unpopulate(val, "BackupScheduleGroupID", &i.BackupScheduleGroupID) delete(rawMsg, key) case "chapId": err = unpopulate(val, "ChapID", &i.ChapID) delete(rawMsg, key) case "description": err = unpopulate(val, "Description", &i.Description) delete(rawMsg, key) case "reverseChapId": err = unpopulate(val, "ReverseChapID", &i.ReverseChapID) delete(rawMsg, key) case "storageDomainId": err = unpopulate(val, "StorageDomainID", &i.StorageDomainID) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Item. func (i Item) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "key", i.Key) populate(objectMap, "value", i.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Item. func (i *Item) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { case "key": err = unpopulate(val, "Key", &i.Key) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &i.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Job. func (j Job) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populateDateTimeRFC3339(objectMap, "endTime", j.EndTime) populate(objectMap, "error", j.Error) populate(objectMap, "id", j.ID) populate(objectMap, "name", j.Name) populate(objectMap, "percentComplete", j.PercentComplete) populate(objectMap, "properties", j.Properties) populateDateTimeRFC3339(objectMap, "startTime", j.StartTime) populate(objectMap, "status", j.Status) populate(objectMap, "type", j.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Job. func (j *Job) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } for key, val := range rawMsg { var err error switch key { case "endTime": err = unpopulateDateTimeRFC3339(val, "EndTime", &j.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &j.Error) delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &j.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &j.Name) delete(rawMsg, key) case "percentComplete": err = unpopulate(val, "PercentComplete", &j.PercentComplete) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &j.Properties) delete(rawMsg, key) case "startTime": err = unpopulateDateTimeRFC3339(val, "StartTime", &j.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &j.Status) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &j.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type JobErrorDetails. func (j JobErrorDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "code", j.Code) populate(objectMap, "errorDetails", j.ErrorDetails) populate(objectMap, "message", j.Message) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type JobErrorDetails. func (j *JobErrorDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } for key, val := range rawMsg { var err error switch key { case "code": err = unpopulate(val, "Code", &j.Code) delete(rawMsg, key) case "errorDetails": err = unpopulate(val, "ErrorDetails", &j.ErrorDetails) delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &j.Message) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type JobErrorItem. func (j JobErrorItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "code", j.Code) populate(objectMap, "message", j.Message) populate(objectMap, "recommendations", j.Recommendations) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type JobErrorItem. func (j *JobErrorItem) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } for key, val := range rawMsg { var err error switch key { case "code": err = unpopulate(val, "Code", &j.Code) delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &j.Message) delete(rawMsg, key) case "recommendations": err = unpopulate(val, "Recommendations", &j.Recommendations) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type JobFilter. func (j JobFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "jobType", j.JobType) populateDateTimeRFC3339(objectMap, "startTime", j.StartTime) populate(objectMap, "status", j.Status) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type JobFilter. func (j *JobFilter) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } for key, val := range rawMsg { var err error switch key { case "jobType": err = unpopulate(val, "JobType", &j.JobType) delete(rawMsg, key) case "startTime": err = unpopulateDateTimeRFC3339(val, "StartTime", &j.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &j.Status) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type JobList. func (j JobList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", j.NextLink) populate(objectMap, "value", j.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type JobList. func (j *JobList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } for key, val := range rawMsg { var err error switch key { case "nextLink": err = unpopulate(val, "NextLink", &j.NextLink) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &j.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type JobProperties. func (j JobProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populateDateTimeRFC3339(objectMap, "backupPointInTime", j.BackupPointInTime) populate(objectMap, "deviceId", j.DeviceID) populate(objectMap, "downloadProgress", j.DownloadProgress) populate(objectMap, "entityId", j.EntityID) populate(objectMap, "entityType", j.EntityType) populate(objectMap, "installProgress", j.InstallProgress) populate(objectMap, "isCancellable", j.IsCancellable) populate(objectMap, "jobStages", j.JobStages) populate(objectMap, "jobType", j.JobType) populate(objectMap, "sourceDeviceId", j.SourceDeviceID) populate(objectMap, "stats", j.Stats) populate(objectMap, "targetId", j.TargetID) populate(objectMap, "targetType", j.TargetType) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type JobProperties. func (j *JobProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } for key, val := range rawMsg { var err error switch key { case "backupPointInTime": err = unpopulateDateTimeRFC3339(val, "BackupPointInTime", &j.BackupPointInTime) delete(rawMsg, key) case "deviceId": err = unpopulate(val, "DeviceID", &j.DeviceID) delete(rawMsg, key) case "downloadProgress": err = unpopulate(val, "DownloadProgress", &j.DownloadProgress) delete(rawMsg, key) case "entityId": err = unpopulate(val, "EntityID", &j.EntityID) delete(rawMsg, key) case "entityType": err = unpopulate(val, "EntityType", &j.EntityType) delete(rawMsg, key) case "installProgress": err = unpopulate(val, "InstallProgress", &j.InstallProgress) delete(rawMsg, key) case "isCancellable": err = unpopulate(val, "IsCancellable", &j.IsCancellable) delete(rawMsg, key) case "jobStages": err = unpopulate(val, "JobStages", &j.JobStages) delete(rawMsg, key) case "jobType": err = unpopulate(val, "JobType", &j.JobType) delete(rawMsg, key) case "sourceDeviceId": err = unpopulate(val, "SourceDeviceID", &j.SourceDeviceID) delete(rawMsg, key) case "stats": err = unpopulate(val, "Stats", &j.Stats) delete(rawMsg, key) case "targetId": err = unpopulate(val, "TargetID", &j.TargetID) delete(rawMsg, key) case "targetType": err = unpopulate(val, "TargetType", &j.TargetType) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type JobStage. func (j JobStage) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "detail", j.Detail) populate(objectMap, "errorCode", j.ErrorCode) populate(objectMap, "message", j.Message) populate(objectMap, "stageStatus", j.StageStatus) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type JobStage. func (j *JobStage) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } for key, val := range rawMsg { var err error switch key { case "detail": err = unpopulate(val, "Detail", &j.Detail) delete(rawMsg, key) case "errorCode": err = unpopulate(val, "ErrorCode", &j.ErrorCode) delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &j.Message) delete(rawMsg, key) case "stageStatus": err = unpopulate(val, "StageStatus", &j.StageStatus) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type JobStats. func (j JobStats) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "completedWorkItemCount", j.CompletedWorkItemCount) populate(objectMap, "estimatedTimeRemaining", j.EstimatedTimeRemaining) populate(objectMap, "totalWorkItemCount", j.TotalWorkItemCount) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type JobStats. func (j *JobStats) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } for key, val := range rawMsg { var err error switch key { case "completedWorkItemCount": err = unpopulate(val, "CompletedWorkItemCount", &j.CompletedWorkItemCount) delete(rawMsg, key) case "estimatedTimeRemaining": err = unpopulate(val, "EstimatedTimeRemaining", &j.EstimatedTimeRemaining) delete(rawMsg, key) case "totalWorkItemCount": err = unpopulate(val, "TotalWorkItemCount", &j.TotalWorkItemCount) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Manager. func (m Manager) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "etag", m.Etag) populate(objectMap, "id", m.ID) populate(objectMap, "location", m.Location) populate(objectMap, "name", m.Name) populate(objectMap, "properties", m.Properties) populate(objectMap, "tags", m.Tags) populate(objectMap, "type", m.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Manager. func (m *Manager) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "etag": err = unpopulate(val, "Etag", &m.Etag) delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &m.ID) delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &m.Location) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &m.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &m.Properties) delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &m.Tags) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &m.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ManagerExtendedInfo. func (m ManagerExtendedInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "etag", m.Etag) populate(objectMap, "id", m.ID) populate(objectMap, "name", m.Name) populate(objectMap, "properties", m.Properties) populate(objectMap, "type", m.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ManagerExtendedInfo. func (m *ManagerExtendedInfo) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "etag": err = unpopulate(val, "Etag", &m.Etag) delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &m.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &m.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &m.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &m.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ManagerExtendedInfoProperties. func (m ManagerExtendedInfoProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "algorithm", m.Algorithm) populate(objectMap, "encryptionKey", m.EncryptionKey) populate(objectMap, "encryptionKeyThumbprint", m.EncryptionKeyThumbprint) populate(objectMap, "integrityKey", m.IntegrityKey) populate(objectMap, "portalCertificateThumbprint", m.PortalCertificateThumbprint) populate(objectMap, "version", m.Version) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ManagerExtendedInfoProperties. func (m *ManagerExtendedInfoProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "algorithm": err = unpopulate(val, "Algorithm", &m.Algorithm) delete(rawMsg, key) case "encryptionKey": err = unpopulate(val, "EncryptionKey", &m.EncryptionKey) delete(rawMsg, key) case "encryptionKeyThumbprint": err = unpopulate(val, "EncryptionKeyThumbprint", &m.EncryptionKeyThumbprint) delete(rawMsg, key) case "integrityKey": err = unpopulate(val, "IntegrityKey", &m.IntegrityKey) delete(rawMsg, key) case "portalCertificateThumbprint": err = unpopulate(val, "PortalCertificateThumbprint", &m.PortalCertificateThumbprint) delete(rawMsg, key) case "version": err = unpopulate(val, "Version", &m.Version) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ManagerIntrinsicSettings. func (m ManagerIntrinsicSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "type", m.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ManagerIntrinsicSettings. func (m *ManagerIntrinsicSettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "type": err = unpopulate(val, "Type", &m.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ManagerList. func (m ManagerList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ManagerList. func (m *ManagerList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &m.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ManagerPatch. func (m ManagerPatch) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "tags", m.Tags) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ManagerPatch. func (m *ManagerPatch) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "tags": err = unpopulate(val, "Tags", &m.Tags) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ManagerProperties. func (m ManagerProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "cisIntrinsicSettings", m.CisIntrinsicSettings) populate(objectMap, "provisioningState", m.ProvisioningState) populate(objectMap, "sku", m.SKU) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ManagerProperties. func (m *ManagerProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "cisIntrinsicSettings": err = unpopulate(val, "CisIntrinsicSettings", &m.CisIntrinsicSettings) delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) delete(rawMsg, key) case "sku": err = unpopulate(val, "SKU", &m.SKU) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ManagerSKU. func (m ManagerSKU) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) objectMap["name"] = "Standard" return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ManagerSKU. func (m *ManagerSKU) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "name": err = unpopulate(val, "Name", &m.Name) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Message. func (m Message) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "language", m.Language) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Message. func (m *Message) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "language": err = unpopulate(val, "Language", &m.Language) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &m.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricAvailablity. func (m MetricAvailablity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "retention", m.Retention) populate(objectMap, "timeGrain", m.TimeGrain) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricAvailablity. func (m *MetricAvailablity) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "retention": err = unpopulate(val, "Retention", &m.Retention) delete(rawMsg, key) case "timeGrain": err = unpopulate(val, "TimeGrain", &m.TimeGrain) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricData. func (m MetricData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "average", m.Average) populate(objectMap, "count", m.Count) populate(objectMap, "maximum", m.Maximum) populate(objectMap, "minimum", m.Minimum) populate(objectMap, "sum", m.Sum) populateDateTimeRFC3339(objectMap, "timeStamp", m.TimeStamp) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricData. func (m *MetricData) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "average": err = unpopulate(val, "Average", &m.Average) delete(rawMsg, key) case "count": err = unpopulate(val, "Count", &m.Count) delete(rawMsg, key) case "maximum": err = unpopulate(val, "Maximum", &m.Maximum) delete(rawMsg, key) case "minimum": err = unpopulate(val, "Minimum", &m.Minimum) delete(rawMsg, key) case "sum": err = unpopulate(val, "Sum", &m.Sum) delete(rawMsg, key) case "timeStamp": err = unpopulateDateTimeRFC3339(val, "TimeStamp", &m.TimeStamp) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricDefinition. func (m MetricDefinition) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "dimensions", m.Dimensions) populate(objectMap, "metricAvailabilities", m.MetricAvailabilities) populate(objectMap, "name", m.Name) populate(objectMap, "primaryAggregationType", m.PrimaryAggregationType) populate(objectMap, "resourceId", m.ResourceID) populate(objectMap, "type", m.Type) populate(objectMap, "unit", m.Unit) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricDefinition. func (m *MetricDefinition) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "dimensions": err = unpopulate(val, "Dimensions", &m.Dimensions) delete(rawMsg, key) case "metricAvailabilities": err = unpopulate(val, "MetricAvailabilities", &m.MetricAvailabilities) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &m.Name) delete(rawMsg, key) case "primaryAggregationType": err = unpopulate(val, "PrimaryAggregationType", &m.PrimaryAggregationType) delete(rawMsg, key) case "resourceId": err = unpopulate(val, "ResourceID", &m.ResourceID) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &m.Type) delete(rawMsg, key) case "unit": err = unpopulate(val, "Unit", &m.Unit) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricDefinitionList. func (m MetricDefinitionList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricDefinitionList. func (m *MetricDefinitionList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &m.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricDimension. func (m MetricDimension) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "name", m.Name) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricDimension. func (m *MetricDimension) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "name": err = unpopulate(val, "Name", &m.Name) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &m.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricFilter. func (m MetricFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populateDateTimeRFC3339(objectMap, "endTime", m.EndTime) populate(objectMap, "name", m.Name) populateDateTimeRFC3339(objectMap, "startTime", m.StartTime) populate(objectMap, "timeGrain", m.TimeGrain) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricFilter. func (m *MetricFilter) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "endTime": err = unpopulateDateTimeRFC3339(val, "EndTime", &m.EndTime) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &m.Name) delete(rawMsg, key) case "startTime": err = unpopulateDateTimeRFC3339(val, "StartTime", &m.StartTime) delete(rawMsg, key) case "timeGrain": err = unpopulate(val, "TimeGrain", &m.TimeGrain) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricList. func (m MetricList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricList. func (m *MetricList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &m.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricName. func (m MetricName) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "localizedValue", m.LocalizedValue) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricName. func (m *MetricName) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "localizedValue": err = unpopulate(val, "LocalizedValue", &m.LocalizedValue) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &m.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type MetricNameFilter. func (m MetricNameFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type MetricNameFilter. func (m *MetricNameFilter) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &m.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Metrics. func (m Metrics) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "dimensions", m.Dimensions) populateDateTimeRFC3339(objectMap, "endTime", m.EndTime) populate(objectMap, "name", m.Name) populate(objectMap, "primaryAggregation", m.PrimaryAggregation) populate(objectMap, "resourceId", m.ResourceID) populateDateTimeRFC3339(objectMap, "startTime", m.StartTime) populate(objectMap, "timeGrain", m.TimeGrain) populate(objectMap, "type", m.Type) populate(objectMap, "unit", m.Unit) populate(objectMap, "values", m.Values) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Metrics. func (m *Metrics) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { case "dimensions": err = unpopulate(val, "Dimensions", &m.Dimensions) delete(rawMsg, key) case "endTime": err = unpopulateDateTimeRFC3339(val, "EndTime", &m.EndTime) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &m.Name) delete(rawMsg, key) case "primaryAggregation": err = unpopulate(val, "PrimaryAggregation", &m.PrimaryAggregation) delete(rawMsg, key) case "resourceId": err = unpopulate(val, "ResourceID", &m.ResourceID) delete(rawMsg, key) case "startTime": err = unpopulateDateTimeRFC3339(val, "StartTime", &m.StartTime) delete(rawMsg, key) case "timeGrain": err = unpopulate(val, "TimeGrain", &m.TimeGrain) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &m.Type) delete(rawMsg, key) case "unit": err = unpopulate(val, "Unit", &m.Unit) delete(rawMsg, key) case "values": err = unpopulate(val, "Values", &m.Values) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type NetworkAdapter. func (n NetworkAdapter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "dhcpStatus", n.DhcpStatus) populate(objectMap, "iPv4Info", n.IPv4Info) populate(objectMap, "iPv6Info", n.IPv6Info) populate(objectMap, "linkSpeed", n.LinkSpeed) populate(objectMap, "networkAdapterName", n.NetworkAdapterName) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type NetworkAdapter. func (n *NetworkAdapter) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", n, err) } for key, val := range rawMsg { var err error switch key { case "dhcpStatus": err = unpopulate(val, "DhcpStatus", &n.DhcpStatus) delete(rawMsg, key) case "iPv4Info": err = unpopulate(val, "IPv4Info", &n.IPv4Info) delete(rawMsg, key) case "iPv6Info": err = unpopulate(val, "IPv6Info", &n.IPv6Info) delete(rawMsg, key) case "linkSpeed": err = unpopulate(val, "LinkSpeed", &n.LinkSpeed) delete(rawMsg, key) case "networkAdapterName": err = unpopulate(val, "NetworkAdapterName", &n.NetworkAdapterName) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", n, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type NetworkSettings. func (n NetworkSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", n.ID) populate(objectMap, "name", n.Name) populate(objectMap, "properties", n.Properties) populate(objectMap, "type", n.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSettings. func (n *NetworkSettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", n, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &n.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &n.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &n.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &n.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", n, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type NetworkSettingsProperties. func (n NetworkSettingsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nodeNetworks", n.NodeNetworks) populate(objectMap, "primaryDnsServer", n.PrimaryDNSServer) populate(objectMap, "secondaryDnsServer", n.SecondaryDNSServer) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type NetworkSettingsProperties. func (n *NetworkSettingsProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", n, err) } for key, val := range rawMsg { var err error switch key { case "nodeNetworks": err = unpopulate(val, "NodeNetworks", &n.NodeNetworks) delete(rawMsg, key) case "primaryDnsServer": err = unpopulate(val, "PrimaryDNSServer", &n.PrimaryDNSServer) delete(rawMsg, key) case "secondaryDnsServer": err = unpopulate(val, "SecondaryDNSServer", &n.SecondaryDNSServer) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", n, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type NodeNetwork. func (n NodeNetwork) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "networkAdapters", n.NetworkAdapters) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type NodeNetwork. func (n *NodeNetwork) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", n, err) } for key, val := range rawMsg { var err error switch key { case "networkAdapters": err = unpopulate(val, "NetworkAdapters", &n.NetworkAdapters) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", n, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type RawCertificateData. func (r RawCertificateData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "authType", r.AuthType) populate(objectMap, "certificate", r.Certificate) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type RawCertificateData. func (r *RawCertificateData) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { case "authType": err = unpopulate(val, "AuthType", &r.AuthType) delete(rawMsg, key) case "certificate": err = unpopulate(val, "Certificate", &r.Certificate) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "location", r.Location) populate(objectMap, "name", r.Name) populate(objectMap, "tags", r.Tags) populate(objectMap, "type", r.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Resource. func (r *Resource) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &r.ID) delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &r.Location) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &r.Name) delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &r.Tags) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &r.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type ResourceCertificateAndAADDetails. func (r ResourceCertificateAndAADDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "aadAuthority", r.AADAuthority) populate(objectMap, "aadTenantId", r.AADTenantID) populate(objectMap, "authType", r.AuthType) populate(objectMap, "azureManagementEndpointAudience", r.AzureManagementEndpointAudience) populate(objectMap, "certificate", r.Certificate) populate(objectMap, "friendlyName", r.FriendlyName) populate(objectMap, "issuer", r.Issuer) populate(objectMap, "resourceId", r.ResourceID) populate(objectMap, "servicePrincipalClientId", r.ServicePrincipalClientID) populate(objectMap, "servicePrincipalObjectId", r.ServicePrincipalObjectID) populate(objectMap, "subject", r.Subject) populate(objectMap, "thumbprint", r.Thumbprint) populateDateTimeRFC3339(objectMap, "validFrom", r.ValidFrom) populateDateTimeRFC3339(objectMap, "validTo", r.ValidTo) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type ResourceCertificateAndAADDetails. func (r *ResourceCertificateAndAADDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) } for key, val := range rawMsg { var err error switch key { case "aadAuthority": err = unpopulate(val, "AADAuthority", &r.AADAuthority) delete(rawMsg, key) case "aadTenantId": err = unpopulate(val, "AADTenantID", &r.AADTenantID) delete(rawMsg, key) case "authType": err = unpopulate(val, "AuthType", &r.AuthType) delete(rawMsg, key) case "azureManagementEndpointAudience": err = unpopulate(val, "AzureManagementEndpointAudience", &r.AzureManagementEndpointAudience) delete(rawMsg, key) case "certificate": err = unpopulate(val, "Certificate", &r.Certificate) delete(rawMsg, key) case "friendlyName": err = unpopulate(val, "FriendlyName", &r.FriendlyName) delete(rawMsg, key) case "issuer": err = unpopulate(val, "Issuer", &r.Issuer) delete(rawMsg, key) case "resourceId": err = unpopulate(val, "ResourceID", &r.ResourceID) delete(rawMsg, key) case "servicePrincipalClientId": err = unpopulate(val, "ServicePrincipalClientID", &r.ServicePrincipalClientID) delete(rawMsg, key) case "servicePrincipalObjectId": err = unpopulate(val, "ServicePrincipalObjectID", &r.ServicePrincipalObjectID) delete(rawMsg, key) case "subject": err = unpopulate(val, "Subject", &r.Subject) delete(rawMsg, key) case "thumbprint": err = unpopulate(val, "Thumbprint", &r.Thumbprint) delete(rawMsg, key) case "validFrom": err = unpopulateDateTimeRFC3339(val, "ValidFrom", &r.ValidFrom) delete(rawMsg, key) case "validTo": err = unpopulateDateTimeRFC3339(val, "ValidTo", &r.ValidTo) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type SecuritySettings. func (s SecuritySettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) populate(objectMap, "type", s.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type SecuritySettings. func (s *SecuritySettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &s.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &s.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &s.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &s.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type SecuritySettingsProperties. func (s SecuritySettingsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "deviceAdminPassword", s.DeviceAdminPassword) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type SecuritySettingsProperties. func (s *SecuritySettingsProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "deviceAdminPassword": err = unpopulate(val, "DeviceAdminPassword", &s.DeviceAdminPassword) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type SendTestAlertEmailRequest. func (s SendTestAlertEmailRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "emailList", s.EmailList) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type SendTestAlertEmailRequest. func (s *SendTestAlertEmailRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "emailList": err = unpopulate(val, "EmailList", &s.EmailList) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type StorageAccountCredential. func (s StorageAccountCredential) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) populate(objectMap, "type", s.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type StorageAccountCredential. func (s *StorageAccountCredential) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &s.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &s.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &s.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &s.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type StorageAccountCredentialList. func (s StorageAccountCredentialList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type StorageAccountCredentialList. func (s *StorageAccountCredentialList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &s.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type StorageAccountCredentialProperties. func (s StorageAccountCredentialProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "accessKey", s.AccessKey) populate(objectMap, "cloudType", s.CloudType) populate(objectMap, "enableSSL", s.EnableSSL) populate(objectMap, "endPoint", s.EndPoint) populate(objectMap, "location", s.Location) populate(objectMap, "login", s.Login) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type StorageAccountCredentialProperties. func (s *StorageAccountCredentialProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "accessKey": err = unpopulate(val, "AccessKey", &s.AccessKey) delete(rawMsg, key) case "cloudType": err = unpopulate(val, "CloudType", &s.CloudType) delete(rawMsg, key) case "enableSSL": err = unpopulate(val, "EnableSSL", &s.EnableSSL) delete(rawMsg, key) case "endPoint": err = unpopulate(val, "EndPoint", &s.EndPoint) delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &s.Location) delete(rawMsg, key) case "login": err = unpopulate(val, "Login", &s.Login) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type StorageDomain. func (s StorageDomain) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) populate(objectMap, "type", s.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type StorageDomain. func (s *StorageDomain) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &s.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &s.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &s.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &s.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type StorageDomainList. func (s StorageDomainList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type StorageDomainList. func (s *StorageDomainList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "value": err = unpopulate(val, "Value", &s.Value) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type StorageDomainProperties. func (s StorageDomainProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "encryptionKey", s.EncryptionKey) populate(objectMap, "encryptionStatus", s.EncryptionStatus) populate(objectMap, "storageAccountCredentialIds", s.StorageAccountCredentialIDs) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type StorageDomainProperties. func (s *StorageDomainProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "encryptionKey": err = unpopulate(val, "EncryptionKey", &s.EncryptionKey) delete(rawMsg, key) case "encryptionStatus": err = unpopulate(val, "EncryptionStatus", &s.EncryptionStatus) delete(rawMsg, key) case "storageAccountCredentialIds": err = unpopulate(val, "StorageAccountCredentialIDs", &s.StorageAccountCredentialIDs) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type SymmetricEncryptedSecret. func (s SymmetricEncryptedSecret) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "encryptionAlgorithm", s.EncryptionAlgorithm) populate(objectMap, "value", s.Value) populate(objectMap, "valueCertificateThumbprint", s.ValueCertificateThumbprint) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type SymmetricEncryptedSecret. func (s *SymmetricEncryptedSecret) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } for key, val := range rawMsg { var err error switch key { case "encryptionAlgorithm": err = unpopulate(val, "EncryptionAlgorithm", &s.EncryptionAlgorithm) delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &s.Value) delete(rawMsg, key) case "valueCertificateThumbprint": err = unpopulate(val, "ValueCertificateThumbprint", &s.ValueCertificateThumbprint) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Time. func (t Time) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "hour", t.Hour) populate(objectMap, "minute", t.Minute) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Time. func (t *Time) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { case "hour": err = unpopulate(val, "Hour", &t.Hour) delete(rawMsg, key) case "minute": err = unpopulate(val, "Minute", &t.Minute) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type TimeSettings. func (t TimeSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "name", t.Name) populate(objectMap, "properties", t.Properties) populate(objectMap, "type", t.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type TimeSettings. func (t *TimeSettings) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &t.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &t.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &t.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &t.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type TimeSettingsProperties. func (t TimeSettingsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "primaryTimeServer", t.PrimaryTimeServer) populate(objectMap, "secondaryTimeServer", t.SecondaryTimeServer) populate(objectMap, "timeZone", t.TimeZone) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type TimeSettingsProperties. func (t *TimeSettingsProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) } for key, val := range rawMsg { var err error switch key { case "primaryTimeServer": err = unpopulate(val, "PrimaryTimeServer", &t.PrimaryTimeServer) delete(rawMsg, key) case "secondaryTimeServer": err = unpopulate(val, "SecondaryTimeServer", &t.SecondaryTimeServer) delete(rawMsg, key) case "timeZone": err = unpopulate(val, "TimeZone", &t.TimeZone) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", t, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type UpdateDownloadProgress. func (u UpdateDownloadProgress) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "downloadPhase", u.DownloadPhase) populate(objectMap, "numberOfUpdatesDownloaded", u.NumberOfUpdatesDownloaded) populate(objectMap, "numberOfUpdatesToDownload", u.NumberOfUpdatesToDownload) populate(objectMap, "percentComplete", u.PercentComplete) populate(objectMap, "totalBytesDownloaded", u.TotalBytesDownloaded) populate(objectMap, "totalBytesToDownload", u.TotalBytesToDownload) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type UpdateDownloadProgress. func (u *UpdateDownloadProgress) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { case "downloadPhase": err = unpopulate(val, "DownloadPhase", &u.DownloadPhase) delete(rawMsg, key) case "numberOfUpdatesDownloaded": err = unpopulate(val, "NumberOfUpdatesDownloaded", &u.NumberOfUpdatesDownloaded) delete(rawMsg, key) case "numberOfUpdatesToDownload": err = unpopulate(val, "NumberOfUpdatesToDownload", &u.NumberOfUpdatesToDownload) delete(rawMsg, key) case "percentComplete": err = unpopulate(val, "PercentComplete", &u.PercentComplete) delete(rawMsg, key) case "totalBytesDownloaded": err = unpopulate(val, "TotalBytesDownloaded", &u.TotalBytesDownloaded) delete(rawMsg, key) case "totalBytesToDownload": err = unpopulate(val, "TotalBytesToDownload", &u.TotalBytesToDownload) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type UpdateInstallProgress. func (u UpdateInstallProgress) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "numberOfUpdatesInstalled", u.NumberOfUpdatesInstalled) populate(objectMap, "numberOfUpdatesToInstall", u.NumberOfUpdatesToInstall) populate(objectMap, "percentComplete", u.PercentComplete) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type UpdateInstallProgress. func (u *UpdateInstallProgress) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { case "numberOfUpdatesInstalled": err = unpopulate(val, "NumberOfUpdatesInstalled", &u.NumberOfUpdatesInstalled) delete(rawMsg, key) case "numberOfUpdatesToInstall": err = unpopulate(val, "NumberOfUpdatesToInstall", &u.NumberOfUpdatesToInstall) delete(rawMsg, key) case "percentComplete": err = unpopulate(val, "PercentComplete", &u.PercentComplete) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type Updates. func (u Updates) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", u.ID) populate(objectMap, "name", u.Name) populate(objectMap, "properties", u.Properties) populate(objectMap, "type", u.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type Updates. func (u *Updates) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &u.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &u.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &u.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &u.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type UpdatesProperties. func (u UpdatesProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populateDateTimeRFC3339(objectMap, "deviceLastScannedTime", u.DeviceLastScannedTime) populate(objectMap, "deviceVersion", u.DeviceVersion) populate(objectMap, "inProgressDownloadJobId", u.InProgressDownloadJobID) populateDateTimeRFC3339(objectMap, "inProgressDownloadJobStartedTime", u.InProgressDownloadJobStartedTime) populate(objectMap, "inProgressInstallJobId", u.InProgressInstallJobID) populateDateTimeRFC3339(objectMap, "inProgressInstallJobStartedTime", u.InProgressInstallJobStartedTime) populateDateTimeRFC3339(objectMap, "inProgressScanStartedTime", u.InProgressScanStartedTime) populateDateTimeRFC3339(objectMap, "lastCompletedDownloadJobTime", u.LastCompletedDownloadJobTime) populateDateTimeRFC3339(objectMap, "lastCompletedInstallJobTime", u.LastCompletedInstallJobTime) populateDateTimeRFC3339(objectMap, "lastCompletedScanTime", u.LastCompletedScanTime) populate(objectMap, "rebootRequiredForInstall", u.RebootRequiredForInstall) populate(objectMap, "regularUpdatesAvailable", u.RegularUpdatesAvailable) populate(objectMap, "status", u.Status) populate(objectMap, "totalItemsPendingForDownload", u.TotalItemsPendingForDownload) populate(objectMap, "totalItemsPendingForInstall", u.TotalItemsPendingForInstall) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type UpdatesProperties. func (u *UpdatesProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { case "deviceLastScannedTime": err = unpopulateDateTimeRFC3339(val, "DeviceLastScannedTime", &u.DeviceLastScannedTime) delete(rawMsg, key) case "deviceVersion": err = unpopulate(val, "DeviceVersion", &u.DeviceVersion) delete(rawMsg, key) case "inProgressDownloadJobId": err = unpopulate(val, "InProgressDownloadJobID", &u.InProgressDownloadJobID) delete(rawMsg, key) case "inProgressDownloadJobStartedTime": err = unpopulateDateTimeRFC3339(val, "InProgressDownloadJobStartedTime", &u.InProgressDownloadJobStartedTime) delete(rawMsg, key) case "inProgressInstallJobId": err = unpopulate(val, "InProgressInstallJobID", &u.InProgressInstallJobID) delete(rawMsg, key) case "inProgressInstallJobStartedTime": err = unpopulateDateTimeRFC3339(val, "InProgressInstallJobStartedTime", &u.InProgressInstallJobStartedTime) delete(rawMsg, key) case "inProgressScanStartedTime": err = unpopulateDateTimeRFC3339(val, "InProgressScanStartedTime", &u.InProgressScanStartedTime) delete(rawMsg, key) case "lastCompletedDownloadJobTime": err = unpopulateDateTimeRFC3339(val, "LastCompletedDownloadJobTime", &u.LastCompletedDownloadJobTime) delete(rawMsg, key) case "lastCompletedInstallJobTime": err = unpopulateDateTimeRFC3339(val, "LastCompletedInstallJobTime", &u.LastCompletedInstallJobTime) delete(rawMsg, key) case "lastCompletedScanTime": err = unpopulateDateTimeRFC3339(val, "LastCompletedScanTime", &u.LastCompletedScanTime) delete(rawMsg, key) case "rebootRequiredForInstall": err = unpopulate(val, "RebootRequiredForInstall", &u.RebootRequiredForInstall) delete(rawMsg, key) case "regularUpdatesAvailable": err = unpopulate(val, "RegularUpdatesAvailable", &u.RegularUpdatesAvailable) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &u.Status) delete(rawMsg, key) case "totalItemsPendingForDownload": err = unpopulate(val, "TotalItemsPendingForDownload", &u.TotalItemsPendingForDownload) delete(rawMsg, key) case "totalItemsPendingForInstall": err = unpopulate(val, "TotalItemsPendingForInstall", &u.TotalItemsPendingForInstall) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type UploadCertificateRequest. func (u UploadCertificateRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "contractVersion", u.ContractVersion) populate(objectMap, "properties", u.Properties) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type UploadCertificateRequest. func (u *UploadCertificateRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { case "contractVersion": err = unpopulate(val, "ContractVersion", &u.ContractVersion) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &u.Properties) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil } // MarshalJSON implements the json.Marshaller interface for type UploadCertificateResponse. func (u UploadCertificateResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", u.ID) populate(objectMap, "name", u.Name) populate(objectMap, "properties", u.Properties) populate(objectMap, "type", u.Type) return json.Marshal(objectMap) } // UnmarshalJSON implements the json.Unmarshaller interface for type UploadCertificateResponse. func (u *UploadCertificateResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } for key, val := range rawMsg { var err error switch key { case "id": err = unpopulate(val, "ID", &u.ID) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &u.Name) delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &u.Properties) delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &u.Type) delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", u, err) } } return nil } func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { m[k] = nil } else if !reflect.ValueOf(v).IsNil() { m[k] = v } } func populateAny(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { m[k] = nil } else { m[k] = v } } func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } if err := json.Unmarshal(data, v); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } return nil }