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

// HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindow hashicorp cloud vault 20201125 major version upgrade config maintenance window
//
// swagger:model hashicorp.cloud.vault_20201125.MajorVersionUpgradeConfig.MaintenanceWindow
type HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindow struct {

	// day of week
	DayOfWeek *HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindowDayOfWeek `json:"day_of_week,omitempty"`

	// time window utc
	TimeWindowUtc *HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindowTimeWindowUTC `json:"time_window_utc,omitempty"`
}

// Validate validates this hashicorp cloud vault 20201125 major version upgrade config maintenance window
func (m *HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindow) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindow) validateDayOfWeek(formats strfmt.Registry) error {
	if swag.IsZero(m.DayOfWeek) { // not required
		return nil
	}

	if m.DayOfWeek != nil {
		if err := m.DayOfWeek.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("day_of_week")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("day_of_week")
			}
			return err
		}
	}

	return nil
}

func (m *HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindow) validateTimeWindowUtc(formats strfmt.Registry) error {
	if swag.IsZero(m.TimeWindowUtc) { // not required
		return nil
	}

	if m.TimeWindowUtc != nil {
		if err := m.TimeWindowUtc.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("time_window_utc")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("time_window_utc")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this hashicorp cloud vault 20201125 major version upgrade config maintenance window based on the context it is used
func (m *HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindow) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindow) contextValidateDayOfWeek(ctx context.Context, formats strfmt.Registry) error {

	if m.DayOfWeek != nil {
		if err := m.DayOfWeek.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("day_of_week")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("day_of_week")
			}
			return err
		}
	}

	return nil
}

func (m *HashicorpCloudVault20201125MajorVersionUpgradeConfigMaintenanceWindow) contextValidateTimeWindowUtc(ctx context.Context, formats strfmt.Registry) error {

	if m.TimeWindowUtc != nil {
		if err := m.TimeWindowUtc.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("time_window_utc")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("time_window_utc")
			}
			return err
		}
	}

	return nil
}

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

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