Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into azure_purview_catalog

* 'master' of https://github.com/Azure/azure-sdk-for-python:
  ignore analysis for swagger readmes (Azure#18520)
  [purview] add azure-purview-nspkg (Azure#18518)
  [AppConfiguration] Appconfig consistency (Azure#18493)
  [Container Registry] Improved samples (Azure#18263)
  [Container Registry] renamings (Azure#18492)
  [ServiceBus] internal code rename and sample readme update (Azure#18516)
  [EventHub] update link in sample readme (Azure#18517)
  Post Process Event Names Script (Azure#18419)
  [Tables] use etag from entity if match condition is given (Azure#18271)
  adding operation-location to headers that are scrubbed (Azure#18514)
  • Loading branch information
iscai-msft committed May 5, 2021
2 parents df4be06 + 0c0a08b commit f56089d
Show file tree
Hide file tree
Showing 77 changed files with 8,716 additions and 625 deletions.
3 changes: 2 additions & 1 deletion eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ known_content_issues:
- ['sdk/monitor/azure-monitor-opentelemetry-exporter/README.md', '#4554']
- ['sdk/digitaltwins/azure-digitaltwins-core/swagger/README.md', '#4554']
- ['sdk/textanalytics/azure-ai-textanalytics/swagger/README.md', '#4554']

- ['sdk/purview/azure-purview-catalog/swagger/README.md',  '#4554']
- ['sdk/purview/azure-purview-scanning/swagger/README.md',  '#4554']
- ['sdk/containerregistry/azure-containerregistry/swagger/README.md', '#4554']
- ['sdk/appconfiguration/azure-appconfiguration/swagger/README.md', '#4554']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under the MIT License.
# ------------------------------------
import json
from typing import Dict, Union, List, Any, Optional
from msrest.serialization import Model
from ._generated.models import KeyValue

Expand Down Expand Up @@ -60,18 +61,21 @@ def _from_generated(cls, key_value):
if key_value is None:
return None
if key_value.content_type is not None:
if key_value.content_type.startswith(
FeatureFlagConfigurationSetting._feature_flag_content_type # pylint:disable=protected-access
) and key_value.key.startswith(FeatureFlagConfigurationSetting.key_prefix):
return FeatureFlagConfigurationSetting._from_generated( # pylint: disable=protected-access
key_value
)
if key_value.content_type.startswith(
SecretReferenceConfigurationSetting._secret_reference_content_type # pylint:disable=protected-access
):
return SecretReferenceConfigurationSetting._from_generated( # pylint: disable=protected-access
key_value
)
try:
if key_value.content_type.startswith(
FeatureFlagConfigurationSetting._feature_flag_content_type # pylint:disable=protected-access
) and key_value.key.startswith(FeatureFlagConfigurationSetting.key_prefix):
return FeatureFlagConfigurationSetting._from_generated( # pylint: disable=protected-access
key_value
)
if key_value.content_type.startswith(
SecretReferenceConfigurationSetting._secret_reference_content_type # pylint:disable=protected-access
):
return SecretReferenceConfigurationSetting._from_generated( # pylint: disable=protected-access
key_value
)
except (KeyError, AttributeError, TypeError):
pass

return cls(
key=key_value.key,
Expand Down Expand Up @@ -143,7 +147,7 @@ class FeatureFlagConfigurationSetting(
kind = "FeatureFlag"

def __init__(self, feature_id, enabled, filters=[], **kwargs): # pylint: disable=dangerous-default-value
# type: (str, bool, Optional[List[Dict[str, Any]]]) -> None
# type: (str, bool, Optional[List[Dict[str, Any]]], **Any) -> None
super(FeatureFlagConfigurationSetting, self).__init__(**kwargs)
if not feature_id.startswith(self.key_prefix):
feature_id = self.key_prefix + feature_id
Expand Down Expand Up @@ -236,19 +240,12 @@ def _from_generated(cls, key_value):
return ConfigurationSetting._from_generated(key_value)

def _to_generated(self):
# type: (...) -> KeyValue
# value = {
# u"id": self.key,
# u"description": self.description,
# u"enabled": self._enabled,
# u"conditions": {u"client_filters": self._filters},
# }
# value = json.dumps(value)
# type: () -> KeyValue

return KeyValue(
key=self.key,
label=self.label,
value=self.value,
value=json.dumps(self.value), # NOTE: This has to be added for valid json
content_type=self.content_type,
last_modified=self.last_modified,
tags=self.tags,
Expand Down Expand Up @@ -297,7 +294,7 @@ class SecretReferenceConfigurationSetting(ConfigurationSetting):
kind = "SecretReference"

def __init__(self, key, secret_uri, label=None, **kwargs):
# type: (str, str, str) -> None
# type: (str, str, str, **Any) -> None
self._secret_uri = secret_uri
super(SecretReferenceConfigurationSetting, self).__init__(**kwargs)
self.key = key
Expand Down Expand Up @@ -334,26 +331,24 @@ def _validate(self):
@classmethod
def _from_generated(cls, key_value):
# type: (KeyValue) -> SecretReferenceConfigurationSetting
try:
if key_value is None:
return None
if key_value.value:
try:
key_value.value = json.loads(key_value.value)
except json.decoder.JSONDecodeError:
pass
return cls(
key=key_value.key,
secret_uri=key_value.value[u"secret_uri"],
label=key_value.label,
secret_id=key_value.value,
last_modified=key_value.last_modified,
tags=key_value.tags,
read_only=key_value.locked,
etag=key_value.etag,
)
except (KeyError, AttributeError):
return ConfigurationSetting._from_generated(key_value)
if key_value is None:
return None
if key_value.value:
try:
key_value.value = json.loads(key_value.value)
except json.decoder.JSONDecodeError:
pass

return cls(
key=key_value.key,
secret_uri=key_value.value[u"secret_uri"],
label=key_value.label,
secret_id=key_value.value,
last_modified=key_value.last_modified,
tags=key_value.tags,
read_only=key_value.locked,
etag=key_value.etag,
)

def _to_generated(self):
# type: (...) -> KeyValue
Expand Down
Loading

0 comments on commit f56089d

Please sign in to comment.