<?php
/**
 * ServerInfoBrief
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  OpenAPI\Client
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * orchd
 *
 * orchd API docs
 *
 * The version of the OpenAPI document: 12.13.0
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.17.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace OpenAPI\Client\Model;

use \ArrayAccess;
use \OpenAPI\Client\ObjectSerializer;

/**
 * ServerInfoBrief Class Doc Comment
 *
 * @category Class
 * @package  OpenAPI\Client
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 * @implements \ArrayAccess<string, mixed>
 */
class ServerInfoBrief implements ModelInterface, ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $openAPIModelName = 'ServerInfoBrief';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'id' => 'string',
        'group_id' => 'string',
        'is_control_panel' => 'bool',
        'is_configured' => 'bool',
        'friendly_name' => 'string',
        'hostname' => 'string',
        'ips' => '\OpenAPI\Client\Model\ServerIp[]',
        'roles' => '\OpenAPI\Client\Model\RoleInstalledStatusSummary',
        'created_at' => 'string',
        'dedicated_subscription' => 'float',
        'is_decommissioned' => 'bool',
        'ipv6_addr' => 'string',
        'appcd_version' => 'string',
        'update_required' => 'bool'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      * @phpstan-var array<string, string|null>
      * @psalm-var array<string, string|null>
      */
    protected static $openAPIFormats = [
        'id' => 'uuid',
        'group_id' => 'uuid',
        'is_control_panel' => null,
        'is_configured' => null,
        'friendly_name' => null,
        'hostname' => null,
        'ips' => null,
        'roles' => null,
        'created_at' => null,
        'dedicated_subscription' => null,
        'is_decommissioned' => null,
        'ipv6_addr' => null,
        'appcd_version' => null,
        'update_required' => null
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'id' => false,
        'group_id' => false,
        'is_control_panel' => false,
        'is_configured' => false,
        'friendly_name' => false,
        'hostname' => false,
        'ips' => false,
        'roles' => false,
        'created_at' => false,
        'dedicated_subscription' => false,
        'is_decommissioned' => false,
        'ipv6_addr' => false,
        'appcd_version' => false,
        'update_required' => false
    ];

    /**
      * If a nullable field gets set to null, insert it here
      *
      * @var boolean[]
      */
    protected array $openAPINullablesSetToNull = [];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPITypes()
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function openAPIFormats()
    {
        return self::$openAPIFormats;
    }

    /**
     * Array of nullable properties
     *
     * @return array
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null
     *
     * @return boolean[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null
     *
     * @param boolean[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Checks if a property is nullable
     *
     * @param string $property
     * @return bool
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     *
     * @param string $property
     * @return bool
     */
    public function isNullableSetToNull(string $property): bool
    {
        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'id' => 'id',
        'group_id' => 'groupId',
        'is_control_panel' => 'isControlPanel',
        'is_configured' => 'isConfigured',
        'friendly_name' => 'friendlyName',
        'hostname' => 'hostname',
        'ips' => 'ips',
        'roles' => 'roles',
        'created_at' => 'createdAt',
        'dedicated_subscription' => 'dedicatedSubscription',
        'is_decommissioned' => 'isDecommissioned',
        'ipv6_addr' => 'ipv6Addr',
        'appcd_version' => 'appcdVersion',
        'update_required' => 'updateRequired'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'id' => 'setId',
        'group_id' => 'setGroupId',
        'is_control_panel' => 'setIsControlPanel',
        'is_configured' => 'setIsConfigured',
        'friendly_name' => 'setFriendlyName',
        'hostname' => 'setHostname',
        'ips' => 'setIps',
        'roles' => 'setRoles',
        'created_at' => 'setCreatedAt',
        'dedicated_subscription' => 'setDedicatedSubscription',
        'is_decommissioned' => 'setIsDecommissioned',
        'ipv6_addr' => 'setIpv6Addr',
        'appcd_version' => 'setAppcdVersion',
        'update_required' => 'setUpdateRequired'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'id' => 'getId',
        'group_id' => 'getGroupId',
        'is_control_panel' => 'getIsControlPanel',
        'is_configured' => 'getIsConfigured',
        'friendly_name' => 'getFriendlyName',
        'hostname' => 'getHostname',
        'ips' => 'getIps',
        'roles' => 'getRoles',
        'created_at' => 'getCreatedAt',
        'dedicated_subscription' => 'getDedicatedSubscription',
        'is_decommissioned' => 'getIsDecommissioned',
        'ipv6_addr' => 'getIpv6Addr',
        'appcd_version' => 'getAppcdVersion',
        'update_required' => 'getUpdateRequired'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$openAPIModelName;
    }


    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[]|null $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('group_id', $data ?? [], null);
        $this->setIfExists('is_control_panel', $data ?? [], null);
        $this->setIfExists('is_configured', $data ?? [], null);
        $this->setIfExists('friendly_name', $data ?? [], null);
        $this->setIfExists('hostname', $data ?? [], null);
        $this->setIfExists('ips', $data ?? [], null);
        $this->setIfExists('roles', $data ?? [], null);
        $this->setIfExists('created_at', $data ?? [], null);
        $this->setIfExists('dedicated_subscription', $data ?? [], null);
        $this->setIfExists('is_decommissioned', $data ?? [], null);
        $this->setIfExists('ipv6_addr', $data ?? [], null);
        $this->setIfExists('appcd_version', $data ?? [], null);
        $this->setIfExists('update_required', $data ?? [], null);
    }

    /**
    * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
    * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
    * $this->openAPINullablesSetToNull array
    *
    * @param string $variableName
    * @param array  $fields
    * @param mixed  $defaultValue
    */
    private function setIfExists(string $variableName, array $fields, $defaultValue): void
    {
        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
            $this->openAPINullablesSetToNull[] = $variableName;
        }

        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if ($this->container['id'] === null) {
            $invalidProperties[] = "'id' can't be null";
        }
        if ($this->container['group_id'] === null) {
            $invalidProperties[] = "'group_id' can't be null";
        }
        if ($this->container['is_control_panel'] === null) {
            $invalidProperties[] = "'is_control_panel' can't be null";
        }
        if ($this->container['is_configured'] === null) {
            $invalidProperties[] = "'is_configured' can't be null";
        }
        if ($this->container['friendly_name'] === null) {
            $invalidProperties[] = "'friendly_name' can't be null";
        }
        if ($this->container['hostname'] === null) {
            $invalidProperties[] = "'hostname' can't be null";
        }
        if ($this->container['ips'] === null) {
            $invalidProperties[] = "'ips' can't be null";
        }
        if ($this->container['roles'] === null) {
            $invalidProperties[] = "'roles' can't be null";
        }
        if ($this->container['created_at'] === null) {
            $invalidProperties[] = "'created_at' can't be null";
        }
        if ($this->container['is_decommissioned'] === null) {
            $invalidProperties[] = "'is_decommissioned' can't be null";
        }
        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets id
     *
     * @return string
     */
    public function getId()
    {
        return $this->container['id'];
    }

    /**
     * Sets id
     *
     * @param string $id id
     *
     * @return self
     */
    public function setId($id)
    {
        if (is_null($id)) {
            throw new \InvalidArgumentException('non-nullable id cannot be null');
        }
        $this->container['id'] = $id;

        return $this;
    }

    /**
     * Gets group_id
     *
     * @return string
     */
    public function getGroupId()
    {
        return $this->container['group_id'];
    }

    /**
     * Sets group_id
     *
     * @param string $group_id group_id
     *
     * @return self
     */
    public function setGroupId($group_id)
    {
        if (is_null($group_id)) {
            throw new \InvalidArgumentException('non-nullable group_id cannot be null');
        }
        $this->container['group_id'] = $group_id;

        return $this;
    }

    /**
     * Gets is_control_panel
     *
     * @return bool
     */
    public function getIsControlPanel()
    {
        return $this->container['is_control_panel'];
    }

    /**
     * Sets is_control_panel
     *
     * @param bool $is_control_panel is_control_panel
     *
     * @return self
     */
    public function setIsControlPanel($is_control_panel)
    {
        if (is_null($is_control_panel)) {
            throw new \InvalidArgumentException('non-nullable is_control_panel cannot be null');
        }
        $this->container['is_control_panel'] = $is_control_panel;

        return $this;
    }

    /**
     * Gets is_configured
     *
     * @return bool
     */
    public function getIsConfigured()
    {
        return $this->container['is_configured'];
    }

    /**
     * Sets is_configured
     *
     * @param bool $is_configured is_configured
     *
     * @return self
     */
    public function setIsConfigured($is_configured)
    {
        if (is_null($is_configured)) {
            throw new \InvalidArgumentException('non-nullable is_configured cannot be null');
        }
        $this->container['is_configured'] = $is_configured;

        return $this;
    }

    /**
     * Gets friendly_name
     *
     * @return string
     */
    public function getFriendlyName()
    {
        return $this->container['friendly_name'];
    }

    /**
     * Sets friendly_name
     *
     * @param string $friendly_name friendly_name
     *
     * @return self
     */
    public function setFriendlyName($friendly_name)
    {
        if (is_null($friendly_name)) {
            throw new \InvalidArgumentException('non-nullable friendly_name cannot be null');
        }
        $this->container['friendly_name'] = $friendly_name;

        return $this;
    }

    /**
     * Gets hostname
     *
     * @return string
     */
    public function getHostname()
    {
        return $this->container['hostname'];
    }

    /**
     * Sets hostname
     *
     * @param string $hostname hostname
     *
     * @return self
     */
    public function setHostname($hostname)
    {
        if (is_null($hostname)) {
            throw new \InvalidArgumentException('non-nullable hostname cannot be null');
        }
        $this->container['hostname'] = $hostname;

        return $this;
    }

    /**
     * Gets ips
     *
     * @return \OpenAPI\Client\Model\ServerIp[]
     */
    public function getIps()
    {
        return $this->container['ips'];
    }

    /**
     * Sets ips
     *
     * @param \OpenAPI\Client\Model\ServerIp[] $ips ips
     *
     * @return self
     */
    public function setIps($ips)
    {
        if (is_null($ips)) {
            throw new \InvalidArgumentException('non-nullable ips cannot be null');
        }
        $this->container['ips'] = $ips;

        return $this;
    }

    /**
     * Gets roles
     *
     * @return \OpenAPI\Client\Model\RoleInstalledStatusSummary
     */
    public function getRoles()
    {
        return $this->container['roles'];
    }

    /**
     * Sets roles
     *
     * @param \OpenAPI\Client\Model\RoleInstalledStatusSummary $roles roles
     *
     * @return self
     */
    public function setRoles($roles)
    {
        if (is_null($roles)) {
            throw new \InvalidArgumentException('non-nullable roles cannot be null');
        }
        $this->container['roles'] = $roles;

        return $this;
    }

    /**
     * Gets created_at
     *
     * @return string
     */
    public function getCreatedAt()
    {
        return $this->container['created_at'];
    }

    /**
     * Sets created_at
     *
     * @param string $created_at created_at
     *
     * @return self
     */
    public function setCreatedAt($created_at)
    {
        if (is_null($created_at)) {
            throw new \InvalidArgumentException('non-nullable created_at cannot be null');
        }
        $this->container['created_at'] = $created_at;

        return $this;
    }

    /**
     * Gets dedicated_subscription
     *
     * @return float|null
     */
    public function getDedicatedSubscription()
    {
        return $this->container['dedicated_subscription'];
    }

    /**
     * Sets dedicated_subscription
     *
     * @param float|null $dedicated_subscription dedicated_subscription
     *
     * @return self
     */
    public function setDedicatedSubscription($dedicated_subscription)
    {
        if (is_null($dedicated_subscription)) {
            throw new \InvalidArgumentException('non-nullable dedicated_subscription cannot be null');
        }
        $this->container['dedicated_subscription'] = $dedicated_subscription;

        return $this;
    }

    /**
     * Gets is_decommissioned
     *
     * @return bool
     */
    public function getIsDecommissioned()
    {
        return $this->container['is_decommissioned'];
    }

    /**
     * Sets is_decommissioned
     *
     * @param bool $is_decommissioned is_decommissioned
     *
     * @return self
     */
    public function setIsDecommissioned($is_decommissioned)
    {
        if (is_null($is_decommissioned)) {
            throw new \InvalidArgumentException('non-nullable is_decommissioned cannot be null');
        }
        $this->container['is_decommissioned'] = $is_decommissioned;

        return $this;
    }

    /**
     * Gets ipv6_addr
     *
     * @return string|null
     */
    public function getIpv6Addr()
    {
        return $this->container['ipv6_addr'];
    }

    /**
     * Sets ipv6_addr
     *
     * @param string|null $ipv6_addr ipv6_addr
     *
     * @return self
     */
    public function setIpv6Addr($ipv6_addr)
    {
        if (is_null($ipv6_addr)) {
            throw new \InvalidArgumentException('non-nullable ipv6_addr cannot be null');
        }
        $this->container['ipv6_addr'] = $ipv6_addr;

        return $this;
    }

    /**
     * Gets appcd_version
     *
     * @return string|null
     */
    public function getAppcdVersion()
    {
        return $this->container['appcd_version'];
    }

    /**
     * Sets appcd_version
     *
     * @param string|null $appcd_version appcd_version
     *
     * @return self
     */
    public function setAppcdVersion($appcd_version)
    {
        if (is_null($appcd_version)) {
            throw new \InvalidArgumentException('non-nullable appcd_version cannot be null');
        }
        $this->container['appcd_version'] = $appcd_version;

        return $this;
    }

    /**
     * Gets update_required
     *
     * @return bool|null
     */
    public function getUpdateRequired()
    {
        return $this->container['update_required'];
    }

    /**
     * Sets update_required
     *
     * @param bool|null $update_required update_required
     *
     * @return self
     */
    public function setUpdateRequired($update_required)
    {
        if (is_null($update_required)) {
            throw new \InvalidArgumentException('non-nullable update_required cannot be null');
        }
        $this->container['update_required'] = $update_required;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer|string $offset Offset
     *
     * @return boolean
     */
    public function offsetExists(mixed $offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer|string $offset Offset
     *
     * @return mixed|null
     */
    #[\ReturnTypeWillChange]
    public function offsetGet(mixed $offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param int|null $offset Offset
     * @param mixed    $value  Value to be set
     *
     * @return void
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer|string $offset Offset
     *
     * @return void
     */
    public function offsetUnset(mixed $offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed Returns data which can be serialized by json_encode(), which is a value
     * of any type other than a resource.
     */
    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
       return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Gets a header-safe presentation of the object
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}


