// Code generated by go-swagger; DO NOT EDIT.

package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// DataPoint data point
//
// swagger:model DataPoint
type DataPoint struct {

	// alert body
	AlertBody string `json:"alertBody,omitempty"`

	// alert clear transition interval
	AlertClearTransitionInterval int32 `json:"alertClearTransitionInterval,omitempty"`

	// alert expr
	AlertExpr string `json:"alertExpr,omitempty"`

	// alert expr note
	AlertExprNote string `json:"alertExprNote,omitempty"`

	// alert for no data
	AlertForNoData int32 `json:"alertForNoData,omitempty"`

	// alert subject
	AlertSubject string `json:"alertSubject,omitempty"`

	// alert transition interval
	AlertTransitionInterval int32 `json:"alertTransitionInterval,omitempty"`

	// data source Id
	// Read Only: true
	DataSourceID int32 `json:"dataSourceId,omitempty"`

	// data type
	DataType int32 `json:"dataType,omitempty"`

	// description
	Description string `json:"description,omitempty"`

	// id
	// Read Only: true
	ID int32 `json:"id,omitempty"`

	// max digits
	MaxDigits int32 `json:"maxDigits,omitempty"`

	// max value
	MaxValue string `json:"maxValue,omitempty"`

	// min value
	MinValue string `json:"minValue,omitempty"`

	// name
	// Required: true
	Name *string `json:"name"`

	// post processor method
	PostProcessorMethod string `json:"postProcessorMethod,omitempty"`

	// post processor param
	PostProcessorParam string `json:"postProcessorParam,omitempty"`

	// raw data field name
	RawDataFieldName string `json:"rawDataFieldName,omitempty"`

	// type
	Type int32 `json:"type,omitempty"`

	// user param1
	UserParam1 string `json:"userParam1,omitempty"`

	// user param2
	UserParam2 string `json:"userParam2,omitempty"`

	// user param3
	UserParam3 string `json:"userParam3,omitempty"`
}

// Validate validates this data point
func (m *DataPoint) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateName(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *DataPoint) validateName(formats strfmt.Registry) error {

	if err := validate.Required("name", "body", m.Name); err != nil {
		return err
	}

	return nil
}

// ContextValidate validate this data point based on the context it is used
func (m *DataPoint) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateDataSourceID(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateID(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *DataPoint) contextValidateDataSourceID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "dataSourceId", "body", int32(m.DataSourceID)); err != nil {
		return err
	}

	return nil
}

func (m *DataPoint) contextValidateID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "id", "body", int32(m.ID)); err != nil {
		return err
	}

	return nil
}

// MarshalBinary interface implementation
func (m *DataPoint) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *DataPoint) UnmarshalBinary(b []byte) error {
	var res DataPoint
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
