/*
DM OpenAPI DOC

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

API version: 6.0.0
*/

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

package dm

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

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

// GetClusterInfoResponse struct for GetClusterInfoResponse
type GetClusterInfoResponse struct {
	// cluster id
	ClusterId int64            `json:"cluster_id"`
	Topology  *ClusterTopology `json:"topology,omitempty"`
}

type _GetClusterInfoResponse GetClusterInfoResponse

// NewGetClusterInfoResponse instantiates a new GetClusterInfoResponse 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 NewGetClusterInfoResponse(clusterId int64) *GetClusterInfoResponse {
	this := GetClusterInfoResponse{}
	this.ClusterId = clusterId
	return &this
}

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

// GetClusterId returns the ClusterId field value
func (o *GetClusterInfoResponse) GetClusterId() int64 {
	if o == nil {
		var ret int64
		return ret
	}

	return o.ClusterId
}

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

// SetClusterId sets field value
func (o *GetClusterInfoResponse) SetClusterId(v int64) {
	o.ClusterId = v
}

// GetTopology returns the Topology field value if set, zero value otherwise.
func (o *GetClusterInfoResponse) GetTopology() ClusterTopology {
	if o == nil || IsNil(o.Topology) {
		var ret ClusterTopology
		return ret
	}
	return *o.Topology
}

// GetTopologyOk returns a tuple with the Topology field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *GetClusterInfoResponse) GetTopologyOk() (*ClusterTopology, bool) {
	if o == nil || IsNil(o.Topology) {
		return nil, false
	}
	return o.Topology, true
}

// HasTopology returns a boolean if a field has been set.
func (o *GetClusterInfoResponse) HasTopology() bool {
	if o != nil && !IsNil(o.Topology) {
		return true
	}

	return false
}

// SetTopology gets a reference to the given ClusterTopology and assigns it to the Topology field.
func (o *GetClusterInfoResponse) SetTopology(v ClusterTopology) {
	o.Topology = &v
}

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

func (o GetClusterInfoResponse) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["cluster_id"] = o.ClusterId
	if !IsNil(o.Topology) {
		toSerialize["topology"] = o.Topology
	}
	return toSerialize, nil
}

func (o *GetClusterInfoResponse) 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{
		"cluster_id",
	}

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

	varGetClusterInfoResponse := _GetClusterInfoResponse{}

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

	if err != nil {
		return err
	}

	*o = GetClusterInfoResponse(varGetClusterInfoResponse)

	return err
}

type NullableGetClusterInfoResponse struct {
	value *GetClusterInfoResponse
	isSet bool
}

func (v NullableGetClusterInfoResponse) Get() *GetClusterInfoResponse {
	return v.value
}

func (v *NullableGetClusterInfoResponse) Set(val *GetClusterInfoResponse) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableGetClusterInfoResponse(val *GetClusterInfoResponse) *NullableGetClusterInfoResponse {
	return &NullableGetClusterInfoResponse{value: val, isSet: true}
}

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

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