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
pub mod create;
pub mod export;
pub mod list;
pub mod symbols;
mod delete;
mod import;
use std::sync::Arc;
use crate::{ClientCore, Result};
use self::create::{NewSystemVariable, VariableCreateBuilder};
use self::delete::VariableDeleteBuilder;
use self::export::SystemVariableExportBuilder;
use self::import::VariableImportBuilder;
use self::list::{SystemVariableList, SystemVariableListBuilder};
use self::symbols::{SystemSymbolList, SystemSymbolListBuilder};
#[derive(Clone, Debug)]
pub struct SystemVariablesClient {
core: ClientCore,
}
impl SystemVariablesClient {
pub(crate) fn new(core: ClientCore) -> Self {
SystemVariablesClient { core }
}
/// # Examples
///
/// Create system variables:
/// ```
/// # use z_osmf::system_variables::create::NewSystemVariable;
/// # async fn example(zosmf: z_osmf::ZOsmf) -> anyhow::Result<()> {
/// let new_variables = [
/// NewSystemVariable::new("var1", "value1", "description of the variable"),
/// NewSystemVariable::new("var2", "value2", "description of the variable"),
/// ];
///
/// zosmf.system_variables()
/// .create("TESTPLEX", "TESTNODE", &new_variables)
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn create<P, S>(
&self,
sysplex: P,
system: S,
new_variables: &[NewSystemVariable],
) -> Result<()>
where
P: std::fmt::Display,
S: std::fmt::Display,
{
VariableCreateBuilder::new(self.core.clone(), sysplex, system, new_variables)
.build()
.await
}
/// # Examples
///
/// Delete system variables:
/// ```
/// # async fn example(zosmf: z_osmf::ZOsmf) -> anyhow::Result<()> {
/// let variable_names = [
/// "var1",
/// "var2",
/// ];
///
/// zosmf.system_variables()
/// .delete("TESTPLEX", "TESTNODE", &variable_names)
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn delete<P, S, N>(&self, sysplex: P, system: S, variable_names: &[N]) -> Result<()>
where
P: std::fmt::Display,
S: std::fmt::Display,
N: std::fmt::Display,
{
let variable_names = variable_names
.iter()
.map(|name| name.to_string())
.collect::<Arc<[_]>>();
VariableDeleteBuilder::new(self.core.clone(), sysplex, system, variable_names)
.build()
.await
}
/// # Examples
///
/// Export system variables to a CSV file and overwrite the file if it already exists:
/// ```
/// # async fn example(zosmf: z_osmf::ZOsmf) -> anyhow::Result<()> {
/// zosmf.system_variables()
/// .export("TESTPLEX", "TESTNODE", "/u/testuser/backup-variables.csv")
/// .overwrite(true)
/// .build()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub fn export<X, S, P>(&self, sysplex: X, system: S, path: P) -> SystemVariableExportBuilder<()>
where
X: std::fmt::Display,
S: std::fmt::Display,
P: std::fmt::Display,
{
SystemVariableExportBuilder::new(self.core.clone(), sysplex, system, path)
}
/// # Examples
///
/// Import system variables from a CSV file:
/// ```
/// # async fn example(zosmf: z_osmf::ZOsmf) -> anyhow::Result<()> {
/// zosmf.system_variables()
/// .import("TESTPLEX", "TESTNODE", "/u/testuser/variables.csv")
/// .await?;
/// # Ok(())
/// # }
/// ```
pub async fn import<X, S, P>(&self, sysplex: X, system: S, path: P) -> Result<()>
where
X: std::fmt::Display,
S: std::fmt::Display,
P: std::fmt::Display,
{
VariableImportBuilder::new(self.core.clone(), sysplex, system, path)
.build()
.await
}
/// # Examples
///
/// List all system variables on the local system:
/// ```
/// # async fn example(zosmf: z_osmf::ZOsmf) -> anyhow::Result<()> {
/// let variables = zosmf.system_variables().list().build().await?;
/// # Ok(())
/// # }
/// ```
///
/// List all system variables on a named system:
/// ```
/// # use z_osmf::system_variables::list::SystemId;
/// # async fn example(zosmf: z_osmf::ZOsmf) -> anyhow::Result<()> {
/// let system_id = SystemId::Named {
/// sysplex: "TESTPLEX".to_string(),
/// system: "TESTNODE".to_string(),
/// };
///
/// let variables = zosmf.system_variables()
/// .list()
/// .system_id(system_id)
/// .build()
/// .await?;
/// # Ok(())
/// # }
/// ```
pub fn list(&self) -> SystemVariableListBuilder<SystemVariableList> {
SystemVariableListBuilder::new(self.core.clone())
}
/// # Examples
///
/// List all system symbols on the local system:
/// ```
/// # async fn example(zosmf: z_osmf::ZOsmf) -> anyhow::Result<()> {
/// let symbols = zosmf.system_variables().symbols().build().await?;
/// # Ok(())
/// # }
/// ```
pub fn symbols(&self) -> SystemSymbolListBuilder<SystemSymbolList> {
SystemSymbolListBuilder::new(self.core.clone())
}
}