/*
Edge Application API

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

API version: 2.0.0
*/

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

package edgeapplications

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

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

// OriginsResultResponseAddresses struct for OriginsResultResponseAddresses
type OriginsResultResponseAddresses struct {
	Address string `json:"address"`
	Weight NullableString `json:"weight"`
	ServerRole string `json:"server_role"`
	IsActive bool `json:"is_active"`
}

type _OriginsResultResponseAddresses OriginsResultResponseAddresses

// NewOriginsResultResponseAddresses instantiates a new OriginsResultResponseAddresses 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 NewOriginsResultResponseAddresses(address string, weight NullableString, serverRole string, isActive bool) *OriginsResultResponseAddresses {
	this := OriginsResultResponseAddresses{}
	this.Address = address
	this.Weight = weight
	this.ServerRole = serverRole
	this.IsActive = isActive
	return &this
}

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

// GetAddress returns the Address field value
func (o *OriginsResultResponseAddresses) GetAddress() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Address
}

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

// SetAddress sets field value
func (o *OriginsResultResponseAddresses) SetAddress(v string) {
	o.Address = v
}

// GetWeight returns the Weight field value
// If the value is explicit nil, the zero value for string will be returned
func (o *OriginsResultResponseAddresses) GetWeight() string {
	if o == nil || o.Weight.Get() == nil {
		var ret string
		return ret
	}

	return *o.Weight.Get()
}

// GetWeightOk returns a tuple with the Weight 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 *OriginsResultResponseAddresses) GetWeightOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.Weight.Get(), o.Weight.IsSet()
}

// SetWeight sets field value
func (o *OriginsResultResponseAddresses) SetWeight(v string) {
	o.Weight.Set(&v)
}

// GetServerRole returns the ServerRole field value
func (o *OriginsResultResponseAddresses) GetServerRole() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.ServerRole
}

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

// SetServerRole sets field value
func (o *OriginsResultResponseAddresses) SetServerRole(v string) {
	o.ServerRole = v
}

// GetIsActive returns the IsActive field value
func (o *OriginsResultResponseAddresses) GetIsActive() bool {
	if o == nil {
		var ret bool
		return ret
	}

	return o.IsActive
}

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

// SetIsActive sets field value
func (o *OriginsResultResponseAddresses) SetIsActive(v bool) {
	o.IsActive = v
}

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

func (o OriginsResultResponseAddresses) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["address"] = o.Address
	toSerialize["weight"] = o.Weight.Get()
	toSerialize["server_role"] = o.ServerRole
	toSerialize["is_active"] = o.IsActive
	return toSerialize, nil
}

func (o *OriginsResultResponseAddresses) 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{
		"address",
		"weight",
		"server_role",
		"is_active",
	}

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

	varOriginsResultResponseAddresses := _OriginsResultResponseAddresses{}

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

	if err != nil {
		return err
	}

	*o = OriginsResultResponseAddresses(varOriginsResultResponseAddresses)

	return err
}

type NullableOriginsResultResponseAddresses struct {
	value *OriginsResultResponseAddresses
	isSet bool
}

func (v NullableOriginsResultResponseAddresses) Get() *OriginsResultResponseAddresses {
	return v.value
}

func (v *NullableOriginsResultResponseAddresses) Set(val *OriginsResultResponseAddresses) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableOriginsResultResponseAddresses(val *OriginsResultResponseAddresses) *NullableOriginsResultResponseAddresses {
	return &NullableOriginsResultResponseAddresses{value: val, isSet: true}
}

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

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


