Skip to content

Commit 6c1f804

Browse files
authored
{Storage} Remove azure-mgmt-storage multiapi references (#31526)
1 parent 39d7517 commit 6c1f804

21 files changed

+112
-220
lines changed

src/azure-cli-core/azure/cli/core/profiles/_shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def default_api_version(self):
155155

156156
AZURE_API_PROFILES = {
157157
'latest': {
158-
ResourceType.MGMT_STORAGE: '2024-01-01',
158+
ResourceType.MGMT_STORAGE: None,
159159
ResourceType.MGMT_NETWORK: '2022-01-01',
160160
ResourceType.MGMT_COMPUTE: SDKProfile('2024-11-01', {
161161
'resource_skus': '2019-04-01',

src/azure-cli/azure/cli/command_modules/storage/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ def register_common_storage_account_options(self):
133133
arg_type=get_three_state_flag())
134134
self.argument('sku', help='The storage account SKU.', arg_type=get_enum_type(t_sku_name))
135135
self.argument('assign_identity', action='store_true', resource_type=ResourceType.MGMT_STORAGE,
136-
min_api='2017-06-01',
137136
help='Generate and assign a new Storage Account Identity for this storage account for use '
138137
'with key management services like Azure KeyVault.')
139138
self.argument('access_tier', arg_type=get_enum_type(t_access_tier),
@@ -146,7 +145,7 @@ def register_common_storage_account_options(self):
146145
encryption_choices = list(
147146
t_encryption_services._attribute_map.keys()) # pylint: disable=protected-access
148147
self.argument('encryption_services', arg_type=get_enum_type(encryption_choices),
149-
resource_type=ResourceType.MGMT_STORAGE, min_api='2016-12-01', nargs='+',
148+
resource_type=ResourceType.MGMT_STORAGE, nargs='+',
150149
validator=validate_encryption_services, help='Specifies which service(s) to encrypt.')
151150

152151
def register_precondition_options(self, prefix=''):

src/azure-cli/azure/cli/command_modules/storage/_params.py

Lines changed: 71 additions & 87 deletions
Large diffs are not rendered by default.

src/azure-cli/azure/cli/command_modules/storage/commands.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,24 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
109109
g.show_command('show', 'get_properties')
110110
g.custom_command('list', 'list_storage_accounts')
111111
g.custom_command(
112-
'show-usage', 'show_storage_account_usage', min_api='2018-02-01')
113-
g.custom_command(
114-
'show-usage', 'show_storage_account_usage_no_location', max_api='2017-10-01')
112+
'show-usage', 'show_storage_account_usage')
115113
g.custom_command('show-connection-string',
116114
'show_storage_account_connection_string')
117115
g.generic_update_command('update', getter_name='get_properties', setter_name='update',
118-
custom_func_name='update_storage_account', min_api='2016-12-01')
119-
g.custom_command('failover', 'begin_failover', supports_no_wait=True, is_preview=True, min_api='2018-07-01')
116+
custom_func_name='update_storage_account')
117+
g.custom_command('failover', 'begin_failover', supports_no_wait=True, is_preview=True)
120118
g.command('hns-migration start', 'begin_hierarchical_namespace_migration',
121-
supports_no_wait=True, min_api='2021-06-01')
119+
supports_no_wait=True)
122120
g.command('hns-migration stop', 'begin_abort_hierarchical_namespace_migration',
123-
supports_no_wait=True, min_api='2021-06-01')
121+
supports_no_wait=True)
124122

125123
with self.command_group('storage account', storage_account_sdk_keys, resource_type=ResourceType.MGMT_STORAGE,
126124
custom_command_type=storage_account_custom_type) as g:
127125
g.custom_command('keys renew', 'regenerate_key',
128126
transform=lambda x: getattr(x, 'keys', x))
129127
g.command('keys list', 'list_keys',
130128
transform=lambda x: getattr(x, 'keys', x))
131-
g.command('revoke-delegation-keys', 'revoke_user_delegation_keys', min_api='2019-04-01')
129+
g.command('revoke-delegation-keys', 'revoke_user_delegation_keys')
132130

133131
account_blob_service_custom_sdk = get_custom_sdk('account', client_factory=cf_blob_service,
134132
resource_type=ResourceType.DATA_STORAGE_BLOB)
@@ -150,7 +148,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
150148

151149
with self.command_group('storage account blob-inventory-policy', blob_inventory_sdk,
152150
custom_command_type=blob_inventory_custom_type, is_preview=True,
153-
resource_type=ResourceType.MGMT_STORAGE, min_api='2020-08-01-preview') as g:
151+
resource_type=ResourceType.MGMT_STORAGE) as g:
154152
g.custom_command('create', 'create_blob_inventory_policy')
155153
g.generic_update_command('update', getter_name='get_blob_inventory_policy',
156154
getter_type=blob_inventory_custom_type,
@@ -173,7 +171,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
173171

174172
with self.command_group('storage account encryption-scope', encryption_scope_sdk,
175173
custom_command_type=encryption_scope_custom_type,
176-
resource_type=ResourceType.MGMT_STORAGE, min_api='2019-06-01') as g:
174+
resource_type=ResourceType.MGMT_STORAGE) as g:
177175

178176
g.custom_command('create', 'create_encryption_scope')
179177
g.show_command('show', 'get')
@@ -196,7 +194,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
196194
resource_type=ResourceType.MGMT_STORAGE)
197195

198196
with self.command_group('storage account management-policy', management_policy_sdk,
199-
resource_type=ResourceType.MGMT_STORAGE, min_api='2018-11-01',
197+
resource_type=ResourceType.MGMT_STORAGE,
200198
custom_command_type=management_policy_custom_type) as g:
201199
g.custom_show_command('show', 'get_management_policy')
202200
g.custom_command('create', 'create_management_policies')
@@ -208,7 +206,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
208206

209207
with self.command_group('storage account network-rule', storage_account_sdk,
210208
custom_command_type=storage_account_custom_type,
211-
resource_type=ResourceType.MGMT_STORAGE, min_api='2017-06-01') as g:
209+
resource_type=ResourceType.MGMT_STORAGE) as g:
212210
g.custom_command('add', 'add_network_rule')
213211
g.custom_command('list', 'list_network_rules')
214212
g.custom_command('remove', 'remove_network_rule')
@@ -223,7 +221,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
223221
client_factory=cf_or_policy)
224222

225223
with self.command_group('storage account or-policy', or_policy_sdk, is_preview=True,
226-
resource_type=ResourceType.MGMT_STORAGE, min_api='2019-06-01',
224+
resource_type=ResourceType.MGMT_STORAGE,
227225
custom_command_type=or_policy_custom_type) as g:
228226
g.show_command('show', 'get')
229227
g.command('list', 'list')
@@ -232,7 +230,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
232230
g.command('delete', 'delete')
233231

234232
with self.command_group('storage account or-policy rule', or_policy_sdk, is_preview=True,
235-
resource_type=ResourceType.MGMT_STORAGE, min_api='2019-06-01',
233+
resource_type=ResourceType.MGMT_STORAGE,
236234
custom_command_type=or_policy_custom_type) as g:
237235
g.custom_show_command('show', 'get_or_rule')
238236
g.custom_command('list', 'list_or_rules')
@@ -242,7 +240,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
242240

243241
with self.command_group('storage account private-endpoint-connection', private_endpoint_sdk,
244242
custom_command_type=private_endpoint_custom_type, is_preview=True,
245-
resource_type=ResourceType.MGMT_STORAGE, min_api='2019-06-01') as g:
243+
resource_type=ResourceType.MGMT_STORAGE) as g:
246244
from ._validators import validate_private_endpoint_connection_id
247245
g.command('delete', 'delete', confirmation=True, validator=validate_private_endpoint_connection_id)
248246
g.show_command('show', 'get', validator=validate_private_endpoint_connection_id)
@@ -254,12 +252,12 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
254252
with self.command_group('storage account private-link-resource', private_link_resource_sdk,
255253
resource_type=ResourceType.MGMT_STORAGE) as g:
256254
from azure.cli.core.commands.transform import gen_dict_to_list_transform
257-
g.command('list', 'list_by_storage_account', is_preview=True, min_api='2019-06-01',
255+
g.command('list', 'list_by_storage_account', is_preview=True,
258256
transform=gen_dict_to_list_transform(key="value"))
259257

260258
with self.command_group('storage account blob-service-properties', blob_service_mgmt_sdk,
261259
custom_command_type=storage_account_custom_type,
262-
resource_type=ResourceType.MGMT_STORAGE, min_api='2018-07-01') as g:
260+
resource_type=ResourceType.MGMT_STORAGE) as g:
263261
from ._transformers import transform_restore_policy_output
264262
g.show_command('show', 'get_service_properties', transform=transform_restore_policy_output)
265263
g.generic_update_command('update',
@@ -269,7 +267,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
269267
transform=transform_restore_policy_output)
270268

271269
with self.command_group('storage account blob-service-properties cors-rule',
272-
blob_service_mgmt_sdk, resource_type=ResourceType.MGMT_STORAGE, min_api='2022-09-01',
270+
blob_service_mgmt_sdk, resource_type=ResourceType.MGMT_STORAGE,
273271
custom_command_type=get_custom_sdk('account',
274272
client_factory=cf_mgmt_blob_services,
275273
resource_type=ResourceType.MGMT_STORAGE)) as g:
@@ -280,7 +278,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
280278
with self.command_group('storage account file-service-properties', file_service_mgmt_sdk,
281279
custom_command_type=get_custom_sdk('account', client_factory=cf_mgmt_file_services,
282280
resource_type=ResourceType.MGMT_STORAGE),
283-
resource_type=ResourceType.MGMT_STORAGE, min_api='2019-06-01') as g:
281+
resource_type=ResourceType.MGMT_STORAGE) as g:
284282
g.show_command('show', 'get_service_properties')
285283
g.generic_update_command('update',
286284
getter_name='get_service_properties',
@@ -302,7 +300,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
302300

303301
with self.command_group('storage account local-user', local_users_sdk,
304302
custom_command_type=local_users_custom_type,
305-
resource_type=ResourceType.MGMT_STORAGE, min_api='2021-08-01') as g:
303+
resource_type=ResourceType.MGMT_STORAGE) as g:
306304
g.custom_command('create', 'create_local_user')
307305
g.custom_command('update', 'update_local_user')
308306
g.command('delete', 'delete')
@@ -432,7 +430,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
432430

433431
with self.command_group('storage blob', storage_account_sdk, resource_type=ResourceType.MGMT_STORAGE,
434432
custom_command_type=storage_blob_custom_type) as g:
435-
g.custom_command('restore', 'restore_blob_ranges', min_api='2019-06-01', supports_no_wait=True)
433+
g.custom_command('restore', 'restore_blob_ranges', supports_no_wait=True)
436434

437435
with self.command_group('storage blob incremental-copy',
438436
operations_tmpl='azure.multiapi.storage.blob.pageblobservice#PageBlobService.{}',
@@ -560,12 +558,11 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
560558
with self.command_group('storage container-rm', command_type=blob_container_mgmt_sdk,
561559
custom_command_type=get_custom_sdk('blob', cf_blob_container_mgmt,
562560
resource_type=ResourceType.MGMT_STORAGE),
563-
resource_type=ResourceType.MGMT_STORAGE, min_api='2018-02-01') as g:
561+
resource_type=ResourceType.MGMT_STORAGE) as g:
564562
g.custom_command('create', 'create_container_rm')
565563
g.command('delete', 'delete', confirmation=True)
566-
g.generic_update_command('update', setter_name='update', max_api='2019-04-01')
567564
g.generic_update_command('update', setter_name='update', setter_arg_name='blob_container',
568-
custom_func_name='update_container_rm', min_api='2019-06-01')
565+
custom_func_name='update_container_rm')
569566
g.custom_command('list', 'list_container_rm')
570567
g.custom_command('exists', 'container_rm_exists', transform=create_boolean_result_output_transformer('exists'),
571568
table_transformer=transform_boolean_for_table)
@@ -596,12 +593,12 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
596593
custom_command_type=get_custom_sdk('file',
597594
cf_mgmt_file_shares,
598595
resource_type=ResourceType.MGMT_STORAGE),
599-
resource_type=ResourceType.MGMT_STORAGE, min_api='2019-04-01') as g:
596+
resource_type=ResourceType.MGMT_STORAGE) as g:
600597
from ._transformers import transform_share_rm_output
601598
g.custom_command('exists', '_file_share_exists', transform=create_boolean_result_output_transformer('exists'))
602599
g.custom_command('stats', 'get_stats', transform=lambda x: getattr(x, 'share_usage_bytes'))
603600
g.custom_command('restore', 'restore_share_rm')
604-
g.custom_command('snapshot', 'snapshot_share_rm', min_api='2020-08-01-preview', is_preview=True,
601+
g.custom_command('snapshot', 'snapshot_share_rm', is_preview=True,
605602
transform=transform_share_rm_output)
606603

607604
with self.command_group('storage share-rm'):

src/azure-cli/azure/cli/command_modules/storage/operations/blob.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,19 @@ def create_container_rm(cmd, client, container_name, resource_group_name, accoun
6969
account_name=account_name, container_name=container_name):
7070
raise CLIError('The specified container already exists.')
7171

72-
if cmd.supported_api_version(min_api='2019-06-01', resource_type=ResourceType.MGMT_STORAGE):
73-
BlobContainer = cmd.get_models('BlobContainer', resource_type=ResourceType.MGMT_STORAGE)
74-
blob_container = BlobContainer(public_access=public_access,
75-
default_encryption_scope=default_encryption_scope,
76-
deny_encryption_scope_override=deny_encryption_scope_override,
77-
metadata=metadata,
78-
enable_nfs_v3_all_squash=enable_nfs_v3_all_squash,
79-
enable_nfs_v3_root_squash=enable_nfs_v3_root_squash)
80-
if enable_vlw is not None:
81-
ImmutableStorageWithVersioning = cmd.get_models('ImmutableStorageWithVersioning',
82-
resource_type=ResourceType.MGMT_STORAGE)
83-
blob_container.immutable_storage_with_versioning = ImmutableStorageWithVersioning(enabled=enable_vlw)
84-
return client.create(resource_group_name=resource_group_name, account_name=account_name,
85-
container_name=container_name, blob_container=blob_container)
72+
BlobContainer = cmd.get_models('BlobContainer', resource_type=ResourceType.MGMT_STORAGE)
73+
blob_container = BlobContainer(public_access=public_access,
74+
default_encryption_scope=default_encryption_scope,
75+
deny_encryption_scope_override=deny_encryption_scope_override,
76+
metadata=metadata,
77+
enable_nfs_v3_all_squash=enable_nfs_v3_all_squash,
78+
enable_nfs_v3_root_squash=enable_nfs_v3_root_squash)
79+
if enable_vlw is not None:
80+
ImmutableStorageWithVersioning = cmd.get_models('ImmutableStorageWithVersioning',
81+
resource_type=ResourceType.MGMT_STORAGE)
82+
blob_container.immutable_storage_with_versioning = ImmutableStorageWithVersioning(enabled=enable_vlw)
8683
return client.create(resource_group_name=resource_group_name, account_name=account_name,
87-
container_name=container_name, public_access=public_access, metadata=metadata)
84+
container_name=container_name, blob_container=blob_container)
8885

8986

9087
def update_container_rm(cmd, instance, metadata=None, public_access=None,

0 commit comments

Comments
 (0)