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

// APIAwsSnsIntegration api aws sns integration
//
// swagger:model apiAwsSnsIntegration
type APIAwsSnsIntegration struct {

	// AWS Access Key ID.
	AccessKeyID string `json:"accessKeyId,omitempty"`

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

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

	// AWS region.
	Region string `json:"region,omitempty"`

	// AWS Secret Access Key.
	SecretAccessKey string `json:"secretAccessKey,omitempty"`

	// Topic ARN.
	TopicArn string `json:"topicArn,omitempty"`
}

// Validate validates this api aws sns integration
func (m *APIAwsSnsIntegration) 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 *APIAwsSnsIntegration) 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 aws sns integration based on the context it is used
func (m *APIAwsSnsIntegration) 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 *APIAwsSnsIntegration) 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 *APIAwsSnsIntegration) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

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