Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

from ._digitaltwins_client import DigitalTwinsClient
from ._generated.models import DigitalTwinsModelData
from ._generated.models import QueryResult
from ._generated.models import IncomingRelationship
from ._generated.models import DigitalTwinsEventRoute

__all__ = [
'DigitalTwinsClient',
'DigitalTwinsModelData',
'QueryResult',
'IncomingRelationship',
'DigitalTwinsEventRoute'
]
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def add(

if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize(models.ErrorResponse, response)
error = self._deserialize(self.models.ErrorResponse, response)
raise HttpResponseError(response=response, model=error)

deserialized = self._deserialize('[DigitalTwinsModelData]', pipeline_response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def add(

if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize(models.ErrorResponse, response)
error = self._deserialize(self.models.ErrorResponse, response)
raise HttpResponseError(response=response, model=error)

deserialized = self._deserialize('[DigitalTwinsModelData]', pipeline_response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,41 @@
# -------------------------------------------------------------------------

from azure.core import MatchConditions
from azure.core.exceptions import (
ResourceExistsError,
ResourceModifiedError,
ResourceNotModifiedError)

def quote_etag(etag):
if not etag or etag == "*":
return etag
if etag.startswith('"') and etag.endswith('"'):
return etag
if etag.startswith("'") and etag.endswith("'"):
return etag
return '"' + etag + '"'

def prep_if_match(etag, match_condition):
# type: (str, MatchConditions) -> Optional[str]
error_map = {}
if match_condition == MatchConditions.IfNotModified:
if_match = quote_etag(etag) if etag else None
return if_match
if not etag:
raise ValueError("The 'IfNotModified' match condition must be paired with an etag.")
error_map[412] = ResourceModifiedError
return etag, error_map
if match_condition == MatchConditions.IfPresent:
return "*"
return None
if etag:
raise ValueError("An etag value cannot be paired with the 'IfPresent' match condition.")
return "*", error_map
if match_condition != MatchConditions.Unconditionally:
raise ValueError("Unsupported match condition: {}".format(match_condition))
return None, error_map

def prep_if_none_match(etag, match_condition):
# type: (str, MatchConditions) -> Optional[str]
error_map = {}
if match_condition == MatchConditions.IfModified:
if_none_match = quote_etag(etag) if etag else None
return if_none_match
error_map[412] = ResourceNotModifiedError
if not etag:
raise ValueError("The 'IfModified' match condition must be paired with an etag.")
return etag, error_map
if match_condition == MatchConditions.IfMissing:
return "*"
return None
error_map[412] = ResourceExistsError
if etag:
raise ValueError("An etag value cannot be paired with the 'IfMissing' match condition.")
return "*", error_map
if match_condition != MatchConditions.Unconditionally:
raise ValueError("Unsupported match condition: {}".format(match_condition))
return None, error_map
Loading