github.com/mweagle/Sparta@v1.15.0/aws/cloudwatch/emf.go (about)

     1  // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
     2  
     3  package cloudwatch
     4  
     5  import (
     6  	"encoding/json"
     7  	"fmt"
     8  )
     9  
    10  //lint:ignore U1000 because it's actually used
    11  type emf struct {
    12  	// AWS corresponds to the JSON schema field "_aws".
    13  	AWS emfAWS `json:"_aws"`
    14  }
    15  
    16  // UnmarshalJSON implements json.Unmarshaler.
    17  func (j *emfAWSCloudWatchMetricsElemMetricsElem) UnmarshalJSON(b []byte) error {
    18  	var raw map[string]interface{}
    19  	if err := json.Unmarshal(b, &raw); err != nil {
    20  		return err
    21  	}
    22  	if v, ok := raw["Name"]; !ok || v == nil {
    23  		return fmt.Errorf("field Name: required")
    24  	}
    25  	if v, ok := raw["Unit"]; !ok || v == nil {
    26  		return fmt.Errorf("field Unit: required")
    27  	}
    28  	type Plain emfAWSCloudWatchMetricsElemMetricsElem
    29  	var plain Plain
    30  	if err := json.Unmarshal(b, &plain); err != nil {
    31  		return err
    32  	}
    33  	*j = emfAWSCloudWatchMetricsElemMetricsElem(plain)
    34  	return nil
    35  }
    36  
    37  type emfAWSCloudWatchMetricsElem struct {
    38  	// Dimensions corresponds to the JSON schema field "Dimensions".
    39  	Dimensions [][]string `json:"Dimensions"`
    40  
    41  	// Metrics corresponds to the JSON schema field "Metrics".
    42  	Metrics []emfAWSCloudWatchMetricsElemMetricsElem `json:"Metrics"`
    43  
    44  	// Namespace corresponds to the JSON schema field "Namespace".
    45  	Namespace string `json:"Namespace"`
    46  }
    47  
    48  // UnmarshalJSON implements json.Unmarshaler.
    49  func (j *emfAWSCloudWatchMetricsElem) UnmarshalJSON(b []byte) error {
    50  	var raw map[string]interface{}
    51  	if err := json.Unmarshal(b, &raw); err != nil {
    52  		return err
    53  	}
    54  	if v, ok := raw["Dimensions"]; !ok || v == nil {
    55  		return fmt.Errorf("field Dimensions: required")
    56  	}
    57  	if v, ok := raw["Metrics"]; !ok || v == nil {
    58  		return fmt.Errorf("field Metrics: required")
    59  	}
    60  	if v, ok := raw["Namespace"]; !ok || v == nil {
    61  		return fmt.Errorf("field Namespace: required")
    62  	}
    63  	type Plain emfAWSCloudWatchMetricsElem
    64  	var plain Plain
    65  	if err := json.Unmarshal(b, &plain); err != nil {
    66  		return err
    67  	}
    68  	*j = emfAWSCloudWatchMetricsElem(plain)
    69  	return nil
    70  }
    71  
    72  type emfAWS struct {
    73  	// CloudWatchMetrics corresponds to the JSON schema field "CloudWatchMetrics".
    74  	CloudWatchMetrics []emfAWSCloudWatchMetricsElem `json:"CloudWatchMetrics"`
    75  
    76  	// Timestamp corresponds to the JSON schema field "Timestamp".
    77  	Timestamp int `json:"Timestamp"`
    78  }
    79  
    80  // UnmarshalJSON implements json.Unmarshaler.
    81  func (j *emfAWS) UnmarshalJSON(b []byte) error {
    82  	var raw map[string]interface{}
    83  	if err := json.Unmarshal(b, &raw); err != nil {
    84  		return err
    85  	}
    86  	if v, ok := raw["CloudWatchMetrics"]; !ok || v == nil {
    87  		return fmt.Errorf("field CloudWatchMetrics: required")
    88  	}
    89  	if v, ok := raw["Timestamp"]; !ok || v == nil {
    90  		return fmt.Errorf("field Timestamp: required")
    91  	}
    92  	type Plain emfAWS
    93  	var plain Plain
    94  	if err := json.Unmarshal(b, &plain); err != nil {
    95  		return err
    96  	}
    97  	*j = emfAWS(plain)
    98  	return nil
    99  }
   100  
   101  type emfAWSCloudWatchMetricsElemMetricsElem struct {
   102  	// Name corresponds to the JSON schema field "Name".
   103  	Name string `json:"Name"`
   104  
   105  	// Unit corresponds to the JSON schema field "Unit".
   106  	Unit string `json:"Unit"`
   107  }
   108  
   109  // UnmarshalJSON implements json.Unmarshaler.
   110  func (j *emf) UnmarshalJSON(b []byte) error {
   111  	var raw map[string]interface{}
   112  	if err := json.Unmarshal(b, &raw); err != nil {
   113  		return err
   114  	}
   115  	if v, ok := raw["_aws"]; !ok || v == nil {
   116  		return fmt.Errorf("field _aws: required")
   117  	}
   118  	//lint:ignore U1000 because it's actually used
   119  	type Plain emf
   120  	var plain Plain
   121  	if err := json.Unmarshal(b, &plain); err != nil {
   122  		return err
   123  	}
   124  	*j = emf(plain)
   125  	return nil
   126  }