Skip to main content

txtx_cloud/
lib.rs

1use clap::{Parser, ValueEnum};
2
3pub mod auth;
4pub mod gql;
5pub mod login;
6pub mod publish;
7pub mod router;
8pub mod workspace;
9
10#[derive(Parser, PartialEq, Clone, Debug, Default)]
11pub struct LoginCommand {
12    /// The username to use for authentication
13    #[arg(long = "email", short = 'e', requires = "password", conflicts_with = "pat")]
14    pub email: Option<String>,
15
16    /// The password to use for authentication
17    #[arg(long = "password", short = 'p', requires = "email", conflicts_with = "pat")]
18    pub password: Option<String>,
19
20    /// Automatically log in using a Personal Access Token
21    #[arg(long = "pat", conflicts_with_all = &["email", "password"])]
22    pub pat: Option<String>,
23}
24
25#[derive(Parser, PartialEq, Clone, Debug)]
26pub struct PublishRunbook {
27    /// Path to the manifest
28    #[arg(long = "manifest-file-path", short = 'm', default_value = "./txtx.yml")]
29    pub manifest_path: String,
30    /// Name of the runbook as indexed in the txtx.yml, or the path of the .tx file to run
31    pub runbook: String,
32    /// Choose the environment variable to set from those configured in the txtx.yml
33    #[arg(long = "env")]
34    pub environment: Option<String>,
35    /// A set of inputs to use for batch processing
36    #[arg(long = "input")]
37    pub inputs: Vec<String>,
38    /// The destination to publish the runbook to. By default, the published runbook will be at /manifest/path/<runbook-id>.output.json
39    #[arg(long = "destination", short = 'd')]
40    pub destination: Option<String>,
41    /// The permissions to set for what users can read the runbook.
42    ///  - `public`: Anyone can read the runbook
43    ///  - `private`: Only the owner can read the runbook
44    ///  - `org`: Only members of the organization can read the runbook
45    #[arg(long = "read-permissions", default_value = "private")]
46    pub read_permissions: Option<PublishRunbookReadPermissions>,
47    /// The permissions to set for what users can update the runbook.
48    ///  - `private`: Only the owner can update the runbook
49    ///  - `org`: Only members of the organization can update the runbook
50    #[arg(long = "update-permissions", default_value = "private")]
51    pub update_permissions: Option<PublishRunbookWritePermissions>,
52    /// The permissions to set for what users can delete the runbook.
53    ///  - `private`: Only the owner can delete the runbook
54    ///  - `org`: Only members of the organization can delete the runbook
55    #[arg(long = "delete-permissions", default_value = "private")]
56    pub delete_permissions: Option<PublishRunbookWritePermissions>,
57}
58
59#[derive(ValueEnum, PartialEq, Clone, Debug)]
60#[clap(rename_all = "snake-case")]
61pub enum PublishRunbookReadPermissions {
62    Public,
63    Private,
64    Org,
65}
66
67#[derive(ValueEnum, PartialEq, Clone, Debug)]
68#[clap(rename_all = "snake-case")]
69pub enum PublishRunbookWritePermissions {
70    Private,
71    Org,
72}