// 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"
	"encoding/json"

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

// IqConnectionXo iq connection xo
//
// swagger:model IqConnectionXo
type IqConnectionXo struct {

	// Authentication method
	// Required: true
	// Enum: [USER PKI]
	AuthenticationType *string `json:"authenticationType"`

	// Whether to use IQ Server
	Enabled bool `json:"enabled,omitempty"`

	// Credentials for the IQ Server User
	Password string `json:"password,omitempty"`

	// Additional properties to configure for IQ Server
	Properties string `json:"properties,omitempty"`

	// Show IQ Server link in Browse menu when server is enabled
	ShowLink bool `json:"showLink,omitempty"`

	// Seconds to wait for activity before stopping and retrying the connection. Leave blank to use the globally defined HTTP timeout.
	// Maximum: 3600
	// Minimum: 1
	TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`

	// The address of your IQ Server
	URL string `json:"url,omitempty"`

	// Use certificates stored in the Nexus Repository Manager truststore to connect to IQ Server
	UseTrustStoreForURL bool `json:"useTrustStoreForUrl,omitempty"`

	// User with access to IQ Server
	Username string `json:"username,omitempty"`
}

// Validate validates this iq connection xo
func (m *IqConnectionXo) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

var iqConnectionXoTypeAuthenticationTypePropEnum []interface{}

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

const (

	// IqConnectionXoAuthenticationTypeUSER captures enum value "USER"
	IqConnectionXoAuthenticationTypeUSER string = "USER"

	// IqConnectionXoAuthenticationTypePKI captures enum value "PKI"
	IqConnectionXoAuthenticationTypePKI string = "PKI"
)

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

func (m *IqConnectionXo) validateAuthenticationType(formats strfmt.Registry) error {

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

	// value enum
	if err := m.validateAuthenticationTypeEnum("authenticationType", "body", *m.AuthenticationType); err != nil {
		return err
	}

	return nil
}

func (m *IqConnectionXo) validateTimeoutSeconds(formats strfmt.Registry) error {
	if swag.IsZero(m.TimeoutSeconds) { // not required
		return nil
	}

	if err := validate.MinimumInt("timeoutSeconds", "body", int64(m.TimeoutSeconds), 1, false); err != nil {
		return err
	}

	if err := validate.MaximumInt("timeoutSeconds", "body", int64(m.TimeoutSeconds), 3600, false); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this iq connection xo based on context it is used
func (m *IqConnectionXo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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