/*
 * VM Auto Scaling API
 *
 * The VM Auto Scaling Service enables IONOS clients to horizontally scale the number of VM replicas based on configured rules. You can use VM Auto Scaling to ensure that you have a sufficient number of replicas to handle your application loads at all times.  For this purpose, create a VM Auto Scaling Group that contains the server replicas. The VM Auto Scaling Service ensures that the number of replicas in the group is always within the defined limits.   When scaling policies are set, VM Auto Scaling creates or deletes replicas according to the requirements of your applications. For each policy, specified 'scale-in' and 'scale-out' actions are performed when the corresponding thresholds are reached.
 *
 * API version: 1-SDK.1
 * Contact: support@cloud.ionos.com
 */

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

package ionoscloud

import (
	"encoding/json"
)

// NicFirewallRule struct for NicFirewallRule
type NicFirewallRule struct {
	// The name of the firewall rule.
	Name *string `json:"name,omitempty"`
	// The protocol for the rule. The property cannot be modified after its creation (not allowed in update requests).
	Protocol *string `json:"protocol"`
	// Only traffic originating from the respective MAC address is permitted. Valid format: 'aa:bb:cc:dd:ee:ff'. The value 'null' allows traffic from any MAC address.
	SourceMac *string `json:"sourceMac,omitempty"`
	// Only traffic originating from the respective IPv4 address is permitted. The value 'null' allows traffic from any IP address.
	SourceIp *string `json:"sourceIp,omitempty"`
	// If the target NIC has multiple IP addresses, only the traffic directed to the respective IP address of the NIC is allowed. The value 'null' allows traffic to any target IP address.
	TargetIp *string `json:"targetIp,omitempty"`
	// Sets the allowed code (from 0 to 254) when ICMP protocol is selected. The value 'null'' allows all codes.
	IcmpCode *int32 `json:"icmpCode,omitempty"`
	// Sets the allowed type (from 0 to 254) if the protocol ICMP is selected. The value 'null' allows all types.
	IcmpType *int32 `json:"icmpType,omitempty"`
	// Sets the initial range of the allowed port (from 1 to 65535) if the protocol TCP or UDP is selected. The value 'null' for 'portRangeStart' and 'portRangeEnd' allows all ports.
	PortRangeStart *int32 `json:"portRangeStart,omitempty"`
	// Sets the end range of the allowed port (from 1 to 65535) if the protocol TCP or UDP is selected. The value 'null' for 'portRangeStart' and 'portRangeEnd' allows all ports.
	PortRangeEnd *int32 `json:"portRangeEnd,omitempty"`
	// The firewall rule type. If not specified, the default value 'INGRESS' is used.
	Type *string `json:"type,omitempty"`
}

// NewNicFirewallRule instantiates a new NicFirewallRule 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 NewNicFirewallRule(protocol string) *NicFirewallRule {
	this := NicFirewallRule{}

	this.Protocol = &protocol

	return &this
}

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

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

	return o.Name

}

// GetNameOk returns a tuple with the Name 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 *NicFirewallRule) GetNameOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.Name, true
}

// SetName sets field value
func (o *NicFirewallRule) SetName(v string) {

	o.Name = &v

}

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

	return false
}

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

	return o.Protocol

}

// GetProtocolOk returns a tuple with the Protocol 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 *NicFirewallRule) GetProtocolOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.Protocol, true
}

// SetProtocol sets field value
func (o *NicFirewallRule) SetProtocol(v string) {

	o.Protocol = &v

}

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

	return false
}

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

	return o.SourceMac

}

// GetSourceMacOk returns a tuple with the SourceMac 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 *NicFirewallRule) GetSourceMacOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.SourceMac, true
}

// SetSourceMac sets field value
func (o *NicFirewallRule) SetSourceMac(v string) {

	o.SourceMac = &v

}

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

	return false
}

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

	return o.SourceIp

}

// GetSourceIpOk returns a tuple with the SourceIp 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 *NicFirewallRule) GetSourceIpOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.SourceIp, true
}

// SetSourceIp sets field value
func (o *NicFirewallRule) SetSourceIp(v string) {

	o.SourceIp = &v

}

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

	return false
}

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

	return o.TargetIp

}

// GetTargetIpOk returns a tuple with the TargetIp 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 *NicFirewallRule) GetTargetIpOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.TargetIp, true
}

// SetTargetIp sets field value
func (o *NicFirewallRule) SetTargetIp(v string) {

	o.TargetIp = &v

}

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

	return false
}

// GetIcmpCode returns the IcmpCode field value
// If the value is explicit nil, the zero value for int32 will be returned
func (o *NicFirewallRule) GetIcmpCode() *int32 {
	if o == nil {
		return nil
	}

	return o.IcmpCode

}

// GetIcmpCodeOk returns a tuple with the IcmpCode 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 *NicFirewallRule) GetIcmpCodeOk() (*int32, bool) {
	if o == nil {
		return nil, false
	}

	return o.IcmpCode, true
}

// SetIcmpCode sets field value
func (o *NicFirewallRule) SetIcmpCode(v int32) {

	o.IcmpCode = &v

}

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

	return false
}

// GetIcmpType returns the IcmpType field value
// If the value is explicit nil, the zero value for int32 will be returned
func (o *NicFirewallRule) GetIcmpType() *int32 {
	if o == nil {
		return nil
	}

	return o.IcmpType

}

// GetIcmpTypeOk returns a tuple with the IcmpType 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 *NicFirewallRule) GetIcmpTypeOk() (*int32, bool) {
	if o == nil {
		return nil, false
	}

	return o.IcmpType, true
}

// SetIcmpType sets field value
func (o *NicFirewallRule) SetIcmpType(v int32) {

	o.IcmpType = &v

}

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

	return false
}

// GetPortRangeStart returns the PortRangeStart field value
// If the value is explicit nil, the zero value for int32 will be returned
func (o *NicFirewallRule) GetPortRangeStart() *int32 {
	if o == nil {
		return nil
	}

	return o.PortRangeStart

}

// GetPortRangeStartOk returns a tuple with the PortRangeStart 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 *NicFirewallRule) GetPortRangeStartOk() (*int32, bool) {
	if o == nil {
		return nil, false
	}

	return o.PortRangeStart, true
}

// SetPortRangeStart sets field value
func (o *NicFirewallRule) SetPortRangeStart(v int32) {

	o.PortRangeStart = &v

}

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

	return false
}

// GetPortRangeEnd returns the PortRangeEnd field value
// If the value is explicit nil, the zero value for int32 will be returned
func (o *NicFirewallRule) GetPortRangeEnd() *int32 {
	if o == nil {
		return nil
	}

	return o.PortRangeEnd

}

// GetPortRangeEndOk returns a tuple with the PortRangeEnd 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 *NicFirewallRule) GetPortRangeEndOk() (*int32, bool) {
	if o == nil {
		return nil, false
	}

	return o.PortRangeEnd, true
}

// SetPortRangeEnd sets field value
func (o *NicFirewallRule) SetPortRangeEnd(v int32) {

	o.PortRangeEnd = &v

}

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

	return false
}

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

	return o.Type

}

// GetTypeOk returns a tuple with the Type 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 *NicFirewallRule) GetTypeOk() (*string, bool) {
	if o == nil {
		return nil, false
	}

	return o.Type, true
}

// SetType sets field value
func (o *NicFirewallRule) SetType(v string) {

	o.Type = &v

}

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

	return false
}

func (o NicFirewallRule) MarshalJSON() ([]byte, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["name"] = o.Name

	if o.Protocol != nil {
		toSerialize["protocol"] = o.Protocol
	}

	toSerialize["sourceMac"] = o.SourceMac

	toSerialize["sourceIp"] = o.SourceIp

	toSerialize["targetIp"] = o.TargetIp

	toSerialize["icmpCode"] = o.IcmpCode

	toSerialize["icmpType"] = o.IcmpType

	toSerialize["portRangeStart"] = o.PortRangeStart

	toSerialize["portRangeEnd"] = o.PortRangeEnd

	toSerialize["type"] = o.Type

	return json.Marshal(toSerialize)
}

type NullableNicFirewallRule struct {
	value *NicFirewallRule
	isSet bool
}

func (v NullableNicFirewallRule) Get() *NicFirewallRule {
	return v.value
}

func (v *NullableNicFirewallRule) Set(val *NicFirewallRule) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableNicFirewallRule(val *NicFirewallRule) *NullableNicFirewallRule {
	return &NullableNicFirewallRule{value: val, isSet: true}
}

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

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