-
Notifications
You must be signed in to change notification settings - Fork 3.5k
{Resource} Remove direct call to msrestazure
#29959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
0d3aac6
36b6eb0
0cf5cb7
9ce0c1a
2f467a8
989b9c4
767f076
4099a71
dc554ec
6ce4249
c05d2d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
| from urllib.request import urlopen | ||
| from urllib.parse import urlparse, unquote | ||
|
|
||
| from msrestazure.tools import is_valid_resource_id, parse_resource_id | ||
| from azure.mgmt.core.tools import is_valid_resource_id, parse_resource_id | ||
|
|
||
| from azure.mgmt.resource.resources.models import GenericResource, DeploymentMode | ||
|
|
||
|
|
@@ -66,7 +66,7 @@ | |
|
|
||
|
|
||
| def _build_resource_id(**kwargs): | ||
| from msrestazure.tools import resource_id as resource_id_from_dict | ||
| from azure.mgmt.core.tools import resource_id as resource_id_from_dict | ||
| try: | ||
| return resource_id_from_dict(**kwargs) | ||
| except KeyError: | ||
|
|
@@ -3257,7 +3257,7 @@ def create_policy_assignment(cmd, policy=None, policy_set_definition=None, | |
|
|
||
|
|
||
| def _get_resource_id(cli_ctx, val, resource_group, resource_type, resource_namespace): | ||
| from msrestazure.tools import resource_id | ||
| from azure.mgmt.core.tools import resource_id | ||
| if is_valid_resource_id(val): | ||
| return val | ||
|
|
||
|
|
@@ -4522,7 +4522,9 @@ def invoke_action(self, action, request_body): | |
| """ | ||
| Formats Url if none provided and sends the POST request with the url and request-body. | ||
| """ | ||
| from msrestazure.azure_operation import AzureOperationPoller | ||
|
|
||
| from azure.core.polling import LROPoller | ||
| from azure.mgmt.core.polling.arm_polling import ARMPolling | ||
|
|
||
| query_parameters = {} | ||
| serialize = self.rcf.resources._serialize # pylint: disable=protected-access | ||
|
|
@@ -4564,28 +4566,14 @@ def invoke_action(self, action, request_body): | |
| body_content_kwargs = {} | ||
| body_content_kwargs['content'] = json.loads(request_body) if request_body else None | ||
|
|
||
| # Construct and send request | ||
| def long_running_send(): | ||
| request = client.post(url, query_parameters, header_parameters, **body_content_kwargs) | ||
| pipeline_response = client._pipeline.run(request, stream=False) | ||
| return pipeline_response.http_response.internal_response | ||
|
|
||
| def get_long_running_status(status_link, headers=None): | ||
| request = client.get(status_link, query_parameters, header_parameters) | ||
| if headers: | ||
| request.headers.update(headers) | ||
| pipeline_response = client._pipeline.run(request, stream=False) | ||
| return pipeline_response.http_response.internal_response | ||
|
|
||
| def get_long_running_output(response): | ||
| from azure.core.exceptions import HttpResponseError | ||
| if response.status_code not in [200, 202, 204]: | ||
| exp = HttpResponseError(response) | ||
| exp.request_id = response.headers.get('x-ms-request-id') | ||
| raise exp | ||
| return response.text | ||
|
|
||
| return AzureOperationPoller(long_running_send, get_long_running_output, get_long_running_status) | ||
| def deserialization_cb(pipeline_response): | ||
| return json.loads(pipeline_response.http_response.text()) | ||
|
|
||
| request = client.post(url, query_parameters, header_parameters, **body_content_kwargs) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am surprised that SDK has no equivalent function and we have to construct the |
||
| pipeline_response = client._pipeline.run(request, stream=False) | ||
|
|
||
| return LROPoller(client=client, initial_response=pipeline_response, deserialization_callback=deserialization_cb, | ||
| polling_method=ARMPolling(lro_options={"final-state-via": "azure-async-operation"})) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we still obtain the long running status after the migration?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not an expert on this part, but this process seems to be pretty generic. Do we have to re-define the whole LRO process?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is consistent with the previous logic, since there are no functions for it in the SDK, we need to construct them ourselves.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the name
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is an option to choose to get the final URL, I will not specify it and let it decide for itself. |
||
|
|
||
| @staticmethod | ||
| def resolve_api_version(rcf, resource_provider_namespace, parent_resource_path, resource_type, | ||
|
|
||



Uh oh!
There was an error while loading. Please reload this page.