Example #1
0
def update(
    session: Session, attribute: Attribute, *, description: Optional[str] = None
) -> Attribute:
    """Update an existing attribute

    PUTS an update request to the Tamr server

    Args:
        attribute: Existing attribute to update
        description: Updated description for the existing attribute

    Returns:
        The newly updated attribute

    Raises:
        attribute.NotFound: If no attribute could be found at the specified URL.
            Corresponds to a 404 HTTP error.
        requests.HTTPError: If any other HTTP error is encountered.
    """
    updates = {"description": description}
    r = session.put(str(attribute.url), json=updates)
    if r.status_code == 404:
        raise NotFound(str(attribute.url))
    data = response.successful(r).json()
    return _from_json(attribute.url, data)
Example #2
0
def replace_all(
    session: Session, project: Project, tx: Transformations
) -> requests.Response:
    """Replaces the transformations of a Project

    Args:
        project: Project to place transformations within
        tx: Transformations to put into project

    Raises:
        requests.HTTPError: If any HTTP error is encountered.

    Example:
        >>> import tamr_client as tc
        >>> session = tc.session.from_auth('username', 'password')
        >>> instance = tc.instance.Instance(host="localhost", port=9100)
        >>> project1 = tc.project.from_resource_id(session, instance, id='1')
        >>> dataset3 = tc.dataset.from_resource_id(session, instance, id='3')
        >>> new_input_tx = tc.InputTransformation("SELECT *, upper(name) as name;", [dataset3])
        >>> all_tx = tc.Transformations(
        ... input_scope=[new_input_tx],
        ... unified_scope=["SELECT *, 1 as one;"]
        ... )
        >>> tc.transformations.replace_all(session, project1, all_tx)
    """
    body = _to_json(tx)
    r = session.put(f"{project.url}/transformations", json=body)

    return response.successful(r)