Skip to content

Conversation

@joseba-altran
Copy link

This PR includes changes to address the following problems with the update_component method in azure.digitaltwins.core.DigitalTwinsClient:

  • adt_client.update_component(dt_id, component_path, patch) results in a TypeError stating that requests does not include a param named if_match.
  • The definition of how the patch should be created, as stated in README.md is not valid.
  • Also, the docstring in the method has an incorrect type.

Please note that these issues also affect the package available in PyPI right now.

The sample code below works as expected for me after applying the changes in this PR:

import os
from azure.identity import DefaultAzureCredential
from azure.digitaltwins.core import DigitalTwinsClient

# AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET & AZURE_ADT_URL must be env vars
credential = DefaultAzureCredential()
adt_client = DigitalTwinsClient(os.getenv('AZURE_ADT_URL'), credential)

patch = [{"op": "replace",
                    "path": "/mass",
                    "value": -42.42}]
adt_client.update_component('InitialChamber_1', 'Weight', patch)

Please let me know if you need any more information.

  * It is passed downstream and causes the final request to fail with a TypeError
  * Removed the etag and match_condition variables, which are not needed anymore.
  * Updated the docstring to reflect the correct type for the JSON Patch
  * Changed README.md to reflect the correct format for the JSON Patch
@ghost ghost added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Oct 30, 2020
@ghost
Copy link

ghost commented Oct 30, 2020

Thank you for your contribution joseba-altran! We will review the pull request and get back to you soon.

@annatisch
Copy link
Member

@zolvarga - could you take a look at this issue/patch to confirm the expect service behaviour?

@joseba-altran
Copy link
Author

joseba-altran commented Nov 5, 2020 via email

@joseba-altran
Copy link
Author

In fact, I have not tested other methods, but I see a lot of calls passing the if_match kwarg, I am not sure if those will work too or not but I suspect they won't.

@annatisch
Copy link
Member

Thanks so much for investigating this @joseba-altran!
I have merged another PR here (#15157) which should resolve all the if-match parameter issues.
I will leave this PR open until we have also corrected all the samples/readme snippets accordingly.

@joseba-altran
Copy link
Author

Thank you very much, @annatisch! Happy to help :)

@annatisch
Copy link
Member

Thanks @joseba-altran - all these fixes have been made and released :)

@annatisch annatisch closed this Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported Issues that are reported by GitHub users external to the Azure organization. Digital Twins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants