async_openai/types/admin/
invites.rs

1use crate::types::OpenAIError;
2use crate::types::OrganizationRole;
3use derive_builder::Builder;
4use serde::{Deserialize, Serialize};
5
6/// Query parameters for listing invites.
7#[derive(Debug, Serialize, Default, Clone, Builder, PartialEq)]
8#[builder(name = "ListInvitesQueryArgs")]
9#[builder(pattern = "mutable")]
10#[builder(setter(into, strip_option), default)]
11#[builder(derive(Debug))]
12#[builder(build_fn(error = "OpenAIError"))]
13pub struct ListInvitesQuery {
14    /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub limit: Option<u32>,
17    /// A cursor for use in pagination. `after` is an object ID that defines your place in the list.
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub after: Option<String>,
20}
21
22#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
23#[serde(rename_all = "lowercase")]
24pub enum InviteStatus {
25    Accepted,
26    Expired,
27    Pending,
28}
29
30#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Builder)]
31#[builder(name = "InviteRequestArgs")]
32#[builder(pattern = "mutable")]
33#[builder(setter(into, strip_option))]
34#[builder(derive(Debug))]
35#[builder(build_fn(error = "OpenAIError"))]
36pub struct InviteRequest {
37    pub email: String,
38    pub role: OrganizationRole,
39}
40
41#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
42pub struct InviteListResponse {
43    pub object: String,
44    pub data: Vec<Invite>,
45    pub first_id: Option<String>,
46    pub last_id: Option<String>,
47    pub has_more: Option<bool>,
48}
49
50#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
51pub struct InviteDeleteResponse {
52    /// The object type, which is always `organization.invite.deleted`
53    pub object: String,
54    pub id: String,
55    pub deleted: bool,
56}
57
58/// Represents an individual `invite` to the organization.
59#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
60pub struct Invite {
61    /// The object type, which is always `organization.invite`
62    pub object: String,
63    /// The identifier, which can be referenced in API endpoints
64    pub id: String,
65    /// The email address of the individual to whom the invite was sent
66    pub email: String,
67    /// `owner` or `reader`
68    pub role: OrganizationRole,
69    /// `accepted`, `expired`, or `pending`
70    pub status: InviteStatus,
71    /// The Unix timestamp (in seconds) of when the invite was sent.
72    pub invited_at: u64,
73    /// The Unix timestamp (in seconds) of when the invite expires.
74    pub expires_at: u64,
75    /// The Unix timestamp (in seconds) of when the invite was accepted.
76    pub accepted_at: Option<u64>,
77}