Skip to content

Commit

Permalink
Upgrade azure-mgmt-search to 8.0.0 (#896)
Browse files Browse the repository at this point in the history
* Upgrade azure-mgmt-search to 8.0.0

* small change
  • Loading branch information
Fred-sun authored Jul 12, 2022
1 parent 996f51b commit 845171d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions plugins/module_utils/azure_rm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,7 @@ def search_client(self):
if not self._search_client:
self._search_client = self.get_mgmt_svc_client(SearchManagementClient,
base_url=self._cloud_environment.endpoints.resource_manager,
is_track2=True,
api_version='2020-08-01')
return self._search_client

Expand Down
18 changes: 9 additions & 9 deletions plugins/modules/azure_rm_cognitivesearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase

try:
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
except ImportError:
# This is handled in azure_rm_common
pass
Expand Down Expand Up @@ -304,7 +304,7 @@ def get_search(self):

try:
search_obj = self.search_client.services.get(self.resource_group, self.name)
except CloudError:
except ResourceNotFoundError:
pass

if search_obj:
Expand Down Expand Up @@ -361,9 +361,9 @@ def create_search(self):
)

try:
poller = self.search_client.services.create_or_update(self.resource_group, self.name, search_model)
poller = self.search_client.services.begin_create_or_update(self.resource_group, self.name, search_model)
self.get_poller_result(poller)
except CloudError as e:
except Exception as e:
self.log('Error creating Azure Search.')
self.fail("Failed to create Azure Search: {0}".format(str(e)))

Expand Down Expand Up @@ -406,7 +406,7 @@ def update_search(self):
self.results['changed'] = True
search_update_model.partition_count = self.partition_count

if self.public_network_access and self.account_dict.get('public_network_access') != self.public_network_access:
if self.public_network_access and self.account_dict.get('public_network_access').lower() != self.public_network_access.lower():
self.results['changed'] = True
search_update_model.public_network_access = self.public_network_access

Expand All @@ -425,9 +425,9 @@ def update_search(self):

try:
if self.results['changed']:
poller = self.search_client.services.create_or_update(self.resource_group, self.name, search_update_model)
poller = self.search_client.services.begin_create_or_update(self.resource_group, self.name, search_update_model)
self.get_poller_result(poller)
except CloudError as e:
except Exception as e:
self.fail("Failed to update the search: {0}".format(str(e)))

return self.get_search()
Expand All @@ -439,14 +439,14 @@ def delete_search(self):
if self.account_dict is not None:
self.results['changed'] = True
self.search_client.services.delete(self.resource_group, self.name)
except CloudError as e:
except Exception as e:
self.fail("Failed to delete the search: {0}".format(str(e)))

def check_name_availability(self):
self.log('Checking name availability for {0}'.format(self.name))
try:
response = self.search_client.services.check_name_availability(self.name)
except CloudError as e:
except Exception as e:
self.log('Error attempting to validate name.')
self.fail("Error checking name availability: {0}".format(str(e)))
if not response.is_name_available:
Expand Down
8 changes: 4 additions & 4 deletions plugins/modules/azure_rm_cognitivesearch_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase

try:
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
except ImportError:
# This is handled in azure_rm_common
pass
Expand Down Expand Up @@ -228,7 +228,7 @@ def get_search(self):

try:
search_obj = self.search_client.services.get(self.resource_group, self.name)
except CloudError:
except ResourceNotFoundError:
pass

if search_obj:
Expand All @@ -243,7 +243,7 @@ def list_resource_group(self):

try:
search_obj = self.search_client.services.list_by_resource_group(self.resource_group)
except CloudError:
except Exception:
pass

if search_obj:
Expand All @@ -260,7 +260,7 @@ def list_all(self):

try:
search_obj = self.search_client.services.list_by_subscription()
except CloudError:
except Exception:
pass

if search_obj:
Expand Down
2 changes: 1 addition & 1 deletion requirements-azure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ azure-mgmt-privatedns==0.1.0
azure-mgmt-redis==13.0.0
azure-mgmt-resource==10.2.0
azure-mgmt-rdbms==1.9.0
azure-mgmt-search==3.0.0
azure-mgmt-search==8.0.0
azure-mgmt-servicebus==0.5.3
azure-mgmt-sql==3.0.1
azure-mgmt-storage==19.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
- search_info.state.replica_count == 1
- search_info.state.sku == "basic"
- search_info.state.provisioning_state == "succeeded"
- search_info.state.public_network_access == "enabled"
- search_info.state.public_network_access == "Enabled"
- search_info.state.status == "running"

- name: Get info for Azure Search
Expand All @@ -112,7 +112,7 @@
- search_info_module.search.replica_count == 1
- search_info_module.search.sku == "basic"
- search_info_module.search.provisioning_state == "succeeded"
- search_info_module.search.public_network_access == "enabled"
- search_info_module.search.public_network_access == "Enabled"
- search_info_module.search.status == "running"

- name: Update basic Azure Search (Idempotence)
Expand Down

0 comments on commit 845171d

Please sign in to comment.