Skip to content

Commit c7df407

Browse files
[Storage] Revert addition of 'create_if_not_exists()' for all Python clients (Azure#23857)
1 parent 4c54a6b commit c7df407

File tree

36 files changed

+8
-1611
lines changed

36 files changed

+8
-1611
lines changed

sdk/storage/azure-storage-blob/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## 12.12.0b1 (Unreleased)
44

55
### Features Added
6-
- Added support for `create_container_if_not_exists()` for `BlobContainerClient`
76

87
## 12.11.0 (2022-03-29)
98

sdk/storage/azure-storage-blob/azure/storage/blob/_container_client.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import six
2222

2323
from azure.core import MatchConditions
24-
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError, ResourceExistsError
24+
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
2525
from azure.core.paging import ItemPaged
2626
from azure.core.tracing.decorator import distributed_trace
2727
from azure.core.pipeline import Pipeline
@@ -303,34 +303,6 @@ def create_container(self, metadata=None, public_access=None, **kwargs):
303303
except HttpResponseError as error:
304304
process_storage_error(error)
305305

306-
@distributed_trace
307-
def create_container_if_not_exists(self, **kwargs):
308-
# type: (**Any) -> None
309-
"""
310-
Creates a new container under the specified account. If the container
311-
with the same name already exists, it is not changed.
312-
313-
:keyword Dict[str, str] metadata:
314-
A dict with name_value pairs to associate with the
315-
container as metadata. Example:{'Category':'test'}
316-
:keyword ~azure.storage.blob.PublicAccess public_access:
317-
Possible values include: 'container', 'blob'.
318-
:keyword container_encryption_scope:
319-
Specifies the default encryption scope to set on the container and use for
320-
all future writes.
321-
322-
.. versionadded:: 12.2.0
323-
324-
:paramtype container_encryption_scope: dict or ~azure.storage.blob.ContainerEncryptionScope
325-
:keyword int timeout:
326-
The timeout parameter is expressed in seconds.
327-
:rtype: None
328-
"""
329-
try:
330-
return self.create_container(**kwargs)
331-
except ResourceExistsError:
332-
return None
333-
334306
@distributed_trace
335307
def _rename_container(self, new_name, **kwargs):
336308
# type: (str, **Any) -> ContainerClient

sdk/storage/azure-storage-blob/azure/storage/blob/aio/_container_client_async.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
TYPE_CHECKING
1212
)
1313

14-
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError, ResourceExistsError
14+
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
1515
from azure.core.tracing.decorator import distributed_trace
1616
from azure.core.tracing.decorator_async import distributed_trace_async
1717
from azure.core.async_paging import AsyncItemPaged
@@ -168,34 +168,6 @@ async def create_container(self, metadata=None, public_access=None, **kwargs):
168168
except HttpResponseError as error:
169169
process_storage_error(error)
170170

171-
@distributed_trace_async
172-
async def create_container_if_not_exists(self, **kwargs):
173-
# type: (**Any) -> None
174-
"""
175-
Creates a new container under the specified account. If the container
176-
with the same name already exists, it is not changed.
177-
178-
:keyword Dict[str, str] metadata:
179-
A dict with name_value pairs to associate with the
180-
container as metadata. Example:{'Category':'test'}
181-
:keyword ~azure.storage.blob.PublicAccess public_access:
182-
Possible values include: 'container', 'blob'.
183-
:keyword container_encryption_scope:
184-
Specifies the default encryption scope to set on the container and use for
185-
all future writes.
186-
187-
.. versionadded:: 12.2.0
188-
189-
:paramtype container_encryption_scope: dict or ~azure.storage.blob.ContainerEncryptionScope
190-
:keyword int timeout:
191-
The timeout parameter is expressed in seconds.
192-
:rtype: None
193-
"""
194-
try:
195-
return await self.create_container(**kwargs)
196-
except ResourceExistsError:
197-
return None
198-
199171
@distributed_trace_async
200172
async def _rename_container(self, new_name, **kwargs):
201173
# type: (str, **Any) -> ContainerClient

sdk/storage/azure-storage-blob/tests/recordings/test_container.test_create_container_if_not_exists_with_existing_container.yaml

Lines changed: 0 additions & 79 deletions
This file was deleted.

sdk/storage/azure-storage-blob/tests/recordings/test_container.test_create_container_if_not_exists_without_existing_container.yaml

Lines changed: 0 additions & 40 deletions
This file was deleted.

sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_create_container_if_not_exists_with_existing_container.yaml

Lines changed: 0 additions & 57 deletions
This file was deleted.

sdk/storage/azure-storage-blob/tests/recordings/test_container_async.test_create_container_if_not_exists_without_existing_container.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

sdk/storage/azure-storage-blob/tests/test_container.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,6 @@ def test_create_container_with_already_existing_container_fail_on_exist(self, st
8080
# Assert
8181
self.assertTrue(created)
8282

83-
@BlobPreparer()
84-
def test_create_container_if_not_exists_without_existing_container(self, storage_account_name, storage_account_key):
85-
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key)
86-
container_name = self._get_container_reference()
87-
88-
# Act
89-
container = bsc.get_container_client(container_name)
90-
created = container.create_container_if_not_exists()
91-
92-
# Assert
93-
self.assertTrue(created)
94-
95-
@BlobPreparer()
96-
def test_create_container_if_not_exists_with_existing_container(self, storage_account_name, storage_account_key):
97-
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key)
98-
container_name = self._get_container_reference()
99-
100-
# Act
101-
container = bsc.get_container_client(container_name)
102-
container.create_container()
103-
created = container.create_container_if_not_exists()
104-
105-
# Assert
106-
self.assertIsNone(created)
107-
10883
@BlobPreparer()
10984
def test_create_container_with_public_access_container(self, storage_account_name, storage_account_key):
11085
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key)

sdk/storage/azure-storage-blob/tests/test_container_async.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -98,33 +98,6 @@ async def test_create_container(self, storage_account_name, storage_account_key)
9898
# Assert
9999
self.assertTrue(created)
100100

101-
@BlobPreparer()
102-
@AsyncStorageTestCase.await_prepared_test
103-
async def test_create_container_if_not_exists_without_existing_container(self, storage_account_name, storage_account_key):
104-
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key)
105-
container_name = self._get_container_reference()
106-
107-
# Act
108-
container = bsc.get_container_client(container_name)
109-
created = await container.create_container_if_not_exists()
110-
111-
# Assert
112-
self.assertTrue(created)
113-
114-
@BlobPreparer()
115-
@AsyncStorageTestCase.await_prepared_test
116-
async def test_create_container_if_not_exists_with_existing_container(self, storage_account_name, storage_account_key):
117-
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key)
118-
container_name = self._get_container_reference()
119-
120-
# Act
121-
container = bsc.get_container_client(container_name)
122-
await container.create_container()
123-
created = await container.create_container_if_not_exists()
124-
125-
# Assert
126-
self.assertIsNone(created)
127-
128101
@BlobPreparer()
129102
@AsyncStorageTestCase.await_prepared_test
130103
async def test_create_cntnr_w_existing_cntnr_fail_on_exist(self, storage_account_name, storage_account_key):

sdk/storage/azure-storage-file-datalake/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## 12.7.0b1 (Unreleased)
44

55
### Features Added
6-
- Added support for `create_file_system_if_not_exists()` for `FileSystemClient`
76

87
### Bugs Fixed
98
- Updated `create_file_system()` docstring to have the correct return-type of `None`

0 commit comments

Comments
 (0)