Project Operations

The HERE platform allows you to create and manage projects. As an admin, you can grant other users, apps, and groups access to a project. Users with project access rights can create and manage project resources – catalogs, schemas, and pipelines. The compute, storage, and transfer usage associated with any project resource is automatically tracked based on project ID.

Project Operations

The HERE Data SDK for Python supports the following functionality for projects:

  • Create a project
  • Get a project
  • Manage project access
  • Manage project catalogs, layers, and partitions
  • Update a project
  • List projects
  • Delete a project

Platform Limitation

When developing your code, be aware that when you create a project the admin role for that project will not be immediately available. After creating a project you should implement a short wait interval before performing any project operations.

Below are examples of the most often used methods available. For full detail, see the API documentation.

Create a Project

# Import
from here.platform import Platform
from datetime import datetime
import time
platform = Platform()
#To maintain the unique project_id, using timestamp as id.
now = datetime.now()
project_id = now.strftime("%m%d%H%M%S%f")
project_name = now.strftime("%m%d%H%M%S%f")
project_desc = "This project is created for testing."
project = platform.create_project(project_id, project_name, project_desc)

Get a Project

## It can take time to search the project. See the added delay.
time.sleep(5)
project = platform.get_project(project.hrn)

Update Project Metadata

project_name = "updated-analytics-test"
project_desc = "updated-analytics-description"
result = platform.update_project(project.hrn, project_name, project_desc)

Managing Project Access

The following support is available to manage the project:

  • Grant project access to a user, app, or group
  • Update roles of user, app, or group
  • List all users, apps, and groups that have access to a project
  • Revoke project access from a user, app, or group

Grant Project Access to a User, App, or Group

Note

  • Replace the value of variable MEMBER_HRN with the hrn of the member to be added to this project.
MEMBER_HRN = "hrn:here:account::olp-here:user/HERE-9a80ddb8-8c2d-4974-b347-04dab6fc1b0b"
project.add_member(MEMBER_HRN)

Update Roles of User, App, or Group

role_name = "ProjectAdmin"
project.assign_member_role(MEMBER_HRN, role_name=role_name)

List of All Users, Apps, and Groups That Have Access to a Project

To get a list of project members, you must pass two parameters in the function:

  • limit - Number of entries to be returned in the response
  • only_include_identities - If true, returns an effective project members list containing only user and app identities including those that are members of the project indirectly via a group. It will also return users who are project admins of the project, and resource managers for the realm. If false, returns users, apps, and groups that are direct members of the project, excluding any users and apps that only have membership via a group.
only_include_identities = False
limit = "10"
result = project.list_members(limit, only_include_identities)

Revoke Project Access From a User, App, or Group

project.delete_member(member_hrn=MEMBER_HRN)

Managing Project Catalogs, Layers, and Partitions

The following support is available to manage project resources:

  • Create a catalog
  • Update a catalog
  • Show a catalog
  • Delete a catalog
  • List all visible project resources

Create a Catalog

platform = Platform(project_hrn=project.hrn)

catalog_id = now.strftime("%m%d%H%M%S%f")

catalog = platform.create_catalog(
        id=catalog_id,
        name="project-analytics-catalog-testing",
        summary="project-catalog",
        description="project-catalog",
    )

Get a Catalog

catalog = platform.get_catalog(f"hrn:here:data::olp-here:{catalog_id}")

Update a Catalog

Updating catalog metadata:

platform.update_catalog(
            hrn=catalog.hrn,
            id="update-id",
            name="update-catalog-metadata",
            summary="update-catalog-metadata-summary",
            description="update-catalog-metadata-description",
        )
catalog = platform.get_catalog(f"hrn:here:data::olp-here:{catalog_id}")

Add layer to existing catalog:

layer1 = {
        "id": "temp-layer",
        "name": "temp-layer-update-name",
        "summary": "temp-layer-summary",
        "description": "temp-layer-description",
        "contentType": "application/json",
        "layerType": "volatile",
        "partitioning": {"scheme": "generic"},
    }
layer2 = {
        "id": "temp-layer2",
        "name": "temp-layer-update-name",
        "summary": "temp-layer-summary",
        "description": "temp-layer-description",
        "contentType": "application/json",
        "layerType": "volatile",
        "partitioning": {"scheme": "generic"},
    }

platform.update_catalog(
        hrn=catalog.hrn,
        id=catalog_id,
        name="project-analytics-catalog-testing",
        summary="project-catalog",
        description="project-catalog",
        layers=[layer1, layer2],
    )
catalog = platform.get_catalog(f"hrn:here:data::olp-here:{catalog_id}")

Delete a Catalog in a Project

platform.delete_catalog(catalog.hrn)

Get Project Details

Get Project resources

Get the list of resources in the requested project.

project.list_resources(
        resource_type="catalog", resource_limit="10", resource_relation="home"
    )

Delete a Project

platform.delete_project(project.hrn)

results matching ""

    No results matching ""