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

// V1alpha1Task Identity Service Policy Task
//
// swagger:model v1alpha1Task
type V1alpha1Task struct {

	// An application ID for the Task.
	// Read Only: true
	AppID string `json:"appId,omitempty"`

	// A human-readable description for the Task.
	// Read Only: true
	Description string `json:"description,omitempty"`

	// A unique identifier for the Task.
	// Read Only: true
	ID string `json:"id,omitempty"`

	// A human-readable name for the Task.
	// Read Only: true
	Name string `json:"name,omitempty"`

	// A tool name for the Task.
	// Read Only: true
	ToolName string `json:"toolName,omitempty"`
}

// Validate validates this v1alpha1 task
func (m *V1alpha1Task) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validate this v1alpha1 task based on the context it is used
func (m *V1alpha1Task) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

func (m *V1alpha1Task) contextValidateAppID(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *V1alpha1Task) contextValidateDescription(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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

	return nil
}

func (m *V1alpha1Task) contextValidateName(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

func (m *V1alpha1Task) contextValidateToolName(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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