/*
Hindsight HTTP API

HTTP API for Hindsight

API version: 0.5.3
*/

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

package hindsight

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

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

// BankStatsResponse Response model for bank statistics endpoint.
type BankStatsResponse struct {
	BankId string `json:"bank_id"`
	TotalNodes int32 `json:"total_nodes"`
	TotalLinks int32 `json:"total_links"`
	TotalDocuments int32 `json:"total_documents"`
	NodesByFactType map[string]int32 `json:"nodes_by_fact_type"`
	LinksByLinkType map[string]int32 `json:"links_by_link_type"`
	LinksByFactType map[string]int32 `json:"links_by_fact_type"`
	LinksBreakdown map[string]map[string]int32 `json:"links_breakdown"`
	PendingOperations int32 `json:"pending_operations"`
	FailedOperations int32 `json:"failed_operations"`
	// Async operations grouped by status (pending, in_progress, completed, failed, cancelled).
	OperationsByStatus map[string]int32 `json:"operations_by_status,omitempty"`
	LastConsolidatedAt NullableString `json:"last_consolidated_at,omitempty"`
	// Number of memories not yet processed into observations
	PendingConsolidation *int32 `json:"pending_consolidation,omitempty"`
	// Number of source memories (world/experience) whose consolidation permanently failed and can be retried via the consolidation recovery endpoint.
	FailedConsolidation *int32 `json:"failed_consolidation,omitempty"`
	// Total number of observations
	TotalObservations *int32 `json:"total_observations,omitempty"`
}

type _BankStatsResponse BankStatsResponse

// NewBankStatsResponse instantiates a new BankStatsResponse 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 NewBankStatsResponse(bankId string, totalNodes int32, totalLinks int32, totalDocuments int32, nodesByFactType map[string]int32, linksByLinkType map[string]int32, linksByFactType map[string]int32, linksBreakdown map[string]map[string]int32, pendingOperations int32, failedOperations int32) *BankStatsResponse {
	this := BankStatsResponse{}
	this.BankId = bankId
	this.TotalNodes = totalNodes
	this.TotalLinks = totalLinks
	this.TotalDocuments = totalDocuments
	this.NodesByFactType = nodesByFactType
	this.LinksByLinkType = linksByLinkType
	this.LinksByFactType = linksByFactType
	this.LinksBreakdown = linksBreakdown
	this.PendingOperations = pendingOperations
	this.FailedOperations = failedOperations
	var pendingConsolidation int32 = 0
	this.PendingConsolidation = &pendingConsolidation
	var failedConsolidation int32 = 0
	this.FailedConsolidation = &failedConsolidation
	var totalObservations int32 = 0
	this.TotalObservations = &totalObservations
	return &this
}

// NewBankStatsResponseWithDefaults instantiates a new BankStatsResponse 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 NewBankStatsResponseWithDefaults() *BankStatsResponse {
	this := BankStatsResponse{}
	var pendingConsolidation int32 = 0
	this.PendingConsolidation = &pendingConsolidation
	var failedConsolidation int32 = 0
	this.FailedConsolidation = &failedConsolidation
	var totalObservations int32 = 0
	this.TotalObservations = &totalObservations
	return &this
}

// GetBankId returns the BankId field value
func (o *BankStatsResponse) GetBankId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.BankId
}

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

// SetBankId sets field value
func (o *BankStatsResponse) SetBankId(v string) {
	o.BankId = v
}

// GetTotalNodes returns the TotalNodes field value
func (o *BankStatsResponse) GetTotalNodes() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.TotalNodes
}

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

// SetTotalNodes sets field value
func (o *BankStatsResponse) SetTotalNodes(v int32) {
	o.TotalNodes = v
}

// GetTotalLinks returns the TotalLinks field value
func (o *BankStatsResponse) GetTotalLinks() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.TotalLinks
}

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

// SetTotalLinks sets field value
func (o *BankStatsResponse) SetTotalLinks(v int32) {
	o.TotalLinks = v
}

// GetTotalDocuments returns the TotalDocuments field value
func (o *BankStatsResponse) GetTotalDocuments() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.TotalDocuments
}

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

// SetTotalDocuments sets field value
func (o *BankStatsResponse) SetTotalDocuments(v int32) {
	o.TotalDocuments = v
}

// GetNodesByFactType returns the NodesByFactType field value
func (o *BankStatsResponse) GetNodesByFactType() map[string]int32 {
	if o == nil {
		var ret map[string]int32
		return ret
	}

	return o.NodesByFactType
}

// GetNodesByFactTypeOk returns a tuple with the NodesByFactType field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetNodesByFactTypeOk() (map[string]int32, bool) {
	if o == nil {
		return map[string]int32{}, false
	}
	return o.NodesByFactType, true
}

// SetNodesByFactType sets field value
func (o *BankStatsResponse) SetNodesByFactType(v map[string]int32) {
	o.NodesByFactType = v
}

// GetLinksByLinkType returns the LinksByLinkType field value
func (o *BankStatsResponse) GetLinksByLinkType() map[string]int32 {
	if o == nil {
		var ret map[string]int32
		return ret
	}

	return o.LinksByLinkType
}

// GetLinksByLinkTypeOk returns a tuple with the LinksByLinkType field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetLinksByLinkTypeOk() (map[string]int32, bool) {
	if o == nil {
		return map[string]int32{}, false
	}
	return o.LinksByLinkType, true
}

// SetLinksByLinkType sets field value
func (o *BankStatsResponse) SetLinksByLinkType(v map[string]int32) {
	o.LinksByLinkType = v
}

// GetLinksByFactType returns the LinksByFactType field value
func (o *BankStatsResponse) GetLinksByFactType() map[string]int32 {
	if o == nil {
		var ret map[string]int32
		return ret
	}

	return o.LinksByFactType
}

// GetLinksByFactTypeOk returns a tuple with the LinksByFactType field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetLinksByFactTypeOk() (map[string]int32, bool) {
	if o == nil {
		return map[string]int32{}, false
	}
	return o.LinksByFactType, true
}

// SetLinksByFactType sets field value
func (o *BankStatsResponse) SetLinksByFactType(v map[string]int32) {
	o.LinksByFactType = v
}

// GetLinksBreakdown returns the LinksBreakdown field value
func (o *BankStatsResponse) GetLinksBreakdown() map[string]map[string]int32 {
	if o == nil {
		var ret map[string]map[string]int32
		return ret
	}

	return o.LinksBreakdown
}

// GetLinksBreakdownOk returns a tuple with the LinksBreakdown field value
// and a boolean to check if the value has been set.
func (o *BankStatsResponse) GetLinksBreakdownOk() (map[string]map[string]int32, bool) {
	if o == nil {
		return map[string]map[string]int32{}, false
	}
	return o.LinksBreakdown, true
}

// SetLinksBreakdown sets field value
func (o *BankStatsResponse) SetLinksBreakdown(v map[string]map[string]int32) {
	o.LinksBreakdown = v
}

// GetPendingOperations returns the PendingOperations field value
func (o *BankStatsResponse) GetPendingOperations() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.PendingOperations
}

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

// SetPendingOperations sets field value
func (o *BankStatsResponse) SetPendingOperations(v int32) {
	o.PendingOperations = v
}

// GetFailedOperations returns the FailedOperations field value
func (o *BankStatsResponse) GetFailedOperations() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.FailedOperations
}

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

// SetFailedOperations sets field value
func (o *BankStatsResponse) SetFailedOperations(v int32) {
	o.FailedOperations = v
}

// GetOperationsByStatus returns the OperationsByStatus field value if set, zero value otherwise.
func (o *BankStatsResponse) GetOperationsByStatus() map[string]int32 {
	if o == nil || IsNil(o.OperationsByStatus) {
		var ret map[string]int32
		return ret
	}
	return o.OperationsByStatus
}

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

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

	return false
}

// SetOperationsByStatus gets a reference to the given map[string]int32 and assigns it to the OperationsByStatus field.
func (o *BankStatsResponse) SetOperationsByStatus(v map[string]int32) {
	o.OperationsByStatus = v
}

// GetLastConsolidatedAt returns the LastConsolidatedAt field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *BankStatsResponse) GetLastConsolidatedAt() string {
	if o == nil || IsNil(o.LastConsolidatedAt.Get()) {
		var ret string
		return ret
	}
	return *o.LastConsolidatedAt.Get()
}

// GetLastConsolidatedAtOk returns a tuple with the LastConsolidatedAt field value if set, nil otherwise
// 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 *BankStatsResponse) GetLastConsolidatedAtOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return o.LastConsolidatedAt.Get(), o.LastConsolidatedAt.IsSet()
}

// HasLastConsolidatedAt returns a boolean if a field has been set.
func (o *BankStatsResponse) HasLastConsolidatedAt() bool {
	if o != nil && o.LastConsolidatedAt.IsSet() {
		return true
	}

	return false
}

// SetLastConsolidatedAt gets a reference to the given NullableString and assigns it to the LastConsolidatedAt field.
func (o *BankStatsResponse) SetLastConsolidatedAt(v string) {
	o.LastConsolidatedAt.Set(&v)
}
// SetLastConsolidatedAtNil sets the value for LastConsolidatedAt to be an explicit nil
func (o *BankStatsResponse) SetLastConsolidatedAtNil() {
	o.LastConsolidatedAt.Set(nil)
}

// UnsetLastConsolidatedAt ensures that no value is present for LastConsolidatedAt, not even an explicit nil
func (o *BankStatsResponse) UnsetLastConsolidatedAt() {
	o.LastConsolidatedAt.Unset()
}

// GetPendingConsolidation returns the PendingConsolidation field value if set, zero value otherwise.
func (o *BankStatsResponse) GetPendingConsolidation() int32 {
	if o == nil || IsNil(o.PendingConsolidation) {
		var ret int32
		return ret
	}
	return *o.PendingConsolidation
}

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

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

	return false
}

// SetPendingConsolidation gets a reference to the given int32 and assigns it to the PendingConsolidation field.
func (o *BankStatsResponse) SetPendingConsolidation(v int32) {
	o.PendingConsolidation = &v
}

// GetFailedConsolidation returns the FailedConsolidation field value if set, zero value otherwise.
func (o *BankStatsResponse) GetFailedConsolidation() int32 {
	if o == nil || IsNil(o.FailedConsolidation) {
		var ret int32
		return ret
	}
	return *o.FailedConsolidation
}

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

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

	return false
}

// SetFailedConsolidation gets a reference to the given int32 and assigns it to the FailedConsolidation field.
func (o *BankStatsResponse) SetFailedConsolidation(v int32) {
	o.FailedConsolidation = &v
}

// GetTotalObservations returns the TotalObservations field value if set, zero value otherwise.
func (o *BankStatsResponse) GetTotalObservations() int32 {
	if o == nil || IsNil(o.TotalObservations) {
		var ret int32
		return ret
	}
	return *o.TotalObservations
}

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

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

	return false
}

// SetTotalObservations gets a reference to the given int32 and assigns it to the TotalObservations field.
func (o *BankStatsResponse) SetTotalObservations(v int32) {
	o.TotalObservations = &v
}

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

func (o BankStatsResponse) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["bank_id"] = o.BankId
	toSerialize["total_nodes"] = o.TotalNodes
	toSerialize["total_links"] = o.TotalLinks
	toSerialize["total_documents"] = o.TotalDocuments
	toSerialize["nodes_by_fact_type"] = o.NodesByFactType
	toSerialize["links_by_link_type"] = o.LinksByLinkType
	toSerialize["links_by_fact_type"] = o.LinksByFactType
	toSerialize["links_breakdown"] = o.LinksBreakdown
	toSerialize["pending_operations"] = o.PendingOperations
	toSerialize["failed_operations"] = o.FailedOperations
	if !IsNil(o.OperationsByStatus) {
		toSerialize["operations_by_status"] = o.OperationsByStatus
	}
	if o.LastConsolidatedAt.IsSet() {
		toSerialize["last_consolidated_at"] = o.LastConsolidatedAt.Get()
	}
	if !IsNil(o.PendingConsolidation) {
		toSerialize["pending_consolidation"] = o.PendingConsolidation
	}
	if !IsNil(o.FailedConsolidation) {
		toSerialize["failed_consolidation"] = o.FailedConsolidation
	}
	if !IsNil(o.TotalObservations) {
		toSerialize["total_observations"] = o.TotalObservations
	}
	return toSerialize, nil
}

func (o *BankStatsResponse) 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{
		"bank_id",
		"total_nodes",
		"total_links",
		"total_documents",
		"nodes_by_fact_type",
		"links_by_link_type",
		"links_by_fact_type",
		"links_breakdown",
		"pending_operations",
		"failed_operations",
	}

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

	varBankStatsResponse := _BankStatsResponse{}

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

	if err != nil {
		return err
	}

	*o = BankStatsResponse(varBankStatsResponse)

	return err
}

type NullableBankStatsResponse struct {
	value *BankStatsResponse
	isSet bool
}

func (v NullableBankStatsResponse) Get() *BankStatsResponse {
	return v.value
}

func (v *NullableBankStatsResponse) Set(val *BankStatsResponse) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableBankStatsResponse(val *BankStatsResponse) *NullableBankStatsResponse {
	return &NullableBankStatsResponse{value: val, isSet: true}
}

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

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


