/*
 * IONOS Cloud - API Gateway
 *
 * API Gateway is an application that acts as a \"front door\" for backend services and APIs, handling client requests and routing them to the appropriate backend.
 *
 * API version: 0.0.1
 */

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

package ionoscloud

import (
	"encoding/json"
)

// RouteUpstreams struct for RouteUpstreams
type RouteUpstreams struct {
	// The target URL of the upstream.
	Scheme *string `json:"scheme"`
	// The load balancer algorithm.
	Loadbalancer *string `json:"loadbalancer"`
	// The host of the upstream.
	Host *string `json:"host"`
	// The port of the upstream.
	Port *int32 `json:"port"`
	// Weight with which to split traffic to the upstream.
	Weight *int32 `json:"weight,omitempty"`
}

// NewRouteUpstreams instantiates a new RouteUpstreams 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 NewRouteUpstreams(scheme string, loadbalancer string, host string, port int32) *RouteUpstreams {
	this := RouteUpstreams{}

	this.Scheme = &scheme
	this.Loadbalancer = &loadbalancer
	this.Host = &host
	this.Port = &port
	var weight int32 = 100
	this.Weight = &weight

	return &this
}

// NewRouteUpstreamsWithDefaults instantiates a new RouteUpstreams 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 NewRouteUpstreamsWithDefaults() *RouteUpstreams {
	this := RouteUpstreams{}
	var scheme string = "http"
	this.Scheme = &scheme
	var loadbalancer string = "roundrobin"
	this.Loadbalancer = &loadbalancer
	var port int32 = 80
	this.Port = &port
	var weight int32 = 100
	this.Weight = &weight
	return &this
}

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

	return o.Scheme

}

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

	return o.Scheme, true
}

// SetScheme sets field value
func (o *RouteUpstreams) SetScheme(v string) {

	o.Scheme = &v

}

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

	return false
}

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

	return o.Loadbalancer

}

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

	return o.Loadbalancer, true
}

// SetLoadbalancer sets field value
func (o *RouteUpstreams) SetLoadbalancer(v string) {

	o.Loadbalancer = &v

}

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

	return false
}

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

	return o.Host

}

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

	return o.Host, true
}

// SetHost sets field value
func (o *RouteUpstreams) SetHost(v string) {

	o.Host = &v

}

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

	return false
}

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

	return o.Port

}

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

	return o.Port, true
}

// SetPort sets field value
func (o *RouteUpstreams) SetPort(v int32) {

	o.Port = &v

}

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

	return false
}

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

	return o.Weight

}

// 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 *RouteUpstreams) GetWeightOk() (*int32, bool) {
	if o == nil {
		return nil, false
	}

	return o.Weight, true
}

// SetWeight sets field value
func (o *RouteUpstreams) SetWeight(v int32) {

	o.Weight = &v

}

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

	return false
}

func (o RouteUpstreams) MarshalJSON() ([]byte, error) {
	toSerialize := map[string]interface{}{}
	if o.Scheme != nil {
		toSerialize["scheme"] = o.Scheme
	}

	if o.Loadbalancer != nil {
		toSerialize["loadbalancer"] = o.Loadbalancer
	}

	if o.Host != nil {
		toSerialize["host"] = o.Host
	}

	if o.Port != nil {
		toSerialize["port"] = o.Port
	}

	if o.Weight != nil {
		toSerialize["weight"] = o.Weight
	}

	return json.Marshal(toSerialize)
}

type NullableRouteUpstreams struct {
	value *RouteUpstreams
	isSet bool
}

func (v NullableRouteUpstreams) Get() *RouteUpstreams {
	return v.value
}

func (v *NullableRouteUpstreams) Set(val *RouteUpstreams) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableRouteUpstreams(val *RouteUpstreams) *NullableRouteUpstreams {
	return &NullableRouteUpstreams{value: val, isSet: true}
}

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

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