/*
 * In-Memory DB API
 *
 * API description for the IONOS In-Memory DB
 *
 * API version: 1.0.0
 * Contact: support@cloud.ionos.com
 */

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

package ionoscloud

import (
	"encoding/json"
)

// Connection Details about the network connection for your instance.
type Connection struct {
	// The datacenter to connect your instance to.
	DatacenterId *string `json:"datacenterId"`
	// The numeric LAN ID to connect your instance to.
	LanId *string `json:"lanId"`
	// The IP and subnet for your instance. Note the following unavailable IP ranges: 10.210.0.0/16 10.212.0.0/14
	Cidr *string `json:"cidr"`
}

// 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, cidr string) *Connection {
	this := Connection{}

	this.DatacenterId = &datacenterId
	this.LanId = &lanId
	this.Cidr = &cidr

	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
// If the value is explicit nil, the zero value for string will be returned
func (o *Connection) GetDatacenterId() *string {
	if o == nil {
		return nil
	}

	return o.DatacenterId

}

// GetDatacenterIdOk returns a tuple with the DatacenterId field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
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

}

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

	return false
}

// GetLanId returns the LanId field value
// If the value is explicit nil, the zero value for string will be returned
func (o *Connection) GetLanId() *string {
	if o == nil {
		return nil
	}

	return o.LanId

}

// GetLanIdOk returns a tuple with the LanId field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
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

}

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

	return false
}

// GetCidr returns the Cidr field value
// If the value is explicit nil, the zero value for string will be returned
func (o *Connection) GetCidr() *string {
	if o == nil {
		return nil
	}

	return o.Cidr

}

// GetCidrOk returns a tuple with the Cidr field value
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *Connection) GetCidrOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.Cidr, true
}

// SetCidr sets field value
func (o *Connection) SetCidr(v string) {

	o.Cidr = &v

}

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

	return false
}

func (o Connection) MarshalJSON() ([]byte, error) {
	toSerialize := map[string]interface{}{}
	if o.DatacenterId != nil {
		toSerialize["datacenterId"] = o.DatacenterId
	}

	if o.LanId != nil {
		toSerialize["lanId"] = o.LanId
	}

	if o.Cidr != nil {
		toSerialize["cidr"] = o.Cidr
	}

	return json.Marshal(toSerialize)
}

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)
}
