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

// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed

package members_models

import (
	"context"
	"encoding/json"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag/jsonutils"
	"github.com/go-openapi/swag/typeutils"
	"github.com/go-openapi/validate"
)

// TenantMembershipUpdate tenant membership update
//
// swagger:model TenantMembershipUpdate
type TenantMembershipUpdate struct {

	// access level
	// Enum: ["owner","manager","member","read_only"]
	AccessLevel *string `json:"accessLevel,omitempty"`

	// Optimistic concurrency token from the latest representation.
	// Required: true
	// Format: date-time
	LastModifiedDate *strfmt.DateTime `json:"lastModifiedDate"`

	// status
	// Enum: ["active","suspended","revoked"]
	Status *string `json:"status,omitempty"`
}

// Validate validates this tenant membership update
func (m *TenantMembershipUpdate) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

var tenantMembershipUpdateTypeAccessLevelPropEnum []any

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["owner","manager","member","read_only"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		tenantMembershipUpdateTypeAccessLevelPropEnum = append(tenantMembershipUpdateTypeAccessLevelPropEnum, v)
	}
}

const (

	// TenantMembershipUpdateAccessLevelOwner captures enum value "owner"
	TenantMembershipUpdateAccessLevelOwner string = "owner"

	// TenantMembershipUpdateAccessLevelManager captures enum value "manager"
	TenantMembershipUpdateAccessLevelManager string = "manager"

	// TenantMembershipUpdateAccessLevelMember captures enum value "member"
	TenantMembershipUpdateAccessLevelMember string = "member"

	// TenantMembershipUpdateAccessLevelReadOnly captures enum value "read_only"
	TenantMembershipUpdateAccessLevelReadOnly string = "read_only"
)

// prop value enum
func (m *TenantMembershipUpdate) validateAccessLevelEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, tenantMembershipUpdateTypeAccessLevelPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *TenantMembershipUpdate) validateAccessLevel(formats strfmt.Registry) error {
	if typeutils.IsZero(m.AccessLevel) { // not required
		return nil
	}

	// value enum
	if err := m.validateAccessLevelEnum("accessLevel", "body", *m.AccessLevel); err != nil {
		return err
	}

	return nil
}

func (m *TenantMembershipUpdate) validateLastModifiedDate(formats strfmt.Registry) error {

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

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

	return nil
}

var tenantMembershipUpdateTypeStatusPropEnum []any

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["active","suspended","revoked"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		tenantMembershipUpdateTypeStatusPropEnum = append(tenantMembershipUpdateTypeStatusPropEnum, v)
	}
}

const (

	// TenantMembershipUpdateStatusActive captures enum value "active"
	TenantMembershipUpdateStatusActive string = "active"

	// TenantMembershipUpdateStatusSuspended captures enum value "suspended"
	TenantMembershipUpdateStatusSuspended string = "suspended"

	// TenantMembershipUpdateStatusRevoked captures enum value "revoked"
	TenantMembershipUpdateStatusRevoked string = "revoked"
)

// prop value enum
func (m *TenantMembershipUpdate) validateStatusEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, tenantMembershipUpdateTypeStatusPropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *TenantMembershipUpdate) validateStatus(formats strfmt.Registry) error {
	if typeutils.IsZero(m.Status) { // not required
		return nil
	}

	// value enum
	if err := m.validateStatusEnum("status", "body", *m.Status); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this tenant membership update based on context it is used
func (m *TenantMembershipUpdate) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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