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

package ops

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

import (
	"context"
	"strconv"

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

// DashboardCloudOncallInfoResp dashboard cloud oncall info resp
//
// swagger:model dashboard.CloudOncallInfoResp
type DashboardCloudOncallInfoResp struct {

	// backlog total
	BacklogTotal int64 `json:"backlogTotal,omitempty"`

	// component monthly trend
	ComponentMonthlyTrend []*EntitySeriesMonthlyTrend `json:"componentMonthlyTrend"`

	// monthly trend
	MonthlyTrend []*EntityMonthlyTrend `json:"monthlyTrend"`

	// priority monthly trends
	PriorityMonthlyTrends []*EntitySeriesMonthlyTrend `json:"priorityMonthlyTrends"`

	// top tenants
	TopTenants []*EntityTopTenant `json:"topTenants"`

	// total
	Total int64 `json:"total,omitempty"`

	// ttr in days
	TtrInDays float64 `json:"ttrInDays,omitempty"`
}

// Validate validates this dashboard cloud oncall info resp
func (m *DashboardCloudOncallInfoResp) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *DashboardCloudOncallInfoResp) validateComponentMonthlyTrend(formats strfmt.Registry) error {
	if swag.IsZero(m.ComponentMonthlyTrend) { // not required
		return nil
	}

	for i := 0; i < len(m.ComponentMonthlyTrend); i++ {
		if swag.IsZero(m.ComponentMonthlyTrend[i]) { // not required
			continue
		}

		if m.ComponentMonthlyTrend[i] != nil {
			if err := m.ComponentMonthlyTrend[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("componentMonthlyTrend" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("componentMonthlyTrend" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DashboardCloudOncallInfoResp) validateMonthlyTrend(formats strfmt.Registry) error {
	if swag.IsZero(m.MonthlyTrend) { // not required
		return nil
	}

	for i := 0; i < len(m.MonthlyTrend); i++ {
		if swag.IsZero(m.MonthlyTrend[i]) { // not required
			continue
		}

		if m.MonthlyTrend[i] != nil {
			if err := m.MonthlyTrend[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("monthlyTrend" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("monthlyTrend" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DashboardCloudOncallInfoResp) validatePriorityMonthlyTrends(formats strfmt.Registry) error {
	if swag.IsZero(m.PriorityMonthlyTrends) { // not required
		return nil
	}

	for i := 0; i < len(m.PriorityMonthlyTrends); i++ {
		if swag.IsZero(m.PriorityMonthlyTrends[i]) { // not required
			continue
		}

		if m.PriorityMonthlyTrends[i] != nil {
			if err := m.PriorityMonthlyTrends[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("priorityMonthlyTrends" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("priorityMonthlyTrends" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DashboardCloudOncallInfoResp) validateTopTenants(formats strfmt.Registry) error {
	if swag.IsZero(m.TopTenants) { // not required
		return nil
	}

	for i := 0; i < len(m.TopTenants); i++ {
		if swag.IsZero(m.TopTenants[i]) { // not required
			continue
		}

		if m.TopTenants[i] != nil {
			if err := m.TopTenants[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("topTenants" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("topTenants" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this dashboard cloud oncall info resp based on the context it is used
func (m *DashboardCloudOncallInfoResp) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *DashboardCloudOncallInfoResp) contextValidateComponentMonthlyTrend(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.ComponentMonthlyTrend); i++ {

		if m.ComponentMonthlyTrend[i] != nil {

			if swag.IsZero(m.ComponentMonthlyTrend[i]) { // not required
				return nil
			}

			if err := m.ComponentMonthlyTrend[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("componentMonthlyTrend" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("componentMonthlyTrend" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DashboardCloudOncallInfoResp) contextValidateMonthlyTrend(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.MonthlyTrend); i++ {

		if m.MonthlyTrend[i] != nil {

			if swag.IsZero(m.MonthlyTrend[i]) { // not required
				return nil
			}

			if err := m.MonthlyTrend[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("monthlyTrend" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("monthlyTrend" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DashboardCloudOncallInfoResp) contextValidatePriorityMonthlyTrends(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.PriorityMonthlyTrends); i++ {

		if m.PriorityMonthlyTrends[i] != nil {

			if swag.IsZero(m.PriorityMonthlyTrends[i]) { // not required
				return nil
			}

			if err := m.PriorityMonthlyTrends[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("priorityMonthlyTrends" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("priorityMonthlyTrends" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

func (m *DashboardCloudOncallInfoResp) contextValidateTopTenants(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.TopTenants); i++ {

		if m.TopTenants[i] != nil {

			if swag.IsZero(m.TopTenants[i]) { // not required
				return nil
			}

			if err := m.TopTenants[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("topTenants" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("topTenants" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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