Publish data to a versioned layer

If you need to store and access the history of previous data updates, publish data to a versioned layer. To achieve consistency between layers, publish any update that affects multiple versioned layers together in one publication. You can access a new catalog version when all layers are updated and the publication is finalized. Once you publish a version, you cannot change the data in that version and can remove it only by removing the whole catalog version.

To publish data to the versioned layer:

  1. Create the OlpClientSettings object.

    For instructions, see Create platform client settings.

  2. Create the VersionedLayerClient object with the HERE Resource Name (HRN) of the catalog that contains the layer and the platform client settings from step 1.

    auto versioned_client = olp::dataservice::write::VersionedLayerClient(
    olp::client::HRN{kCatalogHRN}, client_settings);
  3. Create the StartBatchRequest object with the layer ID.

    auto start_batch_request = StartBatchRequest().WithLayers(kLayer);
  4. Run the StartBatchRequest method and wait for the response.

    auto start_batch_response =
  5. Get details of the started batch with the Publication parameter.

    auto get_batch_response =
  6. Create the PublishPartitionDataRequest object with the data that you want to publish, layer ID, and partition ID.

    auto publish_request =
            .WithData(std::make_shared<std::vector<unsigned char>>(20, 0x30))
  7. Run the PublishToBatch method with the Publication and the PublishRequest parameters, and wait for the response.

    auto publish_to_batch_response =
            .PublishToBatch(start_batch_response.GetResult(), publish_request)
  8. Run the CompleteBatch method with the publication details, and wait for the response.

    auto complete_batch_response =

The PublishDataResponse object holds details of the completed operation and is used to determine operation success and access resultant data:

  • IsSuccessful() – if the operation is successful, returns true. Otherwise, returns false.
  • GetResult()– if the operation is successful, returns the following resultant data: olp::dataservice::write::PublishDataResult
  • GetError() – contains error information as a result of an error in the olp::client::ApiError object.
if (response.IsSuccessful()) {
    auto response_result = response.GetResult();
    // Handle success
} else {
    auto api_error = response.GetError();
    // Handle fail

results matching ""

    No results matching ""