1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
use serde::{Deserialize, Serialize};
use super::ApiKey;
/// An outgoing paginated list keys request.
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ListKeysRequest {
/// The id of the api to list keys for.
pub api_id: String,
/// The optional owner id used to filter keys by owner.
pub owner_id: Option<String>,
/// The optional number of keys to return, up to 100.
pub limit: Option<usize>,
/// The pagination cursor indicating the last key that was returned.
pub cursor: Option<String>,
}
impl ListKeysRequest {
/// Creates a new list keys request.
///
/// # Arguments
/// - `api_id`: The id of the api to list keys for.
///
/// # Returns
/// The new list keys request.
///
/// # Example
/// ```
/// # use unkey::models::ListKeysRequest;
/// let r = ListKeysRequest::new("test");
///
/// assert_eq!(r.api_id, String::from("test"));
/// assert_eq!(r.limit, None);
/// assert_eq!(r.cursor, None);
/// assert_eq!(r.owner_id, None);
/// ```
#[must_use]
pub fn new<T: Into<String>>(api_id: T) -> Self {
Self {
api_id: api_id.into(),
owner_id: None,
limit: None,
cursor: None,
}
}
/// Sets the limit for the request.
///
/// # Arguments
/// - `limit`: The limit to set.
///
/// # Returns
/// Self for chained calls.
///
/// # Example
/// ```
/// # use unkey::models::ListKeysRequest;
/// let r = ListKeysRequest::new("test").set_limit(50);
///
/// assert_eq!(r.limit.unwrap(), 50);
/// ```
#[must_use]
pub fn set_limit(mut self, limit: usize) -> Self {
self.limit = Some(limit);
self
}
/// Sets the pagination offset for the request.
///
/// # Arguments
/// - `cursor`: The pagination offset cursor to set.
///
/// # Returns
/// Self for chained calls.
///
/// # Example
/// ```
/// # use unkey::models::ListKeysRequest;
/// let r = ListKeysRequest::new("test").set_cursor("abcabc");
///
/// assert_eq!(r.cursor.unwrap(), String::from("abcabc"));
/// ```
#[must_use]
pub fn set_cursor<T: Into<String>>(mut self, cursor: T) -> Self {
self.cursor = Some(cursor.into());
self
}
/// Sets the owner id for filtering the listed keys by owner.
///
/// # Arguments
/// - `owner_id`: The owner id to set.
///
/// # Returns
/// Self for chained calls.
///
/// # Example
/// ```
/// # use unkey::models::ListKeysRequest;
/// let r = ListKeysRequest::new("test").set_owner_id("WilfredAlmeida");
///
/// assert_eq!(r.owner_id.unwrap(), String::from("WilfredAlmeida"));
/// ```
#[must_use]
pub fn set_owner_id<T: Into<String>>(mut self, owner_id: T) -> Self {
self.owner_id = Some(owner_id.into());
self
}
}
/// An incoming paginated list keys response.
#[derive(Debug, Clone, Deserialize)]
pub struct ListKeysResponse {
/// The api keys included in this page.
pub keys: Vec<ApiKey>,
/// The total number of api keys.
pub total: usize,
/// The cursor indicating the last key that was returned.
pub cursor: Option<String>,
}
/// An outgoing get api request.
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetApiRequest {
/// The id of the api to get information for.
pub api_id: String,
}
impl GetApiRequest {
/// Creates a new get api request.
///
/// # Arguments
/// - `api_id`: The id of the api to get api information for.
///
/// # Returns
/// The new get api request.
///
/// # Example
/// ```
/// # use unkey::models::GetApiRequest;
/// let r = GetApiRequest::new("test");
///
/// assert_eq!(r.api_id, String::from("test"));
/// ```
#[must_use]
pub fn new<T: Into<String>>(api_id: T) -> Self {
Self {
api_id: api_id.into(),
}
}
}
/// An incoming get api response.
#[derive(Debug, Clone, Deserialize)]
pub struct GetApiResponse {
/// The id of the api.
#[serde(rename = "id")]
pub api_id: String,
/// The name of the api.
pub name: String,
/// The workspace id of the api.
#[serde(rename = "workspaceId")]
pub workspace_id: String,
}