// Code generated by go-swagger; DO NOT EDIT.

package model

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

// OpenapiLocalFilePayload LocalFilePayload
//
// LocalFilePayload represents the payload to upload a local file content for importing.
//
// swagger:model openapiLocalFilePayload
type OpenapiLocalFilePayload struct {

	// The base64-encoded content of the local file to be imported. The maximum size of the file should be 52428800 (50 MiB).
	//
	// **Note:** Before providing the content, process the file by taking the following steps:
	// 1. Compress the file using the **gzip** algorithm.
	// 2. Encode the compressed data using the **base64** algorithm.
	// Example: H4sIABbP9mMAAyXHOwoAIQwFwN5jvPoh5neggI2w9Z7fSJqBOZt/fvLQIURmLgFlrqE9BbVmPQOt5j0HvRa9AKN2AUwss6dTAAAA
	// Required: true
	// Max Length: 52428800
	// Format: byte
	Content *strfmt.Base64 `json:"content"`

	// The total size of the **ACTUAL** local file contents, not the total size of the `content` field.
	//
	// The unit is byte, and the maximum value is `52428800` (50 MiB). If the given value of `total_size_bytes` exceeds the maximum value, an error will be reported.
	// Example: 83
	// Required: true
	TotalSizeBytes *string `json:"total_size_bytes"`
}

// Validate validates this openapi local file payload
func (m *OpenapiLocalFilePayload) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *OpenapiLocalFilePayload) validateContent(formats strfmt.Registry) error {

	if err := validate.Required("content", "body", m.Content); err != nil {
		return err
	}

	if err := validate.MaxLength("content", "body", m.Content.String(), 52428800); err != nil {
		return err
	}

	return nil
}

func (m *OpenapiLocalFilePayload) validateTotalSizeBytes(formats strfmt.Registry) error {

	if err := validate.Required("total_size_bytes", "body", m.TotalSizeBytes); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this openapi local file payload based on context it is used
func (m *OpenapiLocalFilePayload) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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