in service/applicationinsights/deserializers.go [4961:5461]
func awsAwsjson11_deserializeDocumentObservation(v **types.Observation, 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.Observation
if *v == nil {
sv = &types.Observation{}
} else {
sv = *v
}
for key, value := range shape {
switch key {
case "CloudWatchEventDetailType":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected CloudWatchEventDetailType to be of type string, got %T instead", value)
}
sv.CloudWatchEventDetailType = ptr.String(jtv)
}
case "CloudWatchEventId":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected CloudWatchEventId to be of type string, got %T instead", value)
}
sv.CloudWatchEventId = ptr.String(jtv)
}
case "CloudWatchEventSource":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected CloudWatchEventSource to be of type string, got %T instead", value)
}
sv.CloudWatchEventSource = types.CloudWatchEventSource(jtv)
}
case "CodeDeployApplication":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected CodeDeployApplication to be of type string, got %T instead", value)
}
sv.CodeDeployApplication = ptr.String(jtv)
}
case "CodeDeployDeploymentGroup":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected CodeDeployDeploymentGroup to be of type string, got %T instead", value)
}
sv.CodeDeployDeploymentGroup = ptr.String(jtv)
}
case "CodeDeployDeploymentId":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected CodeDeployDeploymentId to be of type string, got %T instead", value)
}
sv.CodeDeployDeploymentId = ptr.String(jtv)
}
case "CodeDeployInstanceGroupId":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected CodeDeployInstanceGroupId to be of type string, got %T instead", value)
}
sv.CodeDeployInstanceGroupId = ptr.String(jtv)
}
case "CodeDeployState":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected CodeDeployState to be of type string, got %T instead", value)
}
sv.CodeDeployState = ptr.String(jtv)
}
case "EbsCause":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected EbsCause to be of type string, got %T instead", value)
}
sv.EbsCause = ptr.String(jtv)
}
case "EbsEvent":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected EbsEvent to be of type string, got %T instead", value)
}
sv.EbsEvent = ptr.String(jtv)
}
case "EbsRequestId":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected EbsRequestId to be of type string, got %T instead", value)
}
sv.EbsRequestId = ptr.String(jtv)
}
case "EbsResult":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected EbsResult to be of type string, got %T instead", value)
}
sv.EbsResult = ptr.String(jtv)
}
case "Ec2State":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected Ec2State to be of type string, got %T instead", value)
}
sv.Ec2State = ptr.String(jtv)
}
case "EndTime":
if value != nil {
switch jtv := value.(type) {
case json.Number:
f64, err := jtv.Float64()
if err != nil {
return err
}
sv.EndTime = ptr.Time(smithytime.ParseEpochSeconds(f64))
default:
return fmt.Errorf("expected EndTime to be a JSON Number, got %T instead", value)
}
}
case "HealthEventArn":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected HealthEventArn to be of type string, got %T instead", value)
}
sv.HealthEventArn = ptr.String(jtv)
}
case "HealthEventDescription":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected HealthEventDescription to be of type string, got %T instead", value)
}
sv.HealthEventDescription = ptr.String(jtv)
}
case "HealthEventTypeCategory":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected HealthEventTypeCategory to be of type string, got %T instead", value)
}
sv.HealthEventTypeCategory = ptr.String(jtv)
}
case "HealthEventTypeCode":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected HealthEventTypeCode to be of type string, got %T instead", value)
}
sv.HealthEventTypeCode = ptr.String(jtv)
}
case "HealthService":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected HealthService to be of type string, got %T instead", value)
}
sv.HealthService = ptr.String(jtv)
}
case "Id":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected ObservationId to be of type string, got %T instead", value)
}
sv.Id = ptr.String(jtv)
}
case "LineTime":
if value != nil {
switch jtv := value.(type) {
case json.Number:
f64, err := jtv.Float64()
if err != nil {
return err
}
sv.LineTime = ptr.Time(smithytime.ParseEpochSeconds(f64))
default:
return fmt.Errorf("expected LineTime to be a JSON Number, got %T instead", value)
}
}
case "LogFilter":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected LogFilter to be of type string, got %T instead", value)
}
sv.LogFilter = types.LogFilter(jtv)
}
case "LogGroup":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected LogGroup to be of type string, got %T instead", value)
}
sv.LogGroup = ptr.String(jtv)
}
case "LogText":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected LogText to be of type string, got %T instead", value)
}
sv.LogText = ptr.String(jtv)
}
case "MetricName":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected MetricName to be of type string, got %T instead", value)
}
sv.MetricName = ptr.String(jtv)
}
case "MetricNamespace":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected MetricNamespace to be of type string, got %T instead", value)
}
sv.MetricNamespace = ptr.String(jtv)
}
case "RdsEventCategories":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected RdsEventCategories to be of type string, got %T instead", value)
}
sv.RdsEventCategories = ptr.String(jtv)
}
case "RdsEventMessage":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected RdsEventMessage to be of type string, got %T instead", value)
}
sv.RdsEventMessage = ptr.String(jtv)
}
case "S3EventName":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected S3EventName to be of type string, got %T instead", value)
}
sv.S3EventName = ptr.String(jtv)
}
case "SourceARN":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected SourceARN to be of type string, got %T instead", value)
}
sv.SourceARN = ptr.String(jtv)
}
case "SourceType":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected SourceType to be of type string, got %T instead", value)
}
sv.SourceType = ptr.String(jtv)
}
case "StartTime":
if value != nil {
switch jtv := value.(type) {
case json.Number:
f64, err := jtv.Float64()
if err != nil {
return err
}
sv.StartTime = ptr.Time(smithytime.ParseEpochSeconds(f64))
default:
return fmt.Errorf("expected StartTime to be a JSON Number, got %T instead", value)
}
}
case "StatesArn":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected StatesArn to be of type string, got %T instead", value)
}
sv.StatesArn = ptr.String(jtv)
}
case "StatesExecutionArn":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected StatesExecutionArn to be of type string, got %T instead", value)
}
sv.StatesExecutionArn = ptr.String(jtv)
}
case "StatesInput":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected StatesInput to be of type string, got %T instead", value)
}
sv.StatesInput = ptr.String(jtv)
}
case "StatesStatus":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected StatesStatus to be of type string, got %T instead", value)
}
sv.StatesStatus = ptr.String(jtv)
}
case "Unit":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected Unit to be of type string, got %T instead", value)
}
sv.Unit = ptr.String(jtv)
}
case "Value":
if value != nil {
switch jtv := value.(type) {
case json.Number:
f64, err := jtv.Float64()
if err != nil {
return err
}
sv.Value = 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.Value = ptr.Float64(f64)
default:
return fmt.Errorf("expected Value to be a JSON Number, got %T instead", value)
}
}
case "XRayErrorPercent":
if value != nil {
jtv, ok := value.(json.Number)
if !ok {
return fmt.Errorf("expected XRayErrorPercent to be json.Number, got %T instead", value)
}
i64, err := jtv.Int64()
if err != nil {
return err
}
sv.XRayErrorPercent = ptr.Int32(int32(i64))
}
case "XRayFaultPercent":
if value != nil {
jtv, ok := value.(json.Number)
if !ok {
return fmt.Errorf("expected XRayFaultPercent to be json.Number, got %T instead", value)
}
i64, err := jtv.Int64()
if err != nil {
return err
}
sv.XRayFaultPercent = ptr.Int32(int32(i64))
}
case "XRayNodeName":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected XRayNodeName to be of type string, got %T instead", value)
}
sv.XRayNodeName = ptr.String(jtv)
}
case "XRayNodeType":
if value != nil {
jtv, ok := value.(string)
if !ok {
return fmt.Errorf("expected XRayNodeType to be of type string, got %T instead", value)
}
sv.XRayNodeType = ptr.String(jtv)
}
case "XRayRequestAverageLatency":
if value != nil {
jtv, ok := value.(json.Number)
if !ok {
return fmt.Errorf("expected XRayRequestAverageLatency to be json.Number, got %T instead", value)
}
i64, err := jtv.Int64()
if err != nil {
return err
}
sv.XRayRequestAverageLatency = ptr.Int64(i64)
}
case "XRayRequestCount":
if value != nil {
jtv, ok := value.(json.Number)
if !ok {
return fmt.Errorf("expected XRayRequestCount to be json.Number, got %T instead", value)
}
i64, err := jtv.Int64()
if err != nil {
return err
}
sv.XRayRequestCount = ptr.Int32(int32(i64))
}
case "XRayThrottlePercent":
if value != nil {
jtv, ok := value.(json.Number)
if !ok {
return fmt.Errorf("expected XRayThrottlePercent to be json.Number, got %T instead", value)
}
i64, err := jtv.Int64()
if err != nil {
return err
}
sv.XRayThrottlePercent = ptr.Int32(int32(i64))
}
default:
_, _ = key, value
}
}
*v = sv
return nil
}