/*
shottower
Copyright (C) 2022 RÃ©my Boulanouar

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/*
 * Shottower
 *
 * Shottower is the open source version of Shotstack which is a video, image and audio editing service that allows for the automated generation of videos, images and audio using JSON and a RESTful API.  You arrange and configure an edit and POST it to the API which will render your media and provide a file  location when complete.  For more details visit [shottower](https://github.com/DblK/shottower) or checkout our [getting started](https://shotstack.io/docs/guide/) documentation.  There are two main API's, one for editing and generating assets (Edit API) and one for managing hosted assets (Serve API).  The Edit API base URL is: <b>http://0.0.0.0:4000/{version}</b>  The Serve API base URL is: <b>http://0.0.0.0:4000/serve/{version}</b>
 *
 * API version: stage
 * Generated by: OpenAPI Generator (https://openapi-generator.tech)
 */

package openapi

// Edit - An edit defines the arrangement of a video on a timeline, an audio edit or an image design and the output format.
type Edit struct {
	Timeline Timeline `json:"timeline"`

	Output Output `json:"output"`

	// An array of key/value pairs that provides an easy way to create templates with placeholders. The placeholders can be used to find and replace keys with values. For example you can search for the placeholder `{{NAME}}` and replace it with the value `Jane`.
	Merge []MergeField `json:"merge,omitempty"`

	// An optional webhook callback URL used to receive status notifications when a render completes or fails. See [webhooks](https://shotstack.io/docs/guide/architecting-an-application/webhooks) for  more details.
	Callback string `json:"callback,omitempty"`

	// The disk type to use for storing footage and assets for each render. See [disk types](https://shotstack.io/docs/guide/architecting-an-application/disk-types) for more details. <ul>   <li>`local` - optimized for high speed rendering with up to 512MB storage</li>   <li>`mount` - optimized for larger file sizes and longer videos with 5GB for source footage and 512MB for output render</li> </ul>
	Disk string `json:"disk,omitempty"`
}

// AssertEditRequired checks if the required fields are not zero-ed
func AssertEditRequired(obj *Edit) error {
	elements := map[string]interface{}{
		"timeline": obj.Timeline,
		"output":   obj.Output,
	}
	for name, el := range elements {
		if isZero := IsZeroValue(el); isZero {
			return &RequiredError{Schema: "Edit", Field: name}
		}
	}

	if err := AssertTimelineRequired(&obj.Timeline); err != nil {
		return err
	}
	if err := AssertOutputRequired(&obj.Output); err != nil {
		return err
	}
	for i := range obj.Merge {
		if err := AssertMergeFieldRequired(&obj.Merge[i]); err != nil {
			return err
		}
	}
	return nil
}

// AssertRecurseEditRequired recursively checks if required fields are not zero-ed in a nested slice.
// Accepts only nested slice of Edit (e.g. [][]Edit), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseEditRequired(objSlice interface{}) error {
	return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
		aEdit, ok := obj.(Edit)
		if !ok {
			return ErrTypeAssertionError
		}
		return AssertEditRequired(&aEdit)
	})
}
