Skip to content

Commit

Permalink
update 412 handler and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyan99 committed Sep 10, 2019
1 parent 6f13c4a commit 30c63ac
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,16 @@ async def get_key_value(self, key, label=None, accept_datetime=None, if_match=No
if accept_datetime is not None:
header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct and send request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 304, 404, 412]:
if response.status_code not in [200, 304, 404]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down Expand Up @@ -407,9 +407,9 @@ async def put_key_value(self, key, label=None, entity=None, if_match=None, if_no
if self._config.sync_token is not None:
header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct body
if entity is not None:
Expand All @@ -422,7 +422,7 @@ async def put_key_value(self, key, label=None, entity=None, if_match=None, if_no
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 412]:
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down Expand Up @@ -480,14 +480,14 @@ async def delete_key_value(self, key, label=None, if_match=None, *, cls=None, **
if self._config.sync_token is not None:
header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')

# Construct and send request
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 204, 412]:
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down Expand Up @@ -556,16 +556,16 @@ async def check_key_value(self, key, label=None, accept_datetime=None, if_match=
if accept_datetime is not None:
header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct and send request
request = self._client.head(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 304, 404, 412]:
if response.status_code not in [200, 304, 404]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -755,16 +755,16 @@ async def put_lock(self, key, label=None, if_match=None, if_none_match=None, *,
if self._config.sync_token is not None:
header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct and send request
request = self._client.put(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 404, 412]:
if response.status_code not in [200, 404]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down Expand Up @@ -825,16 +825,16 @@ async def delete_lock(self, key, label=None, if_match=None, if_none_match=None,
if self._config.sync_token is not None:
header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct and send request
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 404, 412]:
if response.status_code not in [200, 404]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,16 @@ def get_key_value(self, key, label=None, accept_datetime=None, if_match=None, if
if accept_datetime is not None:
header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct and send request
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 304, 404, 412]:
if response.status_code not in [200, 304, 404]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down Expand Up @@ -406,9 +406,9 @@ def put_key_value(self, key, label=None, entity=None, if_match=None, if_none_mat
if self._config.sync_token is not None:
header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct body
if entity is not None:
Expand All @@ -421,7 +421,7 @@ def put_key_value(self, key, label=None, entity=None, if_match=None, if_none_mat
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 412]:
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down Expand Up @@ -479,14 +479,14 @@ def delete_key_value(self, key, label=None, if_match=None, cls=None, **kwargs):
if self._config.sync_token is not None:
header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')

# Construct and send request
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 204, 412]:
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down Expand Up @@ -555,16 +555,16 @@ def check_key_value(self, key, label=None, accept_datetime=None, if_match=None,
if accept_datetime is not None:
header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct and send request
request = self._client.head(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 304, 404, 412]:
if response.status_code not in [200, 304, 404]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -753,16 +753,16 @@ def put_lock(self, key, label=None, if_match=None, if_none_match=None, cls=None,
if self._config.sync_token is not None:
header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct and send request
request = self._client.put(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 404, 412]:
if response.status_code not in [200, 404]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down Expand Up @@ -823,16 +823,16 @@ def delete_lock(self, key, label=None, if_match=None, if_none_match=None, cls=No
if self._config.sync_token is not None:
header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str')
if if_match is not None:
header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str')
header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str')
if if_none_match is not None:
header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str')
header_parameters['if-none-match'] = self._serialize.header("if_none_match", if_none_match, 'str')

# Construct and send request
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

if response.status_code not in [200, 404, 412]:
if response.status_code not in [200, 404]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise models.ErrorException(response, self._deserialize)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ async def update_configuration_setting(
label=label
)

if key_value is None:
return None

if value is not None:
key_value.value = value
content_type = kwargs.get("content_type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ def update_configuration_setting(
label=label
)

if key_value is None:
return None

if value is not None:
key_value.value = value
content_type = kwargs.get("content_type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def __init__(self, **kwargs):
def _from_key_value(cls, key_value):
# type: (_models.KeyValue) -> ConfigurationSetting
"""Construct a DeletedKey from an autorest-generated DeletedKeyBundle"""
if key_value is None:
return None
return cls(
key=key_value.key,
label=key_value.label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ def test_appconfig_client_sample(self):
# [START list_configuration_setting]
from datetime import datetime, timedelta

accept_date_time = datetime.today() + timedelta(days=-1)
accept_datetime = datetime.today() + timedelta(days=-1)

all_listed = client.list_configuration_settings()
for item in all_listed:
pass # do something

filtered_listed = client.list_configuration_settings(
labels=["*Labe*"], keys=["*Ke*"], accept_date_time=accept_date_time
labels=["*Labe*"], keys=["*Ke*"], accept_datetime=accept_datetime
)
for item in filtered_listed:
pass # do something
Expand All @@ -110,14 +110,14 @@ def test_appconfig_client_sample(self):
# [START list_revisions]
from datetime import datetime, timedelta

accept_date_time = datetime.today() + timedelta(days=-1)
accept_datetime = datetime.today() + timedelta(days=-1)

all_revisions = client.list_configuration_settings()
for item in all_revisions:
pass # do something

filtered_revisions = client.list_revisions(
labels=["*Labe*"], keys=["*Ke*"], accept_date_time=accept_date_time
labels=["*Labe*"], keys=["*Ke*"], accept_datetime=accept_datetime
)
for item in filtered_revisions:
pass # do something
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def __init__(self, obj):
self.obj = obj

def get_configuration_setting(
self, key, label=None, accept_date_time=None, **kwargs
self, key, label=None, accept_datetime=None, **kwargs
):
return get_event_loop().run_until_complete(
self.obj.get_configuration_setting(
key, label=label, accept_date_time=accept_date_time, **kwargs
key, label=label, accept_datetime=accept_datetime, **kwargs
)
)

Expand All @@ -48,24 +48,24 @@ def delete_configuration_setting(self, key, label=None, etag=None, **kwargs):
)

def list_configuration_settings(
self, labels=None, keys=None, accept_date_time=None, fields=None, **kwargs
self, labels=None, keys=None, accept_datetime=None, fields=None, **kwargs
):
paged = self.obj.list_configuration_settings(
labels=labels,
keys=keys,
accept_date_time=accept_date_time,
accept_datetime=accept_datetime,
fields=fields,
**kwargs
)
return _to_list(paged)

def list_revisions(
self, labels=None, keys=None, accept_date_time=None, fields=None, **kwargs
self, labels=None, keys=None, accept_datetime=None, fields=None, **kwargs
):
paged = self.obj.list_revisions(
labels=labels,
keys=keys,
accept_date_time=accept_date_time,
accept_datetime=accept_datetime,
fields=fields,
**kwargs
)
Expand Down
Loading

0 comments on commit 30c63ac

Please sign in to comment.