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

// HashicorpCloudBoundary20211221MaintenanceWindow MaintenanceWindow is the time window in which upgrades will occur
//
// swagger:model hashicorp.cloud.boundary_20211221.MaintenanceWindow
type HashicorpCloudBoundary20211221MaintenanceWindow struct {

	// day_of_week is the one of 7 days in a week
	DayOfWeek *HashicorpCloudBoundary20211221MaintenanceWindowDayOfWeek `json:"day_of_week,omitempty"`

	// end is the last hour of the window in UTC (exclusive)
	End int32 `json:"end,omitempty"`

	// start is the start hour of the window in UTC
	Start int32 `json:"start,omitempty"`
}

// Validate validates this hashicorp cloud boundary 20211221 maintenance window
func (m *HashicorpCloudBoundary20211221MaintenanceWindow) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudBoundary20211221MaintenanceWindow) 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
}

// ContextValidate validate this hashicorp cloud boundary 20211221 maintenance window based on the context it is used
func (m *HashicorpCloudBoundary20211221MaintenanceWindow) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

	if m.DayOfWeek != nil {

		if swag.IsZero(m.DayOfWeek) { // not required
			return 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
}

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

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