Skip to content

Commit 9100642

Browse files
authored
feat: Add support setting Null for nullable args (#1227)
For primitive types (not arrays and not dicts or similar) when resource attribute can be explicitly nullable (while also being optional) it is necessary to allow CLI user to set it to null. The only practical way found till now is to add additional argument: `device_id / no_device_id` which can be used to set explicit null. Neither relying on specific value ("", "null") nor using default value when no value is sustainable looking at the variations of APIs. Change-Id: I6d549ffcc5c51a9c3ed849c590777b5ba4f6d721 Changes are triggered by https://review.opendev.org/949618
1 parent 67d7055 commit 9100642

File tree

123 files changed

+1560
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1560
-0
lines changed

openstack_cli/src/block_storage/v3/backup/create_30.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,18 @@ struct Backup {
6262
#[arg(help_heading = "Body parameters", long)]
6363
container: Option<String>,
6464

65+
/// Set explicit NULL for the container
66+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "container")]
67+
no_container: bool,
68+
6569
/// The backup description or null.
6670
#[arg(help_heading = "Body parameters", long)]
6771
description: Option<String>,
6872

73+
/// Set explicit NULL for the description
74+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "description")]
75+
no_description: bool,
76+
6977
/// Indicates whether to backup, even if the volume is attached. Default is
7078
/// `false`. See [valid boolean values](#valid-boolean-values)
7179
#[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)]
@@ -80,10 +88,18 @@ struct Backup {
8088
#[arg(help_heading = "Body parameters", long)]
8189
name: Option<String>,
8290

91+
/// Set explicit NULL for the name
92+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "name")]
93+
no_name: bool,
94+
8395
/// The UUID of the source snapshot that you want to back up.
8496
#[arg(help_heading = "Body parameters", long)]
8597
snapshot_id: Option<String>,
8698

99+
/// Set explicit NULL for the snapshot_id
100+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "snapshot_id")]
101+
no_snapshot_id: bool,
102+
87103
/// The UUID of the volume that you want to back up.
88104
#[arg(help_heading = "Body parameters", long)]
89105
volume_id: String,
@@ -115,10 +131,14 @@ impl BackupCommand {
115131

116132
if let Some(val) = &args.container {
117133
backup_builder.container(Some(val.into()));
134+
} else if args.no_container {
135+
backup_builder.container(None);
118136
}
119137

120138
if let Some(val) = &args.description {
121139
backup_builder.description(Some(val.into()));
140+
} else if args.no_description {
141+
backup_builder.description(None);
122142
}
123143

124144
if let Some(val) = &args.incremental {
@@ -131,10 +151,14 @@ impl BackupCommand {
131151

132152
if let Some(val) = &args.name {
133153
backup_builder.name(Some(val.into()));
154+
} else if args.no_name {
155+
backup_builder.name(None);
134156
}
135157

136158
if let Some(val) = &args.snapshot_id {
137159
backup_builder.snapshot_id(Some(val.into()));
160+
} else if args.no_snapshot_id {
161+
backup_builder.snapshot_id(None);
138162
}
139163

140164
ep_builder.backup(backup_builder.build().unwrap());

openstack_cli/src/block_storage/v3/backup/create_343.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ struct Backup {
6363
#[arg(help_heading = "Body parameters", long)]
6464
container: Option<String>,
6565

66+
/// Set explicit NULL for the container
67+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "container")]
68+
no_container: bool,
69+
6670
/// The backup description or null.
6771
#[arg(help_heading = "Body parameters", long)]
6872
description: Option<String>,
6973

74+
/// Set explicit NULL for the description
75+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "description")]
76+
no_description: bool,
77+
7078
/// Indicates whether to backup, even if the volume is attached. Default is
7179
/// `false`. See [valid boolean values](#valid-boolean-values)
7280
#[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)]
@@ -87,10 +95,18 @@ struct Backup {
8795
#[arg(help_heading = "Body parameters", long)]
8896
name: Option<String>,
8997

98+
/// Set explicit NULL for the name
99+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "name")]
100+
no_name: bool,
101+
90102
/// The UUID of the source snapshot that you want to back up.
91103
#[arg(help_heading = "Body parameters", long)]
92104
snapshot_id: Option<String>,
93105

106+
/// Set explicit NULL for the snapshot_id
107+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "snapshot_id")]
108+
no_snapshot_id: bool,
109+
94110
/// The UUID of the volume that you want to back up.
95111
#[arg(help_heading = "Body parameters", long)]
96112
volume_id: String,
@@ -122,10 +138,14 @@ impl BackupCommand {
122138

123139
if let Some(val) = &args.container {
124140
backup_builder.container(Some(val.into()));
141+
} else if args.no_container {
142+
backup_builder.container(None);
125143
}
126144

127145
if let Some(val) = &args.description {
128146
backup_builder.description(Some(val.into()));
147+
} else if args.no_description {
148+
backup_builder.description(None);
129149
}
130150

131151
if let Some(val) = &args.incremental {
@@ -138,10 +158,14 @@ impl BackupCommand {
138158

139159
if let Some(val) = &args.name {
140160
backup_builder.name(Some(val.into()));
161+
} else if args.no_name {
162+
backup_builder.name(None);
141163
}
142164

143165
if let Some(val) = &args.snapshot_id {
144166
backup_builder.snapshot_id(Some(val.into()));
167+
} else if args.no_snapshot_id {
168+
backup_builder.snapshot_id(None);
145169
}
146170

147171
if let Some(val) = &args.metadata {

openstack_cli/src/block_storage/v3/backup/create_351.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,26 @@ struct Backup {
6565
#[arg(help_heading = "Body parameters", long)]
6666
availability_zone: Option<String>,
6767

68+
/// Set explicit NULL for the availability_zone
69+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "availability_zone")]
70+
no_availability_zone: bool,
71+
6872
/// The container name or null.
6973
#[arg(help_heading = "Body parameters", long)]
7074
container: Option<String>,
7175

76+
/// Set explicit NULL for the container
77+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "container")]
78+
no_container: bool,
79+
7280
/// The backup description or null.
7381
#[arg(help_heading = "Body parameters", long)]
7482
description: Option<String>,
7583

84+
/// Set explicit NULL for the description
85+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "description")]
86+
no_description: bool,
87+
7688
/// Indicates whether to backup, even if the volume is attached. Default is
7789
/// `false`. See [valid boolean values](#valid-boolean-values)
7890
#[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)]
@@ -93,10 +105,18 @@ struct Backup {
93105
#[arg(help_heading = "Body parameters", long)]
94106
name: Option<String>,
95107

108+
/// Set explicit NULL for the name
109+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "name")]
110+
no_name: bool,
111+
96112
/// The UUID of the source snapshot that you want to back up.
97113
#[arg(help_heading = "Body parameters", long)]
98114
snapshot_id: Option<String>,
99115

116+
/// Set explicit NULL for the snapshot_id
117+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "snapshot_id")]
118+
no_snapshot_id: bool,
119+
100120
/// The UUID of the volume that you want to back up.
101121
#[arg(help_heading = "Body parameters", long)]
102122
volume_id: String,
@@ -128,10 +148,14 @@ impl BackupCommand {
128148

129149
if let Some(val) = &args.container {
130150
backup_builder.container(Some(val.into()));
151+
} else if args.no_container {
152+
backup_builder.container(None);
131153
}
132154

133155
if let Some(val) = &args.description {
134156
backup_builder.description(Some(val.into()));
157+
} else if args.no_description {
158+
backup_builder.description(None);
135159
}
136160

137161
if let Some(val) = &args.incremental {
@@ -144,10 +168,14 @@ impl BackupCommand {
144168

145169
if let Some(val) = &args.name {
146170
backup_builder.name(Some(val.into()));
171+
} else if args.no_name {
172+
backup_builder.name(None);
147173
}
148174

149175
if let Some(val) = &args.snapshot_id {
150176
backup_builder.snapshot_id(Some(val.into()));
177+
} else if args.no_snapshot_id {
178+
backup_builder.snapshot_id(None);
151179
}
152180

153181
if let Some(val) = &args.metadata {
@@ -156,6 +184,8 @@ impl BackupCommand {
156184

157185
if let Some(val) = &args.availability_zone {
158186
backup_builder.availability_zone(Some(val.into()));
187+
} else if args.no_availability_zone {
188+
backup_builder.availability_zone(None);
159189
}
160190

161191
ep_builder.backup(backup_builder.build().unwrap());

openstack_cli/src/block_storage/v3/backup/restore/create.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,16 @@ struct Restore {
6868
#[arg(help_heading = "Body parameters", long)]
6969
name: Option<String>,
7070

71+
/// Set explicit NULL for the name
72+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "name")]
73+
no_name: bool,
74+
7175
#[arg(help_heading = "Body parameters", long)]
7276
volume_id: Option<String>,
77+
78+
/// Set explicit NULL for the volume_id
79+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "volume_id")]
80+
no_volume_id: bool,
7381
}
7482

7583
impl RestoreCommand {

openstack_cli/src/block_storage/v3/backup/set_343.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,19 @@ struct Backup {
7171
#[arg(help_heading = "Body parameters", long)]
7272
description: Option<String>,
7373

74+
/// Set explicit NULL for the description
75+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "description")]
76+
no_description: bool,
77+
7478
#[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::<String, String>)]
7579
metadata: Option<Vec<(String, String)>>,
7680

7781
#[arg(help_heading = "Body parameters", long)]
7882
name: Option<String>,
83+
84+
/// Set explicit NULL for the name
85+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "name")]
86+
no_name: bool,
7987
}
8088

8189
impl BackupCommand {

openstack_cli/src/block_storage/v3/backup/set_39.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,16 @@ struct Backup {
7070
#[arg(help_heading = "Body parameters", long)]
7171
description: Option<String>,
7272

73+
/// Set explicit NULL for the description
74+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "description")]
75+
no_description: bool,
76+
7377
#[arg(help_heading = "Body parameters", long)]
7478
name: Option<String>,
79+
80+
/// Set explicit NULL for the name
81+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "name")]
82+
no_name: bool,
7583
}
7684

7785
impl BackupCommand {

openstack_cli/src/block_storage/v3/group/create_313.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,18 @@ struct Group {
6262
#[arg(help_heading = "Body parameters", long)]
6363
availability_zone: Option<String>,
6464

65+
/// Set explicit NULL for the availability_zone
66+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "availability_zone")]
67+
no_availability_zone: bool,
68+
6569
/// The group description.
6670
#[arg(help_heading = "Body parameters", long)]
6771
description: Option<String>,
6872

73+
/// Set explicit NULL for the description
74+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "description")]
75+
no_description: bool,
76+
6977
/// The group type ID.
7078
#[arg(help_heading = "Body parameters", long)]
7179
group_type: String,
@@ -74,6 +82,10 @@ struct Group {
7482
#[arg(help_heading = "Body parameters", long)]
7583
name: Option<String>,
7684

85+
/// Set explicit NULL for the name
86+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "name")]
87+
no_name: bool,
88+
7789
/// The list of volume types. In an environment with multiple-storage back
7890
/// ends, the scheduler determines where to send the volume based on the
7991
/// volume type. For information about how to use volume types to create
@@ -108,18 +120,24 @@ impl GroupCommand {
108120
let mut group_builder = create_313::GroupBuilder::default();
109121
if let Some(val) = &args.description {
110122
group_builder.description(Some(val.into()));
123+
} else if args.no_description {
124+
group_builder.description(None);
111125
}
112126

113127
group_builder.group_type(&args.group_type);
114128

115129
if let Some(val) = &args.name {
116130
group_builder.name(Some(val.into()));
131+
} else if args.no_name {
132+
group_builder.name(None);
117133
}
118134

119135
group_builder.volume_types(args.volume_types.iter().map(Into::into).collect::<Vec<_>>());
120136

121137
if let Some(val) = &args.availability_zone {
122138
group_builder.availability_zone(Some(val.into()));
139+
} else if args.no_availability_zone {
140+
group_builder.availability_zone(None);
123141
}
124142

125143
ep_builder.group(group_builder.build().unwrap());

openstack_cli/src/block_storage/v3/group/create_from_src_314.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@ struct CreateFromSrc {
5959
#[arg(help_heading = "Body parameters", long)]
6060
description: Option<String>,
6161

62+
/// Set explicit NULL for the description
63+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "description")]
64+
no_description: bool,
65+
6266
#[arg(help_heading = "Body parameters", long)]
6367
group_snapshot_id: Option<String>,
6468

6569
#[arg(help_heading = "Body parameters", long)]
6670
name: Option<String>,
6771

72+
/// Set explicit NULL for the name
73+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "name")]
74+
no_name: bool,
75+
6876
#[arg(help_heading = "Body parameters", long)]
6977
source_group_id: Option<String>,
7078
}
@@ -92,10 +100,14 @@ impl GroupCommand {
92100
let mut create_from_src_builder = create_from_src_314::CreateFromSrcBuilder::default();
93101
if let Some(val) = &args.description {
94102
create_from_src_builder.description(Some(val.into()));
103+
} else if args.no_description {
104+
create_from_src_builder.description(None);
95105
}
96106

97107
if let Some(val) = &args.name {
98108
create_from_src_builder.name(Some(val.into()));
109+
} else if args.no_name {
110+
create_from_src_builder.name(None);
99111
}
100112

101113
if let Some(val) = &args.source_group_id {

openstack_cli/src/block_storage/v3/group/failover_replication_338.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ struct FailoverReplication {
6161

6262
#[arg(help_heading = "Body parameters", long)]
6363
secondary_backend_id: Option<String>,
64+
65+
/// Set explicit NULL for the secondary_backend_id
66+
#[arg(help_heading = "Body parameters", long, action = clap::ArgAction::SetTrue, conflicts_with = "secondary_backend_id")]
67+
no_secondary_backend_id: bool,
6468
}
6569

6670
impl GroupCommand {
@@ -91,6 +95,8 @@ impl GroupCommand {
9195

9296
if let Some(val) = &args.secondary_backend_id {
9397
failover_replication_builder.secondary_backend_id(Some(val.into()));
98+
} else if args.no_secondary_backend_id {
99+
failover_replication_builder.secondary_backend_id(None);
94100
}
95101

96102
ep_builder.failover_replication(failover_replication_builder.build().unwrap());

0 commit comments

Comments
 (0)