/*
* Zernio API
*
* API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
*
* The version of the OpenAPI document: 1.104.0
* 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>,
/// Resource groups to DISABLE on this key (opt-out denylist). Omit for a legacy full-access key. A key with any group disabled mints with the zrk_ prefix, gets 403 with code=insufficient_permissions and required_group on operations in disabled groups (each operation's group is published as x-resource-group), and can never manage API keys, invites, or member identity. With 'messages' disabled, the key cannot read or send direct messages through any API surface and cannot create or edit a webhook subscription broader than itself. Subscriptions that already exist are governed by their own `disabledResourceGroups`, not by this key's. OAuth connector tokens resolve against the same registry, but their groups are not settable yet.
#[serde(
rename = "disabledResourceGroups",
skip_serializing_if = "Option::is_none"
)]
pub disabled_resource_groups: Option<Vec<DisabledResourceGroups>>,
}
impl CreateApiKeyRequest {
pub fn new(name: String) -> CreateApiKeyRequest {
CreateApiKeyRequest {
name,
expires_in: None,
scope: None,
profile_ids: None,
permission: None,
disabled_resource_groups: 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
}
}
/// Resource groups to DISABLE on this key (opt-out denylist). Omit for a legacy full-access key. A key with any group disabled mints with the zrk_ prefix, gets 403 with code=insufficient_permissions and required_group on operations in disabled groups (each operation's group is published as x-resource-group), and can never manage API keys, invites, or member identity. With 'messages' disabled, the key cannot read or send direct messages through any API surface and cannot create or edit a webhook subscription broader than itself. Subscriptions that already exist are governed by their own `disabledResourceGroups`, not by this key's. OAuth connector tokens resolve against the same registry, but their groups are not settable yet.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum DisabledResourceGroups {
#[serde(rename = "publishing")]
Publishing,
#[serde(rename = "engagement")]
Engagement,
#[serde(rename = "messages")]
Messages,
#[serde(rename = "contacts")]
Contacts,
#[serde(rename = "analytics")]
Analytics,
#[serde(rename = "ads")]
Ads,
#[serde(rename = "telephony")]
Telephony,
#[serde(rename = "accounts")]
Accounts,
#[serde(rename = "billing")]
Billing,
#[serde(rename = "webhooks")]
Webhooks,
}
impl Default for DisabledResourceGroups {
fn default() -> DisabledResourceGroups {
Self::Publishing
}
}