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

// APIPerfMetrics Api perf metrics
//
// swagger:model ApiPerfMetrics
type APIPerfMetrics struct {

	// api name
	// Example: 10
	// Read Only: true
	API string `json:"api,omitempty"`

	// Max time taken to process a request
	// Example: 10
	// Read Only: true
	MaxNanoTime int64 `json:"maxNanoTime,omitempty"`

	// api's summary defined in swagger.json
	// Example: get alert list
	// Read Only: true
	Summary string `json:"summary,omitempty"`

	// api tags
	// Example: Devices, Device Groups
	// Read Only: true
	Tags []string `json:"tags,omitempty"`

	// total time taken to process requests
	// Example: 10
	// Read Only: true
	TotNanoTime int64 `json:"totNanoTime,omitempty"`

	// total processed requests
	// Example: 10
	// Read Only: true
	TotalProcessedRequests int64 `json:"totalProcessedRequests,omitempty"`

	// total requests
	// Example: 10
	// Read Only: true
	TotalRequests int64 `json:"totalRequests,omitempty"`

	// total waiting requests
	// Example: 10
	// Read Only: true
	TotalWaitingRequests int64 `json:"totalWaitingRequests,omitempty"`
}

// Validate validates this Api perf metrics
func (m *APIPerfMetrics) Validate(formats strfmt.Registry) error {
	return nil
}

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

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

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

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

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

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

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

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

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

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

func (m *APIPerfMetrics) contextValidateAPI(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "api", "body", string(m.API)); err != nil {
		return err
	}

	return nil
}

func (m *APIPerfMetrics) contextValidateMaxNanoTime(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "maxNanoTime", "body", int64(m.MaxNanoTime)); err != nil {
		return err
	}

	return nil
}

func (m *APIPerfMetrics) contextValidateSummary(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "summary", "body", string(m.Summary)); err != nil {
		return err
	}

	return nil
}

func (m *APIPerfMetrics) contextValidateTags(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "tags", "body", []string(m.Tags)); err != nil {
		return err
	}

	return nil
}

func (m *APIPerfMetrics) contextValidateTotNanoTime(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "totNanoTime", "body", int64(m.TotNanoTime)); err != nil {
		return err
	}

	return nil
}

func (m *APIPerfMetrics) contextValidateTotalProcessedRequests(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "totalProcessedRequests", "body", int64(m.TotalProcessedRequests)); err != nil {
		return err
	}

	return nil
}

func (m *APIPerfMetrics) contextValidateTotalRequests(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "totalRequests", "body", int64(m.TotalRequests)); err != nil {
		return err
	}

	return nil
}

func (m *APIPerfMetrics) contextValidateTotalWaitingRequests(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "totalWaitingRequests", "body", int64(m.TotalWaitingRequests)); err != nil {
		return err
	}

	return nil
}

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

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