...

Source file src/github.com/prometheus/alertmanager/api/v2/models/silence_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  	"encoding/json"
    25  
    26  	"github.com/go-openapi/errors"
    27  	"github.com/go-openapi/strfmt"
    28  	"github.com/go-openapi/swag"
    29  	"github.com/go-openapi/validate"
    30  )
    31  
    32  // SilenceStatus silence status
    33  //
    34  // swagger:model silenceStatus
    35  type SilenceStatus struct {
    36  
    37  	// state
    38  	// Required: true
    39  	// Enum: [expired active pending]
    40  	State *string `json:"state"`
    41  }
    42  
    43  // Validate validates this silence status
    44  func (m *SilenceStatus) Validate(formats strfmt.Registry) error {
    45  	var res []error
    46  
    47  	if err := m.validateState(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if len(res) > 0 {
    52  		return errors.CompositeValidationError(res...)
    53  	}
    54  	return nil
    55  }
    56  
    57  var silenceStatusTypeStatePropEnum []interface{}
    58  
    59  func init() {
    60  	var res []string
    61  	if err := json.Unmarshal([]byte(`["expired","active","pending"]`), &res); err != nil {
    62  		panic(err)
    63  	}
    64  	for _, v := range res {
    65  		silenceStatusTypeStatePropEnum = append(silenceStatusTypeStatePropEnum, v)
    66  	}
    67  }
    68  
    69  const (
    70  
    71  	// SilenceStatusStateExpired captures enum value "expired"
    72  	SilenceStatusStateExpired string = "expired"
    73  
    74  	// SilenceStatusStateActive captures enum value "active"
    75  	SilenceStatusStateActive string = "active"
    76  
    77  	// SilenceStatusStatePending captures enum value "pending"
    78  	SilenceStatusStatePending string = "pending"
    79  )
    80  
    81  // prop value enum
    82  func (m *SilenceStatus) validateStateEnum(path, location string, value string) error {
    83  	if err := validate.EnumCase(path, location, value, silenceStatusTypeStatePropEnum, true); err != nil {
    84  		return err
    85  	}
    86  	return nil
    87  }
    88  
    89  func (m *SilenceStatus) validateState(formats strfmt.Registry) error {
    90  
    91  	if err := validate.Required("state", "body", m.State); err != nil {
    92  		return err
    93  	}
    94  
    95  	// value enum
    96  	if err := m.validateStateEnum("state", "body", *m.State); err != nil {
    97  		return err
    98  	}
    99  
   100  	return nil
   101  }
   102  
   103  // ContextValidate validates this silence status based on context it is used
   104  func (m *SilenceStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   105  	return nil
   106  }
   107  
   108  // MarshalBinary interface implementation
   109  func (m *SilenceStatus) MarshalBinary() ([]byte, error) {
   110  	if m == nil {
   111  		return nil, nil
   112  	}
   113  	return swag.WriteJSON(m)
   114  }
   115  
   116  // UnmarshalBinary interface implementation
   117  func (m *SilenceStatus) UnmarshalBinary(b []byte) error {
   118  	var res SilenceStatus
   119  	if err := swag.ReadJSON(b, &res); err != nil {
   120  		return err
   121  	}
   122  	*m = res
   123  	return nil
   124  }
   125  

View as plain text