// 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"
)

// APIGetGatewayDutyCycleMetricsResponse api get gateway duty cycle metrics response
//
// swagger:model apiGetGatewayDutyCycleMetricsResponse
type APIGetGatewayDutyCycleMetricsResponse struct {

	// Percentage relative to max load.
	MaxLoadPercentage *CommonMetric `json:"maxLoadPercentage,omitempty"`

	// Percentage relative to tracking window.
	WindowPercentage *CommonMetric `json:"windowPercentage,omitempty"`
}

// Validate validates this api get gateway duty cycle metrics response
func (m *APIGetGatewayDutyCycleMetricsResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *APIGetGatewayDutyCycleMetricsResponse) validateMaxLoadPercentage(formats strfmt.Registry) error {
	if swag.IsZero(m.MaxLoadPercentage) { // not required
		return nil
	}

	if m.MaxLoadPercentage != nil {
		if err := m.MaxLoadPercentage.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("maxLoadPercentage")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("maxLoadPercentage")
			}
			return err
		}
	}

	return nil
}

func (m *APIGetGatewayDutyCycleMetricsResponse) validateWindowPercentage(formats strfmt.Registry) error {
	if swag.IsZero(m.WindowPercentage) { // not required
		return nil
	}

	if m.WindowPercentage != nil {
		if err := m.WindowPercentage.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("windowPercentage")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("windowPercentage")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this api get gateway duty cycle metrics response based on the context it is used
func (m *APIGetGatewayDutyCycleMetricsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *APIGetGatewayDutyCycleMetricsResponse) contextValidateMaxLoadPercentage(ctx context.Context, formats strfmt.Registry) error {

	if m.MaxLoadPercentage != nil {

		if swag.IsZero(m.MaxLoadPercentage) { // not required
			return nil
		}

		if err := m.MaxLoadPercentage.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("maxLoadPercentage")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("maxLoadPercentage")
			}
			return err
		}
	}

	return nil
}

func (m *APIGetGatewayDutyCycleMetricsResponse) contextValidateWindowPercentage(ctx context.Context, formats strfmt.Registry) error {

	if m.WindowPercentage != nil {

		if swag.IsZero(m.WindowPercentage) { // not required
			return nil
		}

		if err := m.WindowPercentage.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("windowPercentage")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("windowPercentage")
			}
			return err
		}
	}

	return nil
}

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

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