in service/costoptimizationhub/deserializers.go [3796:4096]
func awsAwsjson10_deserializeDocumentRecommendation(v **types.Recommendation, value interface{}) error {
if v == nil {
return fmt.Errorf("unexpected nil of type %T", v)
}
if value == nil {
return nil
}
shape, ok := value.(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected JSON type %v", value)
}
var sv *types.Recommendation
if *v == nil {
sv = &types.Recommendation{}
} else {
sv = *v
}
for key, value := range shape {
switch key {
case "accountId":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.AccountId = ptr.String(jtv)
}
case "actionType":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.ActionType = ptr.String(jtv)
}
case "currencyCode":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.CurrencyCode = ptr.String(jtv)
}
case "currentResourceSummary":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.CurrentResourceSummary = ptr.String(jtv)
}
case "currentResourceType":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.CurrentResourceType = ptr.String(jtv)
}
case "estimatedMonthlyCost":
if value != nil {
switch jtv := value.(type) {
case json.Number:
f64, err := jtv.Float64()
if err != nil {
return err
}
sv.EstimatedMonthlyCost = ptr.Float64(f64)
case string:
var f64 float64
switch {
case strings.EqualFold(jtv, "NaN"):
f64 = math.NaN()
case strings.EqualFold(jtv, "Infinity"):
f64 = math.Inf(1)
case strings.EqualFold(jtv, "-Infinity"):
f64 = math.Inf(-1)
default:
return fmt.Errorf("unknown JSON number value: %s", jtv)
}
sv.EstimatedMonthlyCost = ptr.Float64(f64)
default:
return fmt.Errorf("expected Double to be a JSON Number, got %T instead", value)
}
}
case "estimatedMonthlySavings":
if value != nil {
switch jtv := value.(type) {
case json.Number:
f64, err := jtv.Float64()
if err != nil {
return err
}
sv.EstimatedMonthlySavings = ptr.Float64(f64)
case string:
var f64 float64
switch {
case strings.EqualFold(jtv, "NaN"):
f64 = math.NaN()
case strings.EqualFold(jtv, "Infinity"):
f64 = math.Inf(1)
case strings.EqualFold(jtv, "-Infinity"):
f64 = math.Inf(-1)
default:
return fmt.Errorf("unknown JSON number value: %s", jtv)
}
sv.EstimatedMonthlySavings = ptr.Float64(f64)
default:
return fmt.Errorf("expected Double to be a JSON Number, got %T instead", value)
}
}
case "estimatedSavingsPercentage":
if value != nil {
switch jtv := value.(type) {
case json.Number:
f64, err := jtv.Float64()
if err != nil {
return err
}
sv.EstimatedSavingsPercentage = ptr.Float64(f64)
case string:
var f64 float64
switch {
case strings.EqualFold(jtv, "NaN"):
f64 = math.NaN()
case strings.EqualFold(jtv, "Infinity"):
f64 = math.Inf(1)
case strings.EqualFold(jtv, "-Infinity"):
f64 = math.Inf(-1)
default:
return fmt.Errorf("unknown JSON number value: %s", jtv)
}
sv.EstimatedSavingsPercentage = ptr.Float64(f64)
default:
return fmt.Errorf("expected Double to be a JSON Number, got %T instead", value)
}
}
case "implementationEffort":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.ImplementationEffort = ptr.String(jtv)
}
case "lastRefreshTimestamp":
if value != nil {
switch jtv := value.(type) {
case json.Number:
f64, err := jtv.Float64()
if err != nil {
return err
}
sv.LastRefreshTimestamp = ptr.Time(smithytime.ParseEpochSeconds(f64))
default:
return fmt.Errorf("expected Datetime to be a JSON Number, got %T instead", value)
}
}
case "recommendationId":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.RecommendationId = ptr.String(jtv)
}
case "recommendationLookbackPeriodInDays":
if value != nil {
jtv, ok := value.(json.Number)
if !ok {
return fmt.Errorf("expected Integer to be json.Number, got %T instead", value)
}
i64, err := jtv.Int64()
if err != nil {
return err
}
sv.RecommendationLookbackPeriodInDays = ptr.Int32(int32(i64))
}
case "recommendedResourceSummary":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.RecommendedResourceSummary = ptr.String(jtv)
}
case "recommendedResourceType":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.RecommendedResourceType = ptr.String(jtv)
}
case "region":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.Region = ptr.String(jtv)
}
case "resourceArn":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.ResourceArn = ptr.String(jtv)
}
case "resourceId":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected String to be of type string, got %T instead", value)
}
sv.ResourceId = ptr.String(jtv)
}
case "restartNeeded":
if value != nil {
jtv, ok := value.(bool)
if !ok {
return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", value)
}
sv.RestartNeeded = ptr.Bool(jtv)
}
case "rollbackPossible":
if value != nil {
jtv, ok := value.(bool)
if !ok {
return fmt.Errorf("expected Boolean to be of type *bool, got %T instead", value)
}
sv.RollbackPossible = ptr.Bool(jtv)
}
case "source":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected Source to be of type string, got %T instead", value)
}
sv.Source = types.Source(jtv)
}
case "tags":
if err := awsAwsjson10_deserializeDocumentTagList(&sv.Tags, value); err != nil {
return err
}
default:
_, _ = key, value
}
}
*v = sv
return nil
}