/*
 * VPN Gateways
 *
 * POC Docs for VPN gateway as service
 *
 * API version: 0.0.1
 * Contact: support@cloud.ionos.com
 */

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

package vpn

import (
	"encoding/json"
)

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

// Connection Details about the network connection for your VPN Gateway.
type Connection struct {
	// The datacenter to connect your VPN Gateway to.
	DatacenterId string `json:"datacenterId"`
	// The numeric LAN ID to connect your VPN Gateway to.
	LanId string `json:"lanId"`
	// Describes a range of IP V4 addresses in CIDR notation.
	Ipv4CIDR string `json:"ipv4CIDR"`
	// Describes a range of IP V6 addresses in CIDR notation.
	Ipv6CIDR *string `json:"ipv6CIDR,omitempty"`
}

// NewConnection instantiates a new Connection 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 NewConnection(datacenterId string, lanId string, ipv4CIDR string) *Connection {
	this := Connection{}

	this.DatacenterId = datacenterId
	this.LanId = lanId
	this.Ipv4CIDR = ipv4CIDR

	return &this
}

// NewConnectionWithDefaults instantiates a new Connection 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 NewConnectionWithDefaults() *Connection {
	this := Connection{}
	return &this
}

// GetDatacenterId returns the DatacenterId field value
func (o *Connection) GetDatacenterId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.DatacenterId
}

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

// SetDatacenterId sets field value
func (o *Connection) SetDatacenterId(v string) {
	o.DatacenterId = v
}

// GetLanId returns the LanId field value
func (o *Connection) GetLanId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.LanId
}

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

// SetLanId sets field value
func (o *Connection) SetLanId(v string) {
	o.LanId = v
}

// GetIpv4CIDR returns the Ipv4CIDR field value
func (o *Connection) GetIpv4CIDR() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Ipv4CIDR
}

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

// SetIpv4CIDR sets field value
func (o *Connection) SetIpv4CIDR(v string) {
	o.Ipv4CIDR = v
}

// GetIpv6CIDR returns the Ipv6CIDR field value if set, zero value otherwise.
func (o *Connection) GetIpv6CIDR() string {
	if o == nil || IsNil(o.Ipv6CIDR) {
		var ret string
		return ret
	}
	return *o.Ipv6CIDR
}

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

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

	return false
}

// SetIpv6CIDR gets a reference to the given string and assigns it to the Ipv6CIDR field.
func (o *Connection) SetIpv6CIDR(v string) {
	o.Ipv6CIDR = &v
}

func (o Connection) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["datacenterId"] = o.DatacenterId
	toSerialize["lanId"] = o.LanId
	toSerialize["ipv4CIDR"] = o.Ipv4CIDR
	if !IsNil(o.Ipv6CIDR) {
		toSerialize["ipv6CIDR"] = o.Ipv6CIDR
	}
	return toSerialize, nil
}

type NullableConnection struct {
	value *Connection
	isSet bool
}

func (v NullableConnection) Get() *Connection {
	return v.value
}

func (v *NullableConnection) Set(val *Connection) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableConnection(val *Connection) *NullableConnection {
	return &NullableConnection{value: val, isSet: true}
}

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

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