// Code generated by go-swagger; DO NOT EDIT.

package model

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

// CentralCreateAPIKeyReq central create Api key req
//
// swagger:model centralCreateApiKeyReq
type CentralCreateAPIKeyReq struct {

	// biz attr
	BizAttr string `json:"biz_attr,omitempty"`

	// description
	// Required: true
	Description *string `json:"description"`

	// expired at
	// Format: date-time
	ExpiredAt strfmt.DateTime `json:"expired_at,omitempty"`

	// resource ids
	ResourceIds []string `json:"resource_ids"`

	// role
	Role string `json:"role,omitempty"`

	// scope type
	// Required: true
	ScopeType *string `json:"scope_type"`

	// source
	// Required: true
	Source *string `json:"source"`
}

// Validate validates this central create Api key req
func (m *CentralCreateAPIKeyReq) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

func (m *CentralCreateAPIKeyReq) validateDescription(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralCreateAPIKeyReq) validateExpiredAt(formats strfmt.Registry) error {
	if swag.IsZero(m.ExpiredAt) { // not required
		return nil
	}

	if err := validate.FormatOf("expired_at", "body", "date-time", m.ExpiredAt.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *CentralCreateAPIKeyReq) validateScopeType(formats strfmt.Registry) error {

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

	return nil
}

func (m *CentralCreateAPIKeyReq) validateSource(formats strfmt.Registry) error {

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

	return nil
}

// ContextValidate validates this central create Api key req based on context it is used
func (m *CentralCreateAPIKeyReq) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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