Platform Operations

Accessing the HERE Platform

The HERE Data SDK for Python provides interaction with HERE platform through the Platform object. There are two standard platform environments supported by the SDK:

Each of these platform environments has it's own set of credentials. If you are accessing the Default environment and using default credentials, create a Platform object as shown below:

from here.platform import Platform
platform = Platform()

To interact with a different environment and/or provide alternate credentials, pass either or both of the corresponding optional parameters in the Platform constructor:

from here.platform import Platform
platform = Platform(credentials=platform_cred, environment=Environment.INTERNAL)

See the Credentials section of this document for details of the different ways to provide credentials.

Create the Platform Object With Proxies

If you need to use a proxy, you can create and retrieve the platform object by passing a proxy configuration. For more details, see Proxies

from here.platform import Platform
proxies = {
  'http': 'http://10.10.1.10:3128',
  'https': 'http://10.10.1.10:1080',
}
platform = Platform(proxies=proxies)

Create the Platform Object With Adapter

If you plan to use pandas/GeoPandas in your code, you should create the platform object passing a GeoPandasAdapter. This will adapt all of the standard platform operations to work seamlessly with the data structures provided by pandas/GeoPandas. See the Using GeoPandas section of this document for information on working with the GeoPandasAdapter.

from here.geopandas_adapter.GeoPandasAdapter import GeoPandasAdapter
from here.platform import Platform
platform = Platform(adapter=GeoPandasAdapter())

Platform Operations

When you have created a Platform object, you can:

  • Query and manage your platform access
  • Create, query, and manage catalogs
  • Create, query, and manage projects

Below you will find a list of common operations at the platform level. Refer to later sections of this document to learn about the catalog and project operations available to you for catalog and project objects.

from here.platform import Platform
platform = Platform()
env = platform.environment

Set the Platform Environment

from here.platform import Platform
from here.environment import Environment
platform = Platform()
env = Environment.DEFAULT
platform.environment = env

Get the Platform Config

from here.platform import Platform
platform = Platform()
config = platform.platform_config

Get the Platform Status

from here.platform import Platform
platform = Platform()
status = platform.get_status()

Get Catalog Object

Get the catalog object of the given hrn. An error is generated if the catalog does not exist or if your credentials are not valid.

from here.platform import Platform
platform = Platform()
hrn = "hrn:here:data::olp-here:oma-3"
catalog = platform.get_catalog(hrn=hrn)

Check if Catalog Exists

Check if a catalog exists for a given hrn. Returns True or False depending on whether the catalog exists.

from here.platform import Platform
platform = Platform()
hrn = "hrn:here:data::olp-here:rib-2"
result = platform.catalog_exists(hrn=hrn)

Create Catalog

Create a catalog and get the generated catalog object.

from here.platform import Platform
platform = Platform()
catalog = platform.create_catalog(id="catalog-id", name="name-of-the-catalog", 
             summary="summary of the catalog", description="description of the catalog", 
             tags=["tag1", "tag2"])

Create Catalog with Layers

You can define and create one or more layers at the time of catalog creation.

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

catalog = platform.create_catalog(id=catalog_id, name='name-of-the-catalog',
                             summary='summary-of-the-catalog', description='description-of-the-catalog', layers=[layer1],
                             tags=["test", "analytics"])

List Catalogs

List all the catalogs accessible on the HERE platform. Optionally, search and return only catalogs specified by filter criteria.

from here.platform import Platform
platform = Platform()
list_of_catalogs = platform.list_catalogs()

Modify Catalog

Modify the catalog details, including name, summary, and description. This replaces the complete details of the catalog. After this call succeedes, obtain a new catalog via get_catalog to have access to the modified details, including affected layers. This is used to modify catalog fields.

from here.platform import Platform
platform = Platform()
platform.modify_catalog(hrn="hrn:here:data::olp-here:update", name='updated-name', 
                        description='updated-description')

Update Catalog

Update any descriptive and structural information in the catalog. To update a catalog, send a new version of your catalog configuration with the updated data and any required fields.

from here.platform import Platform
platform = Platform()
platform.update_catalog(hrn='hrn:here:data::olp-here:update', id='update', name='update-name',
                        summary='update-summary', description='update-description')

Update Catalog - Add layers

The update_catalog method allows you to add one or more new layers to an existing catalog.

from here.platform import Platform
platform = Platform()
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"},
}

platform.update_catalog(catalog.hrn, id=catalog_id, name="updated-name2", summary="updated-summary2", description="updated-description2", layers=[layer1])

# Refresh the updated catalog
catalog = platform.get_catalog(catalog.hrn)

Delete Catalog

Delete a catalog together with the layers it contains.

from here.platform import Platform
platform = Platform()
platform.delete_catalog(hrn='hrn:here:data::olp-here:sample-catalog')

Get Project

Get a project object for the given hrn.

from here.platform import Platform
platform = Platform()
project_object = platform.get_project("hrn:here:authorization::olp-here:project/test")

Create Project

from here.platform import Platform
platform = Platform()
created_project_object = platform.create_project("hrn:here:authorization::olp-here:sample-test-project")

List Projects

Get the list of projects where you are a project admin or a member based on the can_manage and is_member.

from here.platform import Platform
platform = Platform()
project_list = platform.list_projects()

Update Project

Update the project metadata.

from here.platform import Platform
platform = Platform()
project_list = platform.update_project(hrn ="hrn:here:authorization::olp-here:sample-test-project" , 
                                       project_name="sample-project-name", project_desc="sample project desc")

Delete Project

Delete a project together with the catalogs it contains.

from here.platform import Platform
platform = Platform()
project_list = platform.delete_project("hrn:here:authorization::olp-here:sample-test-project")

Leave Project

Leave the specified project.

from here.platform import Platform
platform = Platform()
project_list = platform.leave_project("hrn:here:authorization::olp-here:sample-test-project")

results matching ""

    No results matching ""