...

Source file src/github.com/prometheus/alertmanager/api/v2/models/alertmanager_status.go

Documentation: github.com/prometheus/alertmanager/api/v2/models

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Prometheus Team
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  // http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  //
    16  
    17  package models
    18  
    19  // This file was generated by the swagger tool.
    20  // Editing this file might prove futile when you re-run the swagger generate command
    21  
    22  import (
    23  	"context"
    24  
    25  	"github.com/go-openapi/errors"
    26  	"github.com/go-openapi/strfmt"
    27  	"github.com/go-openapi/swag"
    28  	"github.com/go-openapi/validate"
    29  )
    30  
    31  // AlertmanagerStatus alertmanager status
    32  //
    33  // swagger:model alertmanagerStatus
    34  type AlertmanagerStatus struct {
    35  
    36  	// cluster
    37  	// Required: true
    38  	Cluster *ClusterStatus `json:"cluster"`
    39  
    40  	// config
    41  	// Required: true
    42  	Config *AlertmanagerConfig `json:"config"`
    43  
    44  	// uptime
    45  	// Required: true
    46  	// Format: date-time
    47  	Uptime *strfmt.DateTime `json:"uptime"`
    48  
    49  	// version info
    50  	// Required: true
    51  	VersionInfo *VersionInfo `json:"versionInfo"`
    52  }
    53  
    54  // Validate validates this alertmanager status
    55  func (m *AlertmanagerStatus) Validate(formats strfmt.Registry) error {
    56  	var res []error
    57  
    58  	if err := m.validateCluster(formats); err != nil {
    59  		res = append(res, err)
    60  	}
    61  
    62  	if err := m.validateConfig(formats); err != nil {
    63  		res = append(res, err)
    64  	}
    65  
    66  	if err := m.validateUptime(formats); err != nil {
    67  		res = append(res, err)
    68  	}
    69  
    70  	if err := m.validateVersionInfo(formats); err != nil {
    71  		res = append(res, err)
    72  	}
    73  
    74  	if len(res) > 0 {
    75  		return errors.CompositeValidationError(res...)
    76  	}
    77  	return nil
    78  }
    79  
    80  func (m *AlertmanagerStatus) validateCluster(formats strfmt.Registry) error {
    81  
    82  	if err := validate.Required("cluster", "body", m.Cluster); err != nil {
    83  		return err
    84  	}
    85  
    86  	if m.Cluster != nil {
    87  		if err := m.Cluster.Validate(formats); err != nil {
    88  			if ve, ok := err.(*errors.Validation); ok {
    89  				return ve.ValidateName("cluster")
    90  			} else if ce, ok := err.(*errors.CompositeError); ok {
    91  				return ce.ValidateName("cluster")
    92  			}
    93  			return err
    94  		}
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  func (m *AlertmanagerStatus) validateConfig(formats strfmt.Registry) error {
   101  
   102  	if err := validate.Required("config", "body", m.Config); err != nil {
   103  		return err
   104  	}
   105  
   106  	if m.Config != nil {
   107  		if err := m.Config.Validate(formats); err != nil {
   108  			if ve, ok := err.(*errors.Validation); ok {
   109  				return ve.ValidateName("config")
   110  			} else if ce, ok := err.(*errors.CompositeError); ok {
   111  				return ce.ValidateName("config")
   112  			}
   113  			return err
   114  		}
   115  	}
   116  
   117  	return nil
   118  }
   119  
   120  func (m *AlertmanagerStatus) validateUptime(formats strfmt.Registry) error {
   121  
   122  	if err := validate.Required("uptime", "body", m.Uptime); err != nil {
   123  		return err
   124  	}
   125  
   126  	if err := validate.FormatOf("uptime", "body", "date-time", m.Uptime.String(), formats); err != nil {
   127  		return err
   128  	}
   129  
   130  	return nil
   131  }
   132  
   133  func (m *AlertmanagerStatus) validateVersionInfo(formats strfmt.Registry) error {
   134  
   135  	if err := validate.Required("versionInfo", "body", m.VersionInfo); err != nil {
   136  		return err
   137  	}
   138  
   139  	if m.VersionInfo != nil {
   140  		if err := m.VersionInfo.Validate(formats); err != nil {
   141  			if ve, ok := err.(*errors.Validation); ok {
   142  				return ve.ValidateName("versionInfo")
   143  			} else if ce, ok := err.(*errors.CompositeError); ok {
   144  				return ce.ValidateName("versionInfo")
   145  			}
   146  			return err
   147  		}
   148  	}
   149  
   150  	return nil
   151  }
   152  
   153  // ContextValidate validate this alertmanager status based on the context it is used
   154  func (m *AlertmanagerStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   155  	var res []error
   156  
   157  	if err := m.contextValidateCluster(ctx, formats); err != nil {
   158  		res = append(res, err)
   159  	}
   160  
   161  	if err := m.contextValidateConfig(ctx, formats); err != nil {
   162  		res = append(res, err)
   163  	}
   164  
   165  	if err := m.contextValidateVersionInfo(ctx, formats); err != nil {
   166  		res = append(res, err)
   167  	}
   168  
   169  	if len(res) > 0 {
   170  		return errors.CompositeValidationError(res...)
   171  	}
   172  	return nil
   173  }
   174  
   175  func (m *AlertmanagerStatus) contextValidateCluster(ctx context.Context, formats strfmt.Registry) error {
   176  
   177  	if m.Cluster != nil {
   178  		if err := m.Cluster.ContextValidate(ctx, formats); err != nil {
   179  			if ve, ok := err.(*errors.Validation); ok {
   180  				return ve.ValidateName("cluster")
   181  			} else if ce, ok := err.(*errors.CompositeError); ok {
   182  				return ce.ValidateName("cluster")
   183  			}
   184  			return err
   185  		}
   186  	}
   187  
   188  	return nil
   189  }
   190  
   191  func (m *AlertmanagerStatus) contextValidateConfig(ctx context.Context, formats strfmt.Registry) error {
   192  
   193  	if m.Config != nil {
   194  		if err := m.Config.ContextValidate(ctx, formats); err != nil {
   195  			if ve, ok := err.(*errors.Validation); ok {
   196  				return ve.ValidateName("config")
   197  			} else if ce, ok := err.(*errors.CompositeError); ok {
   198  				return ce.ValidateName("config")
   199  			}
   200  			return err
   201  		}
   202  	}
   203  
   204  	return nil
   205  }
   206  
   207  func (m *AlertmanagerStatus) contextValidateVersionInfo(ctx context.Context, formats strfmt.Registry) error {
   208  
   209  	if m.VersionInfo != nil {
   210  		if err := m.VersionInfo.ContextValidate(ctx, formats); err != nil {
   211  			if ve, ok := err.(*errors.Validation); ok {
   212  				return ve.ValidateName("versionInfo")
   213  			} else if ce, ok := err.(*errors.CompositeError); ok {
   214  				return ce.ValidateName("versionInfo")
   215  			}
   216  			return err
   217  		}
   218  	}
   219  
   220  	return nil
   221  }
   222  
   223  // MarshalBinary interface implementation
   224  func (m *AlertmanagerStatus) MarshalBinary() ([]byte, error) {
   225  	if m == nil {
   226  		return nil, nil
   227  	}
   228  	return swag.WriteJSON(m)
   229  }
   230  
   231  // UnmarshalBinary interface implementation
   232  func (m *AlertmanagerStatus) UnmarshalBinary(b []byte) error {
   233  	var res AlertmanagerStatus
   234  	if err := swag.ReadJSON(b, &res); err != nil {
   235  		return err
   236  	}
   237  	*m = res
   238  	return nil
   239  }
   240  

View as plain text