Exemplo n.º 1
0
    https://atlas.apache.org/api/v2/json_AtlasEntitiesWithExtInfo.html

    The response of get_entity will be a dict that has an "entities" key
    that contains a list of the entities you requested.
    """

    # Authenticate against your Atlas server
    oauth = ServicePrincipalAuthentication(
        tenant_id=os.environ.get("TENANT_ID", ""),
        client_id=os.environ.get("CLIENT_ID", ""),
        client_secret=os.environ.get("CLIENT_SECRET", ""))
    client = PurviewClient(account_name=os.environ.get("PURVIEW_NAME", ""),
                           authentication=oauth)

    # For a given guid, check if a given classification type is applied
    # If it's not, an AtlasException is thrown.
    try:
        single_class_check = client.get_entity_classification(
            guid="b58fc81e-a85f-4dfc-aad1-ee33b3421b87",
            classificationName="MICROSOFT.PERSONAL.IPADDRESS")
        print(json.dumps(single_class_check, indent=2))
    except AtlasException as e:
        print(
            "The provided classification was not found on the provied entity.")
        print(e)

    # You can also get ALL of the classifications from a given entity
    all_class_check = client.get_entity_classifications(
        guid="b58fc81e-a85f-4dfc-aad1-ee33b3421b83")
    print(json.dumps(all_class_check, indent=2))
Exemplo n.º 2
0
    """
    This sample provides an example of removing a classification from a given
    entity.
    """

    # Authenticate against your Atlas server
    oauth = ServicePrincipalAuthentication(
        tenant_id=os.environ.get("TENANT_ID", ""),
        client_id=os.environ.get("CLIENT_ID", ""),
        client_secret=os.environ.get("CLIENT_SECRET", ""))
    client = PurviewClient(account_name=os.environ.get("PURVIEW_NAME", ""),
                           authentication=oauth)

    # When you know the GUID that you want to delete
    response = client.declassify_entity(
        guid="b58fc81e-a85f-4dfc-aad1-ee33b3421b83",
        classificationName="MICROSOFT.PERSONAL.IPADDRESS")
    print(json.dumps(response, indent=2))

    # When you need to find multiple classifications to delete on an entity.
    # Get all the classifications and then retrieve the "list" attribute.
    classifications = client.get_entity_classifications(
        guid="b58fc81e-a85f-4dfc-aad1-ee33b3421b83")["list"]

    # For every classification, remove it.
    for classification in classifications:
        response = client.declassify_entity(
            guid="b58fc81e-a85f-4dfc-aad1-ee33b3421b83",
            classificationName=classification["typeName"])
        print(response)