// Code generated by azure-service-operator-codegen. DO NOT EDIT.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package arm

import (
	"encoding/json"
	"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
)

type Database_Spec struct {
	Name string `conversion:"pushtoleaf" json:"name,omitempty"`

	// ReadWrite: Mutually exclusive with all other properties
	ReadWrite *ReadWriteDatabase `json:"readWriteDatabase,omitempty"`
}

var _ genruntime.ARMResourceSpec = &Database_Spec{}

// GetAPIVersion returns the ARM API version of the resource. This is always "2023-08-15"
func (database Database_Spec) GetAPIVersion() string {
	return "2023-08-15"
}

// GetName returns the Name of the resource
func (database *Database_Spec) GetName() string {
	return database.Name
}

// GetType returns the ARM Type of the resource. This is always "Microsoft.Kusto/clusters/databases"
func (database *Database_Spec) GetType() string {
	return "Microsoft.Kusto/clusters/databases"
}

// MarshalJSON defers JSON marshaling to the first non-nil property, because Database_Spec represents a discriminated union (JSON OneOf)
func (database Database_Spec) MarshalJSON() ([]byte, error) {
	if database.ReadWrite != nil {
		return json.Marshal(database.ReadWrite)
	}

	return nil, nil
}

// UnmarshalJSON unmarshals the Database_Spec
func (database *Database_Spec) UnmarshalJSON(data []byte) error {
	var rawJson map[string]interface{}
	err := json.Unmarshal(data, &rawJson)
	if err != nil {
		return err
	}
	discriminator := rawJson["kind"]
	if discriminator == "ReadWrite" {
		database.ReadWrite = &ReadWriteDatabase{}
		return json.Unmarshal(data, database.ReadWrite)
	}

	// No error
	return nil
}

type ReadWriteDatabase struct {
	// Kind: Kind of the database
	Kind ReadWriteDatabase_Kind `json:"kind,omitempty"`

	// Location: Resource location.
	Location *string `json:"location,omitempty"`
	Name     string  `conversion:"noarmconversion" json:"name,omitempty"`

	// Properties: The database properties.
	Properties *ReadWriteDatabaseProperties `json:"properties,omitempty"`
}

// +kubebuilder:validation:Enum={"ReadWrite"}
type ReadWriteDatabase_Kind string

const ReadWriteDatabase_Kind_ReadWrite = ReadWriteDatabase_Kind("ReadWrite")

// Mapping from string to ReadWriteDatabase_Kind
var readWriteDatabase_Kind_Values = map[string]ReadWriteDatabase_Kind{
	"readwrite": ReadWriteDatabase_Kind_ReadWrite,
}

// Class representing the Kusto database properties.
type ReadWriteDatabaseProperties struct {
	// HotCachePeriod: The time the data should be kept in cache for fast queries in TimeSpan.
	HotCachePeriod *string `json:"hotCachePeriod,omitempty"`

	// KeyVaultProperties: KeyVault properties for the database encryption.
	KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"`

	// SoftDeletePeriod: The time the data should be kept before it stops being accessible to queries in TimeSpan.
	SoftDeletePeriod *string `json:"softDeletePeriod,omitempty"`
}
