示例#1
0
    def create(self, creation_spec):
        """
        Create an Attribute in this collection

        :param creation_spec: Attribute creation specification should be formatted as specified in the `Public Docs for adding an Attribute <https://docs.tamr.com/reference#add-attributes>`_.
        :type creation_spec: dict[str, str]
        :returns: The created Attribute
        :rtype: :class:`~tamr_unify_client.attribute.resource.Attribute`
        """
        data = self.client.post(self.api_path, json=creation_spec).successful().json()
        alias = self.api_path + "/" + creation_spec["name"]
        return Attribute.from_json(self.client, data, alias)
示例#2
0
    def stream(self):
        """Stream attributes in this collection. Implicitly called when iterating
        over this collection.

        :returns: Stream of attributes.
        :rtype: Python generator yielding :class:`~tamr_unify_client.attribute.resource.Attribute`

        Usage:
            >>> for attribute in collection.stream(): # explicit
            >>>     do_stuff(attribute)
            >>> for attribute in collection: # implicit
            >>>     do_stuff(attribute)
        """
        data = self.client.get(self.api_path).successful().json()
        for resource_json in data:
            alias = self.api_path + "/" + resource_json["name"]
            yield Attribute.from_json(self.client, resource_json, alias)
示例#3
0
 def test_resource_from_json(self):
     alias = "datasets/1/attributes/RowNum"
     expected = Attribute(self.tamr, self._attributes_json[0], alias)
     actual = Attribute.from_json(self.tamr, self._attributes_json[0],
                                  alias)
     self.assertEqual(repr(expected), repr(actual))