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

package ops

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

// TenantGetImpersonateResp tenant get impersonate resp
//
// swagger:model tenant.GetImpersonateResp
type TenantGetImpersonateResp struct {

	// errcode
	Errcode APIErrCode `json:"errcode,omitempty"`

	// errmsg
	Errmsg string `json:"errmsg,omitempty"`

	// the operation instance id
	InstanceID int64 `json:"instance_id,omitempty"`

	// impersonating tenant id for the user
	// Example: 0
	TenantID string `json:"tenant_id,omitempty"`

	// trace id
	TraceID string `json:"trace_id,omitempty"`

	// user
	User string `json:"user,omitempty"`
}

// Validate validates this tenant get impersonate resp
func (m *TenantGetImpersonateResp) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *TenantGetImpersonateResp) validateErrcode(formats strfmt.Registry) error {
	if swag.IsZero(m.Errcode) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this tenant get impersonate resp based on the context it is used
func (m *TenantGetImpersonateResp) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *TenantGetImpersonateResp) contextValidateErrcode(ctx context.Context, formats strfmt.Registry) error {

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

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

	return nil
}

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

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