/*
DM OpenAPI DOC

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

API version: 6.0.0
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package dm

import (
	"bytes"
	"encoding/json"
	"fmt"
)

// checks if the Security type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &Security{}

// Security data source ssl configuration, the field will be hidden when getting the data source configuration from the interface
type Security struct {
	// Common Name of SSL certificates
	CertAllowedCn []string `json:"cert_allowed_cn,omitempty"`
	// certificate file content
	SslCaContent string `json:"ssl_ca_content"`
	// File content of PEM format/X509 format certificates
	SslCertContent string `json:"ssl_cert_content"`
	// Content of the private key file in X509 format
	SslKeyContent string `json:"ssl_key_content"`
}

type _Security Security

// NewSecurity instantiates a new Security object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewSecurity(sslCaContent string, sslCertContent string, sslKeyContent string) *Security {
	this := Security{}
	this.SslCaContent = sslCaContent
	this.SslCertContent = sslCertContent
	this.SslKeyContent = sslKeyContent
	return &this
}

// NewSecurityWithDefaults instantiates a new Security object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewSecurityWithDefaults() *Security {
	this := Security{}
	return &this
}

// GetCertAllowedCn returns the CertAllowedCn field value if set, zero value otherwise.
func (o *Security) GetCertAllowedCn() []string {
	if o == nil || IsNil(o.CertAllowedCn) {
		var ret []string
		return ret
	}
	return o.CertAllowedCn
}

// GetCertAllowedCnOk returns a tuple with the CertAllowedCn field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Security) GetCertAllowedCnOk() ([]string, bool) {
	if o == nil || IsNil(o.CertAllowedCn) {
		return nil, false
	}
	return o.CertAllowedCn, true
}

// HasCertAllowedCn returns a boolean if a field has been set.
func (o *Security) HasCertAllowedCn() bool {
	if o != nil && !IsNil(o.CertAllowedCn) {
		return true
	}

	return false
}

// SetCertAllowedCn gets a reference to the given []string and assigns it to the CertAllowedCn field.
func (o *Security) SetCertAllowedCn(v []string) {
	o.CertAllowedCn = v
}

// GetSslCaContent returns the SslCaContent field value
func (o *Security) GetSslCaContent() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SslCaContent
}

// GetSslCaContentOk returns a tuple with the SslCaContent field value
// and a boolean to check if the value has been set.
func (o *Security) GetSslCaContentOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.SslCaContent, true
}

// SetSslCaContent sets field value
func (o *Security) SetSslCaContent(v string) {
	o.SslCaContent = v
}

// GetSslCertContent returns the SslCertContent field value
func (o *Security) GetSslCertContent() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SslCertContent
}

// GetSslCertContentOk returns a tuple with the SslCertContent field value
// and a boolean to check if the value has been set.
func (o *Security) GetSslCertContentOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.SslCertContent, true
}

// SetSslCertContent sets field value
func (o *Security) SetSslCertContent(v string) {
	o.SslCertContent = v
}

// GetSslKeyContent returns the SslKeyContent field value
func (o *Security) GetSslKeyContent() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.SslKeyContent
}

// GetSslKeyContentOk returns a tuple with the SslKeyContent field value
// and a boolean to check if the value has been set.
func (o *Security) GetSslKeyContentOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.SslKeyContent, true
}

// SetSslKeyContent sets field value
func (o *Security) SetSslKeyContent(v string) {
	o.SslKeyContent = v
}

func (o Security) MarshalJSON() ([]byte, error) {
	toSerialize, err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o Security) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.CertAllowedCn) {
		toSerialize["cert_allowed_cn"] = o.CertAllowedCn
	}
	toSerialize["ssl_ca_content"] = o.SslCaContent
	toSerialize["ssl_cert_content"] = o.SslCertContent
	toSerialize["ssl_key_content"] = o.SslKeyContent
	return toSerialize, nil
}

func (o *Security) UnmarshalJSON(data []byte) (err error) {
	// This validates that all required properties are included in the JSON object
	// by unmarshalling the object into a generic map with string keys and checking
	// that every required field exists as a key in the generic map.
	requiredProperties := []string{
		"ssl_ca_content",
		"ssl_cert_content",
		"ssl_key_content",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(data, &allProperties)

	if err != nil {
		return err
	}

	for _, requiredProperty := range requiredProperties {
		if _, exists := allProperties[requiredProperty]; !exists {
			return fmt.Errorf("no value given for required property %v", requiredProperty)
		}
	}

	varSecurity := _Security{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varSecurity)

	if err != nil {
		return err
	}

	*o = Security(varSecurity)

	return err
}

type NullableSecurity struct {
	value *Security
	isSet bool
}

func (v NullableSecurity) Get() *Security {
	return v.value
}

func (v *NullableSecurity) Set(val *Security) {
	v.value = val
	v.isSet = true
}

func (v NullableSecurity) IsSet() bool {
	return v.isSet
}

func (v *NullableSecurity) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableSecurity(val *Security) *NullableSecurity {
	return &NullableSecurity{value: val, isSet: true}
}

func (v NullableSecurity) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableSecurity) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}
