/*
 * 3DS OUTSCALE API
 *
 * Welcome to the OUTSCALE API documentation.<br /> The OUTSCALE API enables you to manage your resources in the OUTSCALE Cloud. This documentation describes the different actions available along with code examples.<br /><br /> Throttling: To protect against overloads, the number of identical requests allowed in a given time period is limited.<br /> Brute force: To protect against brute force attacks, the number of failed authentication attempts in a given time period is limited.<br /><br /> Note that the OUTSCALE Cloud is compatible with Amazon Web Services (AWS) APIs, but there are [differences in resource names](https://docs.outscale.com/en/userguide/About-the-APIs.html) between AWS and the OUTSCALE API.<br /> You can also manage your resources using the [Cockpit](https://docs.outscale.com/en/userguide/About-Cockpit.html) web interface.<br /><br /> An OpenAPI description of this API is also available for download: <button>[GitHub repository](https://github.com/outscale/osc-api)</button><br /> # Authentication Schemes ### Access Key/Secret Key The main way to authenticate your requests to the OUTSCALE API is to use an access key and a secret key.<br /> The mechanism behind this is based on AWS Signature Version 4, whose technical implementation details are described in [Signature of API Requests](https://docs.outscale.com/en/userguide/Signature-of-API-Requests.html).<br /><br /> In practice, the way to specify your access key and secret key depends on the tool or SDK you want to use to interact with the API.<br />  > For example, if you use OSC CLI: > 1. You need to create an **~/.osc/config.json** file to specify your access key, secret key, and the Region of your account. > 2. You then specify the `--profile` option when executing OSC CLI commands. > > For more information, see [Installing and Configuring OSC CLI](https://docs.outscale.com/en/userguide/Installing-and-Configuring-OSC-CLI.html).  See the code samples in each section of this documentation for specific examples in different programming languages.<br /> For more information about access keys, see [About Access Keys](https://docs.outscale.com/en/userguide/About-Access-Keys.html).  > If you try to sign requests with an invalid access key four times in a row, further authentication attempts will be prevented for 1 minute. This lockout time increases 1 minute every four failed attempts, for up to 10 minutes.  ### Login/Password For certain API actions, you can also use basic authentication with the login (email address) and password of your OUTSCALE account.<br /> This is useful only in special circumstances, for example if you do not know your access key/secret key and want to retrieve them programmatically.<br /> In most cases, however, you can use the Cockpit web interface to retrieve them.<br />  > For example, if you use OSC CLI: > 1. You need to create an **~/.osc/config.json** file to specify the Region of your account, but you leave the access key value and secret key value empty (`&quot;&quot;`). > 2. You then specify the `--profile`, `--authentication-method`, `--login`, and `--password` options when executing OSC CLI commands.  See the code samples in each section of this documentation for specific examples in different programming languages.  > If you try to sign requests with an invalid password four times in a row, further authentication attempts will be prevented for 1 minute. This lockout time increases 1 minute every four failed attempts, for up to 10 minutes.  ### No Authentication A few API actions do not require any authentication. They are indicated as such in this documentation.<br /> ### Other Security Mechanisms In parallel with the authentication schemes, you can add other security mechanisms to your OUTSCALE account, for example to restrict API requests by IP or other criteria.<br /> For more information, see [Managing Your API Accesses](https://docs.outscale.com/en/userguide/Managing-Your-API-Accesses.html). # Pagination Tutorial You can learn more about the pagination methods for read calls in the dedicated [pagination tutorial](https://docs.outscale.com/en/userguide/Tutorial-Paginating-an-API-Request.html). # Error Codes Reference You can learn more about errors returned by the API in the dedicated [errors page](api-errors.html).
 *
 * API version: 1.41.0
 * Contact: support@outscale.com
 */

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

package osc

import (
	"encoding/json"
)

// SecurityGroupRule Information about the security group rule.
type SecurityGroupRule struct {
	// The beginning of the port range for the TCP and UDP protocols, or an ICMP type number.
	FromPortRange *int32 `json:"FromPortRange,omitempty"`
	// The IP protocol name (`tcp`, `udp`, `icmp`, or `-1` for all protocols). By default, `-1`. In a Net, this can also be an IP protocol number. For more information, see the [IANA.org website](https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml).
	IpProtocol *string `json:"IpProtocol,omitempty"`
	// One or more IP ranges for the security group rules, in CIDR notation (for example, `[&quot;10.0.0.0/24&quot; , &quot;10.0.1.0/24&quot;]`).
	IpRanges *[]string `json:"IpRanges,omitempty"`
	// The ID of the security group rule.
	SecurityGroupRuleId *string `json:"SecurityGroupRuleId,omitempty"`
	// Information about one or more source or destination security groups.
	SecurityGroupsMembers *[]SecurityGroupsMember `json:"SecurityGroupsMembers,omitempty"`
	// One or more service IDs to allow traffic from a Net to access the corresponding OUTSCALE services. For more information, see [ReadNetAccessPointServices](#readnetaccesspointservices).
	ServiceIds *[]string `json:"ServiceIds,omitempty"`
	// The end of the port range for the TCP and UDP protocols, or an ICMP code number.
	ToPortRange *int32 `json:"ToPortRange,omitempty"`
}

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

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

// GetFromPortRange returns the FromPortRange field value if set, zero value otherwise.
func (o *SecurityGroupRule) GetFromPortRange() int32 {
	if o == nil || o.FromPortRange == nil {
		var ret int32
		return ret
	}
	return *o.FromPortRange
}

// GetFromPortRangeOk returns a tuple with the FromPortRange field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SecurityGroupRule) GetFromPortRangeOk() (*int32, bool) {
	if o == nil || o.FromPortRange == nil {
		return nil, false
	}
	return o.FromPortRange, true
}

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

	return false
}

// SetFromPortRange gets a reference to the given int32 and assigns it to the FromPortRange field.
func (o *SecurityGroupRule) SetFromPortRange(v int32) {
	o.FromPortRange = &v
}

// GetIpProtocol returns the IpProtocol field value if set, zero value otherwise.
func (o *SecurityGroupRule) GetIpProtocol() string {
	if o == nil || o.IpProtocol == nil {
		var ret string
		return ret
	}
	return *o.IpProtocol
}

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

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

	return false
}

// SetIpProtocol gets a reference to the given string and assigns it to the IpProtocol field.
func (o *SecurityGroupRule) SetIpProtocol(v string) {
	o.IpProtocol = &v
}

// GetIpRanges returns the IpRanges field value if set, zero value otherwise.
func (o *SecurityGroupRule) GetIpRanges() []string {
	if o == nil || o.IpRanges == nil {
		var ret []string
		return ret
	}
	return *o.IpRanges
}

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

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

	return false
}

// SetIpRanges gets a reference to the given []string and assigns it to the IpRanges field.
func (o *SecurityGroupRule) SetIpRanges(v []string) {
	o.IpRanges = &v
}

// GetSecurityGroupRuleId returns the SecurityGroupRuleId field value if set, zero value otherwise.
func (o *SecurityGroupRule) GetSecurityGroupRuleId() string {
	if o == nil || o.SecurityGroupRuleId == nil {
		var ret string
		return ret
	}
	return *o.SecurityGroupRuleId
}

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

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

	return false
}

// SetSecurityGroupRuleId gets a reference to the given string and assigns it to the SecurityGroupRuleId field.
func (o *SecurityGroupRule) SetSecurityGroupRuleId(v string) {
	o.SecurityGroupRuleId = &v
}

// GetSecurityGroupsMembers returns the SecurityGroupsMembers field value if set, zero value otherwise.
func (o *SecurityGroupRule) GetSecurityGroupsMembers() []SecurityGroupsMember {
	if o == nil || o.SecurityGroupsMembers == nil {
		var ret []SecurityGroupsMember
		return ret
	}
	return *o.SecurityGroupsMembers
}

// GetSecurityGroupsMembersOk returns a tuple with the SecurityGroupsMembers field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SecurityGroupRule) GetSecurityGroupsMembersOk() (*[]SecurityGroupsMember, bool) {
	if o == nil || o.SecurityGroupsMembers == nil {
		return nil, false
	}
	return o.SecurityGroupsMembers, true
}

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

	return false
}

// SetSecurityGroupsMembers gets a reference to the given []SecurityGroupsMember and assigns it to the SecurityGroupsMembers field.
func (o *SecurityGroupRule) SetSecurityGroupsMembers(v []SecurityGroupsMember) {
	o.SecurityGroupsMembers = &v
}

// GetServiceIds returns the ServiceIds field value if set, zero value otherwise.
func (o *SecurityGroupRule) GetServiceIds() []string {
	if o == nil || o.ServiceIds == nil {
		var ret []string
		return ret
	}
	return *o.ServiceIds
}

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

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

	return false
}

// SetServiceIds gets a reference to the given []string and assigns it to the ServiceIds field.
func (o *SecurityGroupRule) SetServiceIds(v []string) {
	o.ServiceIds = &v
}

// GetToPortRange returns the ToPortRange field value if set, zero value otherwise.
func (o *SecurityGroupRule) GetToPortRange() int32 {
	if o == nil || o.ToPortRange == nil {
		var ret int32
		return ret
	}
	return *o.ToPortRange
}

// GetToPortRangeOk returns a tuple with the ToPortRange field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *SecurityGroupRule) GetToPortRangeOk() (*int32, bool) {
	if o == nil || o.ToPortRange == nil {
		return nil, false
	}
	return o.ToPortRange, true
}

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

	return false
}

// SetToPortRange gets a reference to the given int32 and assigns it to the ToPortRange field.
func (o *SecurityGroupRule) SetToPortRange(v int32) {
	o.ToPortRange = &v
}

func (o SecurityGroupRule) MarshalJSON() ([]byte, error) {
	toSerialize := map[string]interface{}{}
	if o.FromPortRange != nil {
		toSerialize["FromPortRange"] = o.FromPortRange
	}
	if o.IpProtocol != nil {
		toSerialize["IpProtocol"] = o.IpProtocol
	}
	if o.IpRanges != nil {
		toSerialize["IpRanges"] = o.IpRanges
	}
	if o.SecurityGroupRuleId != nil {
		toSerialize["SecurityGroupRuleId"] = o.SecurityGroupRuleId
	}
	if o.SecurityGroupsMembers != nil {
		toSerialize["SecurityGroupsMembers"] = o.SecurityGroupsMembers
	}
	if o.ServiceIds != nil {
		toSerialize["ServiceIds"] = o.ServiceIds
	}
	if o.ToPortRange != nil {
		toSerialize["ToPortRange"] = o.ToPortRange
	}
	return json.Marshal(toSerialize)
}

type NullableSecurityGroupRule struct {
	value *SecurityGroupRule
	isSet bool
}

func (v NullableSecurityGroupRule) Get() *SecurityGroupRule {
	return v.value
}

func (v *NullableSecurityGroupRule) Set(val *SecurityGroupRule) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableSecurityGroupRule(val *SecurityGroupRule) *NullableSecurityGroupRule {
	return &NullableSecurityGroupRule{value: val, isSet: true}
}

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

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