zoom-cli 0.2.1

Agent-friendly Zoom CLI with JSON output, structured exit codes, and schema introspection
Documentation
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
use clap::{CommandFactory, Parser, Subcommand};

use zoom_cli::config::Config;
use zoom_cli::output::{OutputConfig, exit_codes};
use zoom_cli::{api, commands};

#[derive(Parser)]
#[command(
    name = "zoom",
    version,
    about = "CLI for the Zoom API",
    arg_required_else_help = true
)]
struct Cli {
    /// Config profile to use [env: ZOOM_PROFILE]
    #[arg(long, env = "ZOOM_PROFILE", global = true)]
    profile: Option<String>,

    /// Output as JSON (auto-enabled when stdout is not a terminal)
    #[arg(long, global = true)]
    json: bool,

    /// Suppress non-data output (counts, confirmations)
    #[arg(long, global = true)]
    quiet: bool,

    #[command(subcommand)]
    command: Command,
}

#[derive(Subcommand)]
enum Command {
    /// Manage meetings
    #[command(subcommand, arg_required_else_help = true)]
    Meetings(MeetingsCommand),

    /// Manage recordings
    #[command(subcommand, arg_required_else_help = true)]
    Recordings(RecordingsCommand),

    /// Manage users
    #[command(subcommand, arg_required_else_help = true)]
    Users(UsersCommand),

    /// Meeting and usage reports
    #[command(subcommand, arg_required_else_help = true)]
    Reports(ReportsCommand),

    /// Manage webinars
    #[command(subcommand, arg_required_else_help = true)]
    Webinars(WebinarsCommand),

    /// Manage configuration
    #[command(subcommand, arg_required_else_help = true)]
    Config(ConfigCommand),

    /// Set up credentials interactively (or print JSON schema for agents)
    Init {
        /// Profile name to create or update (default: "default")
        #[arg(long)]
        profile: Option<String>,
    },

    /// Print schema/field reference for a resource
    Schema {
        /// Resource name: meetings, recordings, users, reports, webinars
        resource: String,
    },

    /// Generate shell completions
    Completions {
        /// Shell to generate completions for
        shell: clap_complete::Shell,
    },
}

#[derive(Subcommand)]
enum ConfigCommand {
    /// Show current configuration: profiles, active profile, and env overrides
    Show,
    /// Delete a profile from the config file
    Delete {
        /// Profile name to delete
        profile: String,
        /// Skip confirmation prompt
        #[arg(long)]
        force: bool,
    },
}

#[derive(Subcommand)]
enum MeetingsCommand {
    /// List meetings for a user
    List {
        #[arg(long, default_value = "me")]
        user: String,
        #[arg(long)]
        r#type: Option<String>,
    },
    /// Get a meeting by ID
    Get { id: u64 },
    /// Create a meeting
    Create {
        #[arg(long)]
        topic: String,
        #[arg(long)]
        duration: Option<u32>,
        #[arg(long)]
        start: Option<String>,
        #[arg(long)]
        password: Option<String>,
    },
    /// Update a meeting
    Update {
        id: u64,
        #[arg(long)]
        topic: Option<String>,
        #[arg(long)]
        duration: Option<u32>,
        #[arg(long)]
        start: Option<String>,
    },
    /// Delete a meeting
    Delete { id: u64 },
    /// End a live meeting
    End { id: u64 },
    /// List participants from a past meeting
    Participants {
        /// Meeting ID or UUID
        meeting_id: String,
    },
    /// Get meeting invitation text
    Invite { id: u64 },
}

#[derive(Subcommand)]
enum RecordingsCommand {
    /// List cloud recordings for a user
    List {
        #[arg(long, default_value = "me")]
        user: String,
        #[arg(long)]
        from: Option<String>,
        #[arg(long)]
        to: Option<String>,
    },
    /// Get recording details for a meeting
    Get {
        /// Meeting ID or UUID
        meeting_id: String,
    },
    /// Download recording files for a meeting
    Download {
        /// Meeting ID or UUID
        meeting_id: String,
        #[arg(long, default_value = ".")]
        out: String,
    },
    /// Delete all cloud recordings for a meeting
    Delete {
        /// Meeting ID or UUID
        meeting_id: String,
        /// Permanently delete instead of moving to trash (irreversible)
        #[arg(long)]
        permanent: bool,
    },
    /// Start cloud recording for a live meeting
    Start {
        /// Numeric meeting ID of the live meeting
        meeting_id: u64,
    },
    /// Stop cloud recording for a live meeting
    Stop {
        /// Numeric meeting ID of the live meeting
        meeting_id: u64,
    },
    /// Pause cloud recording for a live meeting
    Pause {
        /// Numeric meeting ID of the live meeting
        meeting_id: u64,
    },
    /// Resume cloud recording for a live meeting
    Resume {
        /// Numeric meeting ID of the live meeting
        meeting_id: u64,
    },
    /// Download transcript files (VTT/chat) for a meeting
    Transcript {
        /// Meeting ID or UUID
        meeting_id: String,
        #[arg(long, default_value = ".")]
        out: String,
    },
}

#[derive(Subcommand)]
enum UsersCommand {
    /// List users in the account
    List {
        #[arg(long)]
        status: Option<String>,
    },
    /// Get a user by ID or email
    Get { id_or_email: String },
    /// Get the current user
    Me,
    /// Create a new user
    Create {
        #[arg(long)]
        email: String,
        #[arg(long)]
        first_name: Option<String>,
        #[arg(long)]
        last_name: Option<String>,
        /// User type: 1=Basic, 2=Licensed, 3=On-prem
        #[arg(long, default_value = "1")]
        r#type: u8,
    },
    /// Deactivate a user
    Deactivate { id_or_email: String },
    /// Activate (reactivate) a user
    Activate { id_or_email: String },
}

#[derive(Subcommand)]
enum WebinarsCommand {
    /// List webinars for a user
    List {
        #[arg(long, default_value = "me")]
        user: String,
    },
    /// Get a webinar by ID
    Get { id: u64 },
}

#[derive(Subcommand)]
enum ReportsCommand {
    /// Meeting summary report for a user
    Meetings {
        #[arg(long, default_value = "me")]
        user: String,
        /// Start date (YYYY-MM-DD)
        #[arg(long)]
        from: String,
        /// End date (YYYY-MM-DD, default: today)
        #[arg(long)]
        to: Option<String>,
    },
    /// Participant report for a past meeting
    Participants {
        /// Meeting ID or UUID
        meeting_id: String,
    },
}

#[tokio::main]
async fn main() {
    let cli = Cli::parse();
    let out = OutputConfig::new(cli.json, cli.quiet);

    // These commands do not require credentials.
    match &cli.command {
        Command::Config(ConfigCommand::Show) => {
            commands::config::show(cli.profile.as_deref(), &out);
            return;
        }
        Command::Config(ConfigCommand::Delete { profile, force }) => {
            if let Err(e) = commands::config::delete(profile, *force, &out) {
                eprintln!("{e}");
                std::process::exit(exit_codes::for_error(&e));
            }
            return;
        }
        Command::Init { profile } => {
            if let Err(e) = commands::init::init(profile.clone()).await {
                eprintln!("{e}");
                std::process::exit(exit_codes::for_error(&e));
            }
            return;
        }
        Command::Schema { resource } => {
            commands::schema(resource, &out);
            return;
        }
        Command::Completions { shell } => {
            clap_complete::generate(*shell, &mut Cli::command(), "zoom", &mut std::io::stdout());
            return;
        }
        _ => {}
    }

    let cfg = match Config::load(cli.profile) {
        Ok(c) => c,
        Err(e) => {
            eprintln!("{e}");
            std::process::exit(exit_codes::CONFIG_ERROR);
        }
    };

    let mut client = api::ZoomClient::new(cfg.account_id, cfg.client_id, cfg.client_secret);

    let result = match cli.command {
        Command::Meetings(cmd) => match cmd {
            MeetingsCommand::List { user, r#type } => {
                commands::meetings::list(&mut client, &out, &user, r#type.as_deref()).await
            }
            MeetingsCommand::Get { id } => commands::meetings::get(&mut client, &out, id).await,
            MeetingsCommand::Create {
                topic,
                duration,
                start,
                password,
            } => {
                commands::meetings::create(&mut client, &out, topic, duration, start, password)
                    .await
            }
            MeetingsCommand::Update {
                id,
                topic,
                duration,
                start,
            } => commands::meetings::update(&mut client, &out, id, topic, duration, start).await,
            MeetingsCommand::Delete { id } => {
                commands::meetings::delete(&mut client, &out, id).await
            }
            MeetingsCommand::End { id } => commands::meetings::end(&mut client, &out, id).await,
            MeetingsCommand::Participants { meeting_id } => {
                commands::meetings::participants(&mut client, &out, &meeting_id).await
            }
            MeetingsCommand::Invite { id } => {
                commands::meetings::invite(&mut client, &out, id).await
            }
        },
        Command::Recordings(cmd) => match cmd {
            RecordingsCommand::List { user, from, to } => {
                commands::recordings::list(&mut client, &out, &user, from.as_deref(), to.as_deref())
                    .await
            }
            RecordingsCommand::Get { meeting_id } => {
                commands::recordings::get(&mut client, &out, &meeting_id).await
            }
            RecordingsCommand::Download {
                meeting_id,
                out: out_dir,
            } => commands::recordings::download(&mut client, &out, &meeting_id, &out_dir).await,
            RecordingsCommand::Start { meeting_id } => {
                commands::recordings::control(&mut client, &out, meeting_id, "start").await
            }
            RecordingsCommand::Stop { meeting_id } => {
                commands::recordings::control(&mut client, &out, meeting_id, "stop").await
            }
            RecordingsCommand::Pause { meeting_id } => {
                commands::recordings::control(&mut client, &out, meeting_id, "pause").await
            }
            RecordingsCommand::Resume { meeting_id } => {
                commands::recordings::control(&mut client, &out, meeting_id, "resume").await
            }
            RecordingsCommand::Delete {
                meeting_id,
                permanent,
            } => commands::recordings::delete(&mut client, &out, &meeting_id, !permanent).await,
            RecordingsCommand::Transcript {
                meeting_id,
                out: out_dir,
            } => commands::recordings::transcript(&mut client, &out, &meeting_id, &out_dir).await,
        },
        Command::Users(cmd) => match cmd {
            UsersCommand::List { status } => {
                commands::users::list(&mut client, &out, status.as_deref()).await
            }
            UsersCommand::Get { id_or_email } => {
                commands::users::get(&mut client, &out, &id_or_email).await
            }
            UsersCommand::Me => commands::users::me(&mut client, &out).await,
            UsersCommand::Create {
                email,
                first_name,
                last_name,
                r#type,
            } => {
                commands::users::create(&mut client, &out, email, first_name, last_name, r#type)
                    .await
            }
            UsersCommand::Deactivate { id_or_email } => {
                commands::users::deactivate(&mut client, &out, &id_or_email).await
            }
            UsersCommand::Activate { id_or_email } => {
                commands::users::activate(&mut client, &out, &id_or_email).await
            }
        },
        Command::Reports(cmd) => match cmd {
            ReportsCommand::Meetings { user, from, to } => {
                commands::reports::meetings(&mut client, &out, &user, &from, to.as_deref()).await
            }
            ReportsCommand::Participants { meeting_id } => {
                commands::reports::participants(&mut client, &out, &meeting_id).await
            }
        },
        Command::Webinars(cmd) => match cmd {
            WebinarsCommand::List { user } => {
                commands::webinars::list(&mut client, &out, &user).await
            }
            WebinarsCommand::Get { id } => commands::webinars::get(&mut client, &out, id).await,
        },
        Command::Config(ConfigCommand::Show | ConfigCommand::Delete { .. })
        | Command::Init { .. }
        | Command::Schema { .. }
        | Command::Completions { .. } => {
            unreachable!()
        }
    };

    if let Err(e) = result {
        eprintln!("{e}");
        std::process::exit(exit_codes::for_error(&e));
    }
}