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

// APIAzureServiceBusIntegration api azure service bus integration
//
// swagger:model apiAzureServiceBusIntegration
type APIAzureServiceBusIntegration struct {

	// Application ID (UUID).
	ApplicationID string `json:"applicationId,omitempty"`

	// Connection string.
	ConnectionString string `json:"connectionString,omitempty"`

	// Encoding.
	Encoding *APIEncoding `json:"encoding,omitempty"`

	// Publish name.
	// This is the name of the topic or queue.
	PublishName string `json:"publishName,omitempty"`
}

// Validate validates this api azure service bus integration
func (m *APIAzureServiceBusIntegration) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *APIAzureServiceBusIntegration) validateEncoding(formats strfmt.Registry) error {
	if swag.IsZero(m.Encoding) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this api azure service bus integration based on the context it is used
func (m *APIAzureServiceBusIntegration) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *APIAzureServiceBusIntegration) contextValidateEncoding(ctx context.Context, formats strfmt.Registry) error {

	if m.Encoding != nil {

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

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

	return nil
}

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

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