/*
 * Zernio API
 *
 * API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api
 *
 * The version of the OpenAPI document: 1.0.1
 * Contact: support@zernio.com
 * Generated by: https://openapi-generator.tech
 */

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

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateApiKeyRequest {
    #[serde(rename = "name")]
    pub name: String,
    /// Days until expiry
    #[serde(rename = "expiresIn", skip_serializing_if = "Option::is_none")]
    pub expires_in: Option<i32>,
    /// 'full' grants access to all profiles (default), 'profiles' restricts to specific profiles
    #[serde(rename = "scope", skip_serializing_if = "Option::is_none")]
    pub scope: Option<Scope>,
    /// Profile IDs this key can access. Required when scope is 'profiles'.
    #[serde(rename = "profileIds", skip_serializing_if = "Option::is_none")]
    pub profile_ids: Option<Vec<String>>,
    /// 'read-write' allows all operations (default), 'read' restricts to GET requests only
    #[serde(rename = "permission", skip_serializing_if = "Option::is_none")]
    pub permission: Option<Permission>,
}

impl CreateApiKeyRequest {
    pub fn new(name: String) -> CreateApiKeyRequest {
        CreateApiKeyRequest {
            name,
            expires_in: None,
            scope: None,
            profile_ids: None,
            permission: None,
        }
    }
}
/// 'full' grants access to all profiles (default), 'profiles' restricts to specific profiles
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Scope {
    #[serde(rename = "full")]
    Full,
    #[serde(rename = "profiles")]
    Profiles,
}

impl Default for Scope {
    fn default() -> Scope {
        Self::Full
    }
}
/// 'read-write' allows all operations (default), 'read' restricts to GET requests only
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Permission {
    #[serde(rename = "read-write")]
    ReadWrite,
    #[serde(rename = "read")]
    Read,
}

impl Default for Permission {
    fn default() -> Permission {
        Self::ReadWrite
    }
}
