// 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 (
	"strconv"

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

// CentralDatadogIntegrationControlReq central datadog integration control req
//
// swagger:model centralDatadogIntegrationControlReq
type CentralDatadogIntegrationControlReq struct {

	// action
	Action CentralDatadogControlAction `json:"action,omitempty"`

	// datadog API key
	DatadogAPIKey string `json:"datadogAPIKey,omitempty"`

	// datadog site
	DatadogSite CentralDatadogSite `json:"datadogSite,omitempty"`

	// org id
	OrgID string `json:"org_id,omitempty"`

	// payloads
	Payloads []CentralDatadogControlPayload `json:"payloads"`

	// project id
	ProjectID string `json:"project_id,omitempty"`
}

// Validate validates this central datadog integration control req
func (m *CentralDatadogIntegrationControlReq) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *CentralDatadogIntegrationControlReq) validateAction(formats strfmt.Registry) error {

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

	if err := m.Action.Validate(formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("action")
		}
		return err
	}

	return nil
}

func (m *CentralDatadogIntegrationControlReq) validateDatadogSite(formats strfmt.Registry) error {

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

	if err := m.DatadogSite.Validate(formats); err != nil {
		if ve, ok := err.(*errors.Validation); ok {
			return ve.ValidateName("datadogSite")
		}
		return err
	}

	return nil
}

func (m *CentralDatadogIntegrationControlReq) validatePayloads(formats strfmt.Registry) error {

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

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

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

	}

	return nil
}

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

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