Esempio n. 1
0
    def _init_from_dict(self, info):
        """Initialize attributes from the parsed JSON representation.

        :type info: dict
        :param info:
            A ``dict`` parsed from the JSON wire-format representation.
        """
        self.name = info['name']
        self.type = info['type']
        self.labels = tuple(LabelDescriptor._from_dict(label)
                            for label in info.get('labels', []))
        self.metric_kind = info['metricKind']
        self.value_type = info['valueType']
        self.unit = info.get('unit', '')
        self.description = info.get('description', '')
        self.display_name = info.get('displayName', '')
Esempio n. 2
0
    def _init_from_dict(self, info):
        """Initialize attributes from the parsed JSON representation.

        :type info: dict
        :param info:
            A ``dict`` parsed from the JSON wire-format representation.
        """
        self.name = info['name']
        self.type = info['type']
        self.labels = tuple(LabelDescriptor._from_dict(label)
                            for label in info.get('labels', []))
        self.metric_kind = info['metricKind']
        self.value_type = info['valueType']
        self.unit = info.get('unit', '')
        self.description = info.get('description', '')
        self.display_name = info.get('displayName', '')
Esempio n. 3
0
    def _from_dict(cls, info):
        """Construct a resource descriptor from the parsed JSON representation.

        :type info: dict
        :param info:
            A ``dict`` parsed from the JSON wire-format representation.

        :rtype: :class:`ResourceDescriptor`
        :returns: A resource descriptor.
        """
        return cls(
            name=info['name'],
            type_=info['type'],
            display_name=info.get('displayName', ''),
            description=info.get('description', ''),
            labels=tuple(LabelDescriptor._from_dict(label)
                         for label in info.get('labels', ())),
        )
Esempio n. 4
0
    def _from_dict(cls, info):
        """Construct a resource descriptor from the parsed JSON representation.

        :type info: dict
        :param info:
            A ``dict`` parsed from the JSON wire-format representation.

        :rtype: :class:`ResourceDescriptor`
        :returns: A resource descriptor.
        """
        return cls(
            name=info['name'],
            type_=info['type'],
            display_name=info.get('displayName', ''),
            description=info.get('description', ''),
            labels=tuple(
                LabelDescriptor._from_dict(label)
                for label in info.get('labels', ())),
        )