// 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"
	"github.com/go-openapi/validate"
)

// DeviceDataSourceInstanceGroup device data source instance group
//
// swagger:model DeviceDataSourceInstanceGroup
type DeviceDataSourceInstanceGroup struct {

	// create on
	// Read Only: true
	CreateOn int64 `json:"createOn,omitempty"`

	// The description of the datasource instance group
	// Example: Test the availability of HQ
	Description string `json:"description,omitempty"`

	// device data source Id
	// Read Only: true
	DeviceDataSourceID int32 `json:"deviceDataSourceId,omitempty"`

	// device display name
	// Read Only: true
	DeviceDisplayName string `json:"deviceDisplayName,omitempty"`

	// device Id
	// Read Only: true
	DeviceID int32 `json:"deviceId,omitempty"`

	// id
	// Read Only: true
	ID int32 `json:"id,omitempty"`

	// Name of the datasource instance group
	// Example: Ping Checks at HQ
	// Required: true
	Name *string `json:"name"`
}

// Validate validates this device data source instance group
func (m *DeviceDataSourceInstanceGroup) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *DeviceDataSourceInstanceGroup) validateName(formats strfmt.Registry) error {

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

	return nil
}

// ContextValidate validate this device data source instance group based on the context it is used
func (m *DeviceDataSourceInstanceGroup) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

func (m *DeviceDataSourceInstanceGroup) contextValidateCreateOn(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "createOn", "body", int64(m.CreateOn)); err != nil {
		return err
	}

	return nil
}

func (m *DeviceDataSourceInstanceGroup) contextValidateDeviceDataSourceID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "deviceDataSourceId", "body", int32(m.DeviceDataSourceID)); err != nil {
		return err
	}

	return nil
}

func (m *DeviceDataSourceInstanceGroup) contextValidateDeviceDisplayName(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "deviceDisplayName", "body", string(m.DeviceDisplayName)); err != nil {
		return err
	}

	return nil
}

func (m *DeviceDataSourceInstanceGroup) contextValidateDeviceID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "deviceId", "body", int32(m.DeviceID)); err != nil {
		return err
	}

	return nil
}

func (m *DeviceDataSourceInstanceGroup) contextValidateID(ctx context.Context, formats strfmt.Registry) error {

	if err := validate.ReadOnly(ctx, "id", "body", int32(m.ID)); err != nil {
		return err
	}

	return nil
}

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

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