/*
 * The Jira Cloud platform REST API
 *
 * Jira Cloud platform REST API documentation
 *
 * The version of the OpenAPI document: 1001.0.0-SNAPSHOT-48dd1e2d75e7eac65741e465279d2700f927137d
 * Contact: ecosystem@atlassian.com
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// FieldMetadata : The metadata describing an issue field.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FieldMetadata {
    /// The list of values allowed in the field.
    #[serde(rename = "allowedValues", skip_serializing_if = "Option::is_none")]
    pub allowed_values: Option<Vec<serde_json::Value>>,
    /// The URL that can be used to automatically complete the field.
    #[serde(rename = "autoCompleteUrl", skip_serializing_if = "Option::is_none")]
    pub auto_complete_url: Option<String>,
    /// The configuration properties.
    #[serde(rename = "configuration", skip_serializing_if = "Option::is_none")]
    pub configuration: Option<std::collections::HashMap<String, serde_json::Value>>,
    /// The default value of the field.
    #[serde(rename = "defaultValue", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
    pub default_value: Option<Option<serde_json::Value>>,
    /// Whether the field has a default value.
    #[serde(rename = "hasDefaultValue", skip_serializing_if = "Option::is_none")]
    pub has_default_value: Option<bool>,
    /// The key of the field.
    #[serde(rename = "key")]
    pub key: String,
    /// The name of the field.
    #[serde(rename = "name")]
    pub name: String,
    /// The list of operations that can be performed on the field.
    #[serde(rename = "operations")]
    pub operations: Vec<String>,
    /// Whether the field is required.
    #[serde(rename = "required")]
    pub required: bool,
    /// The data type of the field.
    #[serde(rename = "schema")]
    pub schema: Box<models::JsonTypeBean>,
}

impl FieldMetadata {
    /// The metadata describing an issue field.
    pub fn new(key: String, name: String, operations: Vec<String>, required: bool, schema: models::JsonTypeBean) -> FieldMetadata {
        FieldMetadata {
            allowed_values: None,
            auto_complete_url: None,
            configuration: None,
            default_value: None,
            has_default_value: None,
            key,
            name,
            operations,
            required,
            schema: Box::new(schema),
        }
    }
}

