// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

/*
 * External DNS Webhook Server
 *
 * Implements the external DNS webhook endpoints.
 *
 * API version: v0.15.0
 */

package externaldnsapi

// Changes - This is the list of changes send by `external-dns` that need to be applied.  There are four lists of endpoints.  The `create` and `delete` lists are lists of records to create and delete respectively.  The `updateOld` and `updateNew` lists are paired. For each entry there's the old version of the record and a new version of the record.
type Changes struct {

	// This is a list of DNS records.
	Create []Endpoint `json:"create,omitempty"`

	// This is a list of DNS records.
	UpdateOld []Endpoint `json:"updateOld,omitempty"`

	// This is a list of DNS records.
	UpdateNew []Endpoint `json:"updateNew,omitempty"`

	// This is a list of DNS records.
	Delete []Endpoint `json:"delete,omitempty"`
}

// AssertChangesRequired checks if the required fields are not zero-ed
func AssertChangesRequired(obj Changes) error {
	for _, el := range obj.Create {
		if err := AssertEndpointRequired(el); err != nil {
			return err
		}
	}
	for _, el := range obj.UpdateOld {
		if err := AssertEndpointRequired(el); err != nil {
			return err
		}
	}
	for _, el := range obj.UpdateNew {
		if err := AssertEndpointRequired(el); err != nil {
			return err
		}
	}
	for _, el := range obj.Delete {
		if err := AssertEndpointRequired(el); err != nil {
			return err
		}
	}
	return nil
}

// AssertChangesConstraints checks if the values respects the defined constraints
func AssertChangesConstraints(obj Changes) error {
	for _, el := range obj.Create {
		if err := AssertEndpointConstraints(el); err != nil {
			return err
		}
	}
	for _, el := range obj.UpdateOld {
		if err := AssertEndpointConstraints(el); err != nil {
			return err
		}
	}
	for _, el := range obj.UpdateNew {
		if err := AssertEndpointConstraints(el); err != nil {
			return err
		}
	}
	for _, el := range obj.Delete {
		if err := AssertEndpointConstraints(el); err != nil {
			return err
		}
	}
	return nil
}
