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

// HashicorpCloudBoundary20211221MaintenanceWindowGetResponse MaintenanceWindowGetResponse is a response for fetching the maintenance set for this cluster.
//
// swagger:model hashicorp.cloud.boundary_20211221.MaintenanceWindowGetResponse
type HashicorpCloudBoundary20211221MaintenanceWindowGetResponse struct {

	// maintenance_window contains time frame that user set we want to update the cluster.
	MaintenanceWindow *HashicorpCloudBoundary20211221MaintenanceWindow `json:"maintenance_window,omitempty"`

	// upgrade_type contains upgrade methods set for this clusters.
	UpgradeType *HashicorpCloudBoundary20211221UpgradeType `json:"upgrade_type,omitempty"`
}

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

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

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

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

func (m *HashicorpCloudBoundary20211221MaintenanceWindowGetResponse) validateMaintenanceWindow(formats strfmt.Registry) error {
	if swag.IsZero(m.MaintenanceWindow) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudBoundary20211221MaintenanceWindowGetResponse) validateUpgradeType(formats strfmt.Registry) error {
	if swag.IsZero(m.UpgradeType) { // not required
		return nil
	}

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

	return nil
}

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

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

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

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

func (m *HashicorpCloudBoundary20211221MaintenanceWindowGetResponse) contextValidateMaintenanceWindow(ctx context.Context, formats strfmt.Registry) error {

	if m.MaintenanceWindow != nil {

		if swag.IsZero(m.MaintenanceWindow) { // not required
			return nil
		}

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

	return nil
}

func (m *HashicorpCloudBoundary20211221MaintenanceWindowGetResponse) contextValidateUpgradeType(ctx context.Context, formats strfmt.Registry) error {

	if m.UpgradeType != nil {

		if swag.IsZero(m.UpgradeType) { // not required
			return nil
		}

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

	return nil
}

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

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