sdk/resourcemanager/carbonoptimization/armcarbonoptimization/models_serde.go (1,188 lines of code) (raw):
// 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) Go Code Generator. DO NOT EDIT.
package armcarbonoptimization
import (
"encoding/json"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"reflect"
)
// MarshalJSON implements the json.Marshaller interface for type CarbonEmissionData.
func (c CarbonEmissionData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "dataType", c.DataType)
populate(objectMap, "latestMonthEmissions", c.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", c.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", c.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", c.PreviousMonthEmissions)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CarbonEmissionData.
func (c *CarbonEmissionData) 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 "dataType":
err = unpopulate(val, "DataType", &c.DataType)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &c.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &c.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &c.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &c.PreviousMonthEmissions)
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 CarbonEmissionDataAvailableDateRange.
func (c CarbonEmissionDataAvailableDateRange) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "endDate", c.EndDate)
populate(objectMap, "startDate", c.StartDate)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CarbonEmissionDataAvailableDateRange.
func (c *CarbonEmissionDataAvailableDateRange) 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 "endDate":
err = unpopulate(val, "EndDate", &c.EndDate)
delete(rawMsg, key)
case "startDate":
err = unpopulate(val, "StartDate", &c.StartDate)
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 CarbonEmissionDataListResult.
func (c CarbonEmissionDataListResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "skipToken", c.SkipToken)
populate(objectMap, "subscriptionAccessDecisionList", c.SubscriptionAccessDecisionList)
populate(objectMap, "value", c.Value)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CarbonEmissionDataListResult.
func (c *CarbonEmissionDataListResult) 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 "skipToken":
err = unpopulate(val, "SkipToken", &c.SkipToken)
delete(rawMsg, key)
case "subscriptionAccessDecisionList":
err = unpopulate(val, "SubscriptionAccessDecisionList", &c.SubscriptionAccessDecisionList)
delete(rawMsg, key)
case "value":
c.Value, err = unmarshalCarbonEmissionDataClassificationArray(val)
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 CarbonEmissionItemDetailData.
func (c CarbonEmissionItemDetailData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", c.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumItemDetailsData
populate(objectMap, "itemName", c.ItemName)
populate(objectMap, "latestMonthEmissions", c.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", c.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", c.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", c.PreviousMonthEmissions)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CarbonEmissionItemDetailData.
func (c *CarbonEmissionItemDetailData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &c.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &c.DataType)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &c.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &c.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &c.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &c.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &c.PreviousMonthEmissions)
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 CarbonEmissionMonthlySummaryData.
func (c CarbonEmissionMonthlySummaryData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "carbonIntensity", c.CarbonIntensity)
objectMap["dataType"] = ResponseDataTypeEnumMonthlySummaryData
populate(objectMap, "date", c.Date)
populate(objectMap, "latestMonthEmissions", c.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", c.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", c.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", c.PreviousMonthEmissions)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CarbonEmissionMonthlySummaryData.
func (c *CarbonEmissionMonthlySummaryData) 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 "carbonIntensity":
err = unpopulate(val, "CarbonIntensity", &c.CarbonIntensity)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &c.DataType)
delete(rawMsg, key)
case "date":
err = unpopulate(val, "Date", &c.Date)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &c.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &c.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &c.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &c.PreviousMonthEmissions)
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 CarbonEmissionOverallSummaryData.
func (c CarbonEmissionOverallSummaryData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
objectMap["dataType"] = ResponseDataTypeEnumOverallSummaryData
populate(objectMap, "latestMonthEmissions", c.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", c.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", c.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", c.PreviousMonthEmissions)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CarbonEmissionOverallSummaryData.
func (c *CarbonEmissionOverallSummaryData) 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 "dataType":
err = unpopulate(val, "DataType", &c.DataType)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &c.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &c.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &c.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &c.PreviousMonthEmissions)
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 CarbonEmissionTopItemMonthlySummaryData.
func (c CarbonEmissionTopItemMonthlySummaryData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", c.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumTopItemsMonthlySummaryData
populate(objectMap, "date", c.Date)
populate(objectMap, "itemName", c.ItemName)
populate(objectMap, "latestMonthEmissions", c.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", c.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", c.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", c.PreviousMonthEmissions)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CarbonEmissionTopItemMonthlySummaryData.
func (c *CarbonEmissionTopItemMonthlySummaryData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &c.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &c.DataType)
delete(rawMsg, key)
case "date":
err = unpopulate(val, "Date", &c.Date)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &c.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &c.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &c.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &c.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &c.PreviousMonthEmissions)
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 CarbonEmissionTopItemsSummaryData.
func (c CarbonEmissionTopItemsSummaryData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", c.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumTopItemsSummaryData
populate(objectMap, "itemName", c.ItemName)
populate(objectMap, "latestMonthEmissions", c.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", c.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", c.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", c.PreviousMonthEmissions)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type CarbonEmissionTopItemsSummaryData.
func (c *CarbonEmissionTopItemsSummaryData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &c.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &c.DataType)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &c.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &c.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &c.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &c.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &c.PreviousMonthEmissions)
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 DateRange.
func (d DateRange) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populateDateType(objectMap, "end", d.End)
populateDateType(objectMap, "start", d.Start)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type DateRange.
func (d *DateRange) 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 "end":
err = unpopulateDateType(val, "End", &d.End)
delete(rawMsg, key)
case "start":
err = unpopulateDateType(val, "Start", &d.Start)
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 ItemDetailsQueryFilter.
func (i ItemDetailsQueryFilter) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "carbonScopeList", i.CarbonScopeList)
populate(objectMap, "categoryType", i.CategoryType)
populate(objectMap, "dateRange", i.DateRange)
populate(objectMap, "locationList", i.LocationList)
populate(objectMap, "orderBy", i.OrderBy)
populate(objectMap, "pageSize", i.PageSize)
objectMap["reportType"] = ReportTypeEnumItemDetailsReport
populate(objectMap, "resourceGroupUrlList", i.ResourceGroupURLList)
populate(objectMap, "resourceTypeList", i.ResourceTypeList)
populate(objectMap, "skipToken", i.SkipToken)
populate(objectMap, "sortDirection", i.SortDirection)
populate(objectMap, "subscriptionList", i.SubscriptionList)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ItemDetailsQueryFilter.
func (i *ItemDetailsQueryFilter) 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 "carbonScopeList":
err = unpopulate(val, "CarbonScopeList", &i.CarbonScopeList)
delete(rawMsg, key)
case "categoryType":
err = unpopulate(val, "CategoryType", &i.CategoryType)
delete(rawMsg, key)
case "dateRange":
err = unpopulate(val, "DateRange", &i.DateRange)
delete(rawMsg, key)
case "locationList":
err = unpopulate(val, "LocationList", &i.LocationList)
delete(rawMsg, key)
case "orderBy":
err = unpopulate(val, "OrderBy", &i.OrderBy)
delete(rawMsg, key)
case "pageSize":
err = unpopulate(val, "PageSize", &i.PageSize)
delete(rawMsg, key)
case "reportType":
err = unpopulate(val, "ReportType", &i.ReportType)
delete(rawMsg, key)
case "resourceGroupUrlList":
err = unpopulate(val, "ResourceGroupURLList", &i.ResourceGroupURLList)
delete(rawMsg, key)
case "resourceTypeList":
err = unpopulate(val, "ResourceTypeList", &i.ResourceTypeList)
delete(rawMsg, key)
case "skipToken":
err = unpopulate(val, "SkipToken", &i.SkipToken)
delete(rawMsg, key)
case "sortDirection":
err = unpopulate(val, "SortDirection", &i.SortDirection)
delete(rawMsg, key)
case "subscriptionList":
err = unpopulate(val, "SubscriptionList", &i.SubscriptionList)
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 MonthlySummaryReportQueryFilter.
func (m MonthlySummaryReportQueryFilter) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "carbonScopeList", m.CarbonScopeList)
populate(objectMap, "dateRange", m.DateRange)
populate(objectMap, "locationList", m.LocationList)
objectMap["reportType"] = ReportTypeEnumMonthlySummaryReport
populate(objectMap, "resourceGroupUrlList", m.ResourceGroupURLList)
populate(objectMap, "resourceTypeList", m.ResourceTypeList)
populate(objectMap, "subscriptionList", m.SubscriptionList)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type MonthlySummaryReportQueryFilter.
func (m *MonthlySummaryReportQueryFilter) 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 "carbonScopeList":
err = unpopulate(val, "CarbonScopeList", &m.CarbonScopeList)
delete(rawMsg, key)
case "dateRange":
err = unpopulate(val, "DateRange", &m.DateRange)
delete(rawMsg, key)
case "locationList":
err = unpopulate(val, "LocationList", &m.LocationList)
delete(rawMsg, key)
case "reportType":
err = unpopulate(val, "ReportType", &m.ReportType)
delete(rawMsg, key)
case "resourceGroupUrlList":
err = unpopulate(val, "ResourceGroupURLList", &m.ResourceGroupURLList)
delete(rawMsg, key)
case "resourceTypeList":
err = unpopulate(val, "ResourceTypeList", &m.ResourceTypeList)
delete(rawMsg, key)
case "subscriptionList":
err = unpopulate(val, "SubscriptionList", &m.SubscriptionList)
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 Operation.
func (o Operation) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "actionType", o.ActionType)
populate(objectMap, "display", o.Display)
populate(objectMap, "isDataAction", o.IsDataAction)
populate(objectMap, "name", o.Name)
populate(objectMap, "origin", o.Origin)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type Operation.
func (o *Operation) 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", o, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "actionType":
err = unpopulate(val, "ActionType", &o.ActionType)
delete(rawMsg, key)
case "display":
err = unpopulate(val, "Display", &o.Display)
delete(rawMsg, key)
case "isDataAction":
err = unpopulate(val, "IsDataAction", &o.IsDataAction)
delete(rawMsg, key)
case "name":
err = unpopulate(val, "Name", &o.Name)
delete(rawMsg, key)
case "origin":
err = unpopulate(val, "Origin", &o.Origin)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", o, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type OperationDisplay.
func (o OperationDisplay) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "description", o.Description)
populate(objectMap, "operation", o.Operation)
populate(objectMap, "provider", o.Provider)
populate(objectMap, "resource", o.Resource)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay.
func (o *OperationDisplay) 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", o, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "description":
err = unpopulate(val, "Description", &o.Description)
delete(rawMsg, key)
case "operation":
err = unpopulate(val, "Operation", &o.Operation)
delete(rawMsg, key)
case "provider":
err = unpopulate(val, "Provider", &o.Provider)
delete(rawMsg, key)
case "resource":
err = unpopulate(val, "Resource", &o.Resource)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", o, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type OperationListResult.
func (o OperationListResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "nextLink", o.NextLink)
populate(objectMap, "value", o.Value)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult.
func (o *OperationListResult) 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", o, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "nextLink":
err = unpopulate(val, "NextLink", &o.NextLink)
delete(rawMsg, key)
case "value":
err = unpopulate(val, "Value", &o.Value)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", o, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type OverallSummaryReportQueryFilter.
func (o OverallSummaryReportQueryFilter) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "carbonScopeList", o.CarbonScopeList)
populate(objectMap, "dateRange", o.DateRange)
populate(objectMap, "locationList", o.LocationList)
objectMap["reportType"] = ReportTypeEnumOverallSummaryReport
populate(objectMap, "resourceGroupUrlList", o.ResourceGroupURLList)
populate(objectMap, "resourceTypeList", o.ResourceTypeList)
populate(objectMap, "subscriptionList", o.SubscriptionList)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type OverallSummaryReportQueryFilter.
func (o *OverallSummaryReportQueryFilter) 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", o, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "carbonScopeList":
err = unpopulate(val, "CarbonScopeList", &o.CarbonScopeList)
delete(rawMsg, key)
case "dateRange":
err = unpopulate(val, "DateRange", &o.DateRange)
delete(rawMsg, key)
case "locationList":
err = unpopulate(val, "LocationList", &o.LocationList)
delete(rawMsg, key)
case "reportType":
err = unpopulate(val, "ReportType", &o.ReportType)
delete(rawMsg, key)
case "resourceGroupUrlList":
err = unpopulate(val, "ResourceGroupURLList", &o.ResourceGroupURLList)
delete(rawMsg, key)
case "resourceTypeList":
err = unpopulate(val, "ResourceTypeList", &o.ResourceTypeList)
delete(rawMsg, key)
case "subscriptionList":
err = unpopulate(val, "SubscriptionList", &o.SubscriptionList)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", o, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type QueryFilter.
func (q QueryFilter) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "carbonScopeList", q.CarbonScopeList)
populate(objectMap, "dateRange", q.DateRange)
populate(objectMap, "locationList", q.LocationList)
populate(objectMap, "reportType", q.ReportType)
populate(objectMap, "resourceGroupUrlList", q.ResourceGroupURLList)
populate(objectMap, "resourceTypeList", q.ResourceTypeList)
populate(objectMap, "subscriptionList", q.SubscriptionList)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type QueryFilter.
func (q *QueryFilter) 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", q, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "carbonScopeList":
err = unpopulate(val, "CarbonScopeList", &q.CarbonScopeList)
delete(rawMsg, key)
case "dateRange":
err = unpopulate(val, "DateRange", &q.DateRange)
delete(rawMsg, key)
case "locationList":
err = unpopulate(val, "LocationList", &q.LocationList)
delete(rawMsg, key)
case "reportType":
err = unpopulate(val, "ReportType", &q.ReportType)
delete(rawMsg, key)
case "resourceGroupUrlList":
err = unpopulate(val, "ResourceGroupURLList", &q.ResourceGroupURLList)
delete(rawMsg, key)
case "resourceTypeList":
err = unpopulate(val, "ResourceTypeList", &q.ResourceTypeList)
delete(rawMsg, key)
case "subscriptionList":
err = unpopulate(val, "SubscriptionList", &q.SubscriptionList)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", q, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type ResourceCarbonEmissionItemDetailData.
func (r ResourceCarbonEmissionItemDetailData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", r.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumResourceItemDetailsData
populate(objectMap, "itemName", r.ItemName)
populate(objectMap, "latestMonthEmissions", r.LatestMonthEmissions)
populate(objectMap, "location", r.Location)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", r.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", r.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", r.PreviousMonthEmissions)
populate(objectMap, "resourceGroup", r.ResourceGroup)
populate(objectMap, "resourceId", r.ResourceID)
populate(objectMap, "resourceType", r.ResourceType)
populate(objectMap, "subscriptionId", r.SubscriptionID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceCarbonEmissionItemDetailData.
func (r *ResourceCarbonEmissionItemDetailData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &r.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &r.DataType)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &r.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &r.LatestMonthEmissions)
delete(rawMsg, key)
case "location":
err = unpopulate(val, "Location", &r.Location)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &r.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &r.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &r.PreviousMonthEmissions)
delete(rawMsg, key)
case "resourceGroup":
err = unpopulate(val, "ResourceGroup", &r.ResourceGroup)
delete(rawMsg, key)
case "resourceId":
err = unpopulate(val, "ResourceID", &r.ResourceID)
delete(rawMsg, key)
case "resourceType":
err = unpopulate(val, "ResourceType", &r.ResourceType)
delete(rawMsg, key)
case "subscriptionId":
err = unpopulate(val, "SubscriptionID", &r.SubscriptionID)
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 ResourceCarbonEmissionTopItemMonthlySummaryData.
func (r ResourceCarbonEmissionTopItemMonthlySummaryData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", r.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumResourceTopItemsMonthlySummaryData
populate(objectMap, "date", r.Date)
populate(objectMap, "itemName", r.ItemName)
populate(objectMap, "latestMonthEmissions", r.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", r.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", r.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", r.PreviousMonthEmissions)
populate(objectMap, "resourceGroup", r.ResourceGroup)
populate(objectMap, "resourceId", r.ResourceID)
populate(objectMap, "subscriptionId", r.SubscriptionID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceCarbonEmissionTopItemMonthlySummaryData.
func (r *ResourceCarbonEmissionTopItemMonthlySummaryData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &r.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &r.DataType)
delete(rawMsg, key)
case "date":
err = unpopulate(val, "Date", &r.Date)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &r.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &r.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &r.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &r.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &r.PreviousMonthEmissions)
delete(rawMsg, key)
case "resourceGroup":
err = unpopulate(val, "ResourceGroup", &r.ResourceGroup)
delete(rawMsg, key)
case "resourceId":
err = unpopulate(val, "ResourceID", &r.ResourceID)
delete(rawMsg, key)
case "subscriptionId":
err = unpopulate(val, "SubscriptionID", &r.SubscriptionID)
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 ResourceCarbonEmissionTopItemsSummaryData.
func (r ResourceCarbonEmissionTopItemsSummaryData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", r.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumResourceTopItemsSummaryData
populate(objectMap, "itemName", r.ItemName)
populate(objectMap, "latestMonthEmissions", r.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", r.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", r.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", r.PreviousMonthEmissions)
populate(objectMap, "resourceGroup", r.ResourceGroup)
populate(objectMap, "resourceId", r.ResourceID)
populate(objectMap, "subscriptionId", r.SubscriptionID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceCarbonEmissionTopItemsSummaryData.
func (r *ResourceCarbonEmissionTopItemsSummaryData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &r.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &r.DataType)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &r.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &r.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &r.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &r.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &r.PreviousMonthEmissions)
delete(rawMsg, key)
case "resourceGroup":
err = unpopulate(val, "ResourceGroup", &r.ResourceGroup)
delete(rawMsg, key)
case "resourceId":
err = unpopulate(val, "ResourceID", &r.ResourceID)
delete(rawMsg, key)
case "subscriptionId":
err = unpopulate(val, "SubscriptionID", &r.SubscriptionID)
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 ResourceGroupCarbonEmissionItemDetailData.
func (r ResourceGroupCarbonEmissionItemDetailData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", r.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumResourceGroupItemDetailsData
populate(objectMap, "itemName", r.ItemName)
populate(objectMap, "latestMonthEmissions", r.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", r.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", r.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", r.PreviousMonthEmissions)
populate(objectMap, "resourceGroupUrl", r.ResourceGroupURL)
populate(objectMap, "subscriptionId", r.SubscriptionID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceGroupCarbonEmissionItemDetailData.
func (r *ResourceGroupCarbonEmissionItemDetailData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &r.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &r.DataType)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &r.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &r.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &r.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &r.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &r.PreviousMonthEmissions)
delete(rawMsg, key)
case "resourceGroupUrl":
err = unpopulate(val, "ResourceGroupURL", &r.ResourceGroupURL)
delete(rawMsg, key)
case "subscriptionId":
err = unpopulate(val, "SubscriptionID", &r.SubscriptionID)
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 ResourceGroupCarbonEmissionTopItemMonthlySummaryData.
func (r ResourceGroupCarbonEmissionTopItemMonthlySummaryData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", r.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumResourceGroupTopItemsMonthlySummaryData
populate(objectMap, "date", r.Date)
populate(objectMap, "itemName", r.ItemName)
populate(objectMap, "latestMonthEmissions", r.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", r.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", r.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", r.PreviousMonthEmissions)
populate(objectMap, "resourceGroupUrl", r.ResourceGroupURL)
populate(objectMap, "subscriptionId", r.SubscriptionID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceGroupCarbonEmissionTopItemMonthlySummaryData.
func (r *ResourceGroupCarbonEmissionTopItemMonthlySummaryData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &r.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &r.DataType)
delete(rawMsg, key)
case "date":
err = unpopulate(val, "Date", &r.Date)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &r.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &r.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &r.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &r.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &r.PreviousMonthEmissions)
delete(rawMsg, key)
case "resourceGroupUrl":
err = unpopulate(val, "ResourceGroupURL", &r.ResourceGroupURL)
delete(rawMsg, key)
case "subscriptionId":
err = unpopulate(val, "SubscriptionID", &r.SubscriptionID)
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 ResourceGroupCarbonEmissionTopItemsSummaryData.
func (r ResourceGroupCarbonEmissionTopItemsSummaryData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "categoryType", r.CategoryType)
objectMap["dataType"] = ResponseDataTypeEnumResourceGroupTopItemsSummaryData
populate(objectMap, "itemName", r.ItemName)
populate(objectMap, "latestMonthEmissions", r.LatestMonthEmissions)
populate(objectMap, "monthOverMonthEmissionsChangeRatio", r.MonthOverMonthEmissionsChangeRatio)
populate(objectMap, "monthlyEmissionsChangeValue", r.MonthlyEmissionsChangeValue)
populate(objectMap, "previousMonthEmissions", r.PreviousMonthEmissions)
populate(objectMap, "resourceGroupUrl", r.ResourceGroupURL)
populate(objectMap, "subscriptionId", r.SubscriptionID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceGroupCarbonEmissionTopItemsSummaryData.
func (r *ResourceGroupCarbonEmissionTopItemsSummaryData) 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 "categoryType":
err = unpopulate(val, "CategoryType", &r.CategoryType)
delete(rawMsg, key)
case "dataType":
err = unpopulate(val, "DataType", &r.DataType)
delete(rawMsg, key)
case "itemName":
err = unpopulate(val, "ItemName", &r.ItemName)
delete(rawMsg, key)
case "latestMonthEmissions":
err = unpopulate(val, "LatestMonthEmissions", &r.LatestMonthEmissions)
delete(rawMsg, key)
case "monthOverMonthEmissionsChangeRatio":
err = unpopulate(val, "MonthOverMonthEmissionsChangeRatio", &r.MonthOverMonthEmissionsChangeRatio)
delete(rawMsg, key)
case "monthlyEmissionsChangeValue":
err = unpopulate(val, "MonthlyEmissionsChangeValue", &r.MonthlyEmissionsChangeValue)
delete(rawMsg, key)
case "previousMonthEmissions":
err = unpopulate(val, "PreviousMonthEmissions", &r.PreviousMonthEmissions)
delete(rawMsg, key)
case "resourceGroupUrl":
err = unpopulate(val, "ResourceGroupURL", &r.ResourceGroupURL)
delete(rawMsg, key)
case "subscriptionId":
err = unpopulate(val, "SubscriptionID", &r.SubscriptionID)
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 SubscriptionAccessDecision.
func (s SubscriptionAccessDecision) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "decision", s.Decision)
populate(objectMap, "denialReason", s.DenialReason)
populate(objectMap, "subscriptionId", s.SubscriptionID)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionAccessDecision.
func (s *SubscriptionAccessDecision) 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 "decision":
err = unpopulate(val, "Decision", &s.Decision)
delete(rawMsg, key)
case "denialReason":
err = unpopulate(val, "DenialReason", &s.DenialReason)
delete(rawMsg, key)
case "subscriptionId":
err = unpopulate(val, "SubscriptionID", &s.SubscriptionID)
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 TopItemsMonthlySummaryReportQueryFilter.
func (t TopItemsMonthlySummaryReportQueryFilter) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "carbonScopeList", t.CarbonScopeList)
populate(objectMap, "categoryType", t.CategoryType)
populate(objectMap, "dateRange", t.DateRange)
populate(objectMap, "locationList", t.LocationList)
objectMap["reportType"] = ReportTypeEnumTopItemsMonthlySummaryReport
populate(objectMap, "resourceGroupUrlList", t.ResourceGroupURLList)
populate(objectMap, "resourceTypeList", t.ResourceTypeList)
populate(objectMap, "subscriptionList", t.SubscriptionList)
populate(objectMap, "topItems", t.TopItems)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type TopItemsMonthlySummaryReportQueryFilter.
func (t *TopItemsMonthlySummaryReportQueryFilter) 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 "carbonScopeList":
err = unpopulate(val, "CarbonScopeList", &t.CarbonScopeList)
delete(rawMsg, key)
case "categoryType":
err = unpopulate(val, "CategoryType", &t.CategoryType)
delete(rawMsg, key)
case "dateRange":
err = unpopulate(val, "DateRange", &t.DateRange)
delete(rawMsg, key)
case "locationList":
err = unpopulate(val, "LocationList", &t.LocationList)
delete(rawMsg, key)
case "reportType":
err = unpopulate(val, "ReportType", &t.ReportType)
delete(rawMsg, key)
case "resourceGroupUrlList":
err = unpopulate(val, "ResourceGroupURLList", &t.ResourceGroupURLList)
delete(rawMsg, key)
case "resourceTypeList":
err = unpopulate(val, "ResourceTypeList", &t.ResourceTypeList)
delete(rawMsg, key)
case "subscriptionList":
err = unpopulate(val, "SubscriptionList", &t.SubscriptionList)
delete(rawMsg, key)
case "topItems":
err = unpopulate(val, "TopItems", &t.TopItems)
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 TopItemsSummaryReportQueryFilter.
func (t TopItemsSummaryReportQueryFilter) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]any)
populate(objectMap, "carbonScopeList", t.CarbonScopeList)
populate(objectMap, "categoryType", t.CategoryType)
populate(objectMap, "dateRange", t.DateRange)
populate(objectMap, "locationList", t.LocationList)
objectMap["reportType"] = ReportTypeEnumTopItemsSummaryReport
populate(objectMap, "resourceGroupUrlList", t.ResourceGroupURLList)
populate(objectMap, "resourceTypeList", t.ResourceTypeList)
populate(objectMap, "subscriptionList", t.SubscriptionList)
populate(objectMap, "topItems", t.TopItems)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type TopItemsSummaryReportQueryFilter.
func (t *TopItemsSummaryReportQueryFilter) 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 "carbonScopeList":
err = unpopulate(val, "CarbonScopeList", &t.CarbonScopeList)
delete(rawMsg, key)
case "categoryType":
err = unpopulate(val, "CategoryType", &t.CategoryType)
delete(rawMsg, key)
case "dateRange":
err = unpopulate(val, "DateRange", &t.DateRange)
delete(rawMsg, key)
case "locationList":
err = unpopulate(val, "LocationList", &t.LocationList)
delete(rawMsg, key)
case "reportType":
err = unpopulate(val, "ReportType", &t.ReportType)
delete(rawMsg, key)
case "resourceGroupUrlList":
err = unpopulate(val, "ResourceGroupURLList", &t.ResourceGroupURLList)
delete(rawMsg, key)
case "resourceTypeList":
err = unpopulate(val, "ResourceTypeList", &t.ResourceTypeList)
delete(rawMsg, key)
case "subscriptionList":
err = unpopulate(val, "SubscriptionList", &t.SubscriptionList)
delete(rawMsg, key)
case "topItems":
err = unpopulate(val, "TopItems", &t.TopItems)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", t, 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 unpopulate(data json.RawMessage, fn string, v any) error {
if data == nil || string(data) == "null" {
return nil
}
if err := json.Unmarshal(data, v); err != nil {
return fmt.Errorf("struct field %s: %v", fn, err)
}
return nil
}