1# ------------------------------------
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4# ------------------------------------
5from msrest.serialization import Model
6from ._generated.models import KeyValue
7
8class ConfigurationSetting(Model):
9    """A configuration value.
10    Variables are only populated by the server, and will be ignored when
11    sending a request.
12    :ivar etag: Entity tag (etag) of the object
13    :vartype etag: str
14    :param key:
15    :type key: str
16    :param label:
17    :type label: str
18    :param content_type:
19    :type content_type: str
20    :param value:
21    :type value: str
22    :ivar last_modified:
23    :vartype last_modified: datetime
24    :ivar read_only:
25    :vartype read_only: bool
26    :param tags:
27    :type tags: dict[str, str]
28    """
29    _attribute_map = {
30        'etag': {'key': 'etag', 'type': 'str'},
31        'key': {'key': 'key', 'type': 'str'},
32        'label': {'key': 'label', 'type': 'str'},
33        'content_type': {'key': 'content_type', 'type': 'str'},
34        'value': {'key': 'value', 'type': 'str'},
35        'last_modified': {'key': 'last_modified', 'type': 'iso-8601'},
36        'read_only': {'key': 'read_only', 'type': 'bool'},
37        'tags': {'key': 'tags', 'type': '{str}'},
38    }
39
40    def __init__(self, **kwargs):
41        super(ConfigurationSetting, self).__init__(**kwargs)
42        self.etag = kwargs.get('etag', None)
43        self.key = kwargs.get('key', None)
44        self.label = kwargs.get('label', None)
45        self.content_type = kwargs.get('content_type', None)
46        self.value = kwargs.get('value', None)
47        self.last_modified = kwargs.get('last_modified', None)
48        self.read_only = kwargs.get('read_only', None)
49        self.tags = kwargs.get('tags', None)
50
51    @classmethod
52    def _from_key_value(cls, key_value):
53        # type: (KeyValue) -> ConfigurationSetting
54        if key_value is None:
55            return None
56        return cls(
57            key=key_value.key,
58            label=key_value.label,
59            content_type=key_value.content_type,
60            value=key_value.value,
61            last_modified=key_value.last_modified,
62            tags=key_value.tags,
63            read_only=key_value.locked,
64            etag=key_value.etag,
65        )
66