olp-cpp-sdk  1.22.0
VersionedLayerClient.h
1 /*
2  * Copyright (C) 2019-2021 HERE Europe B.V.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  * License-Filename: LICENSE
18  */
19 
20 #pragma once
21 
22 #include <memory>
23 
24 #include <olp/core/client/ApiError.h>
25 #include <olp/core/client/ApiNoResult.h>
26 #include <olp/core/client/ApiResponse.h>
27 #include <olp/core/client/HRN.h>
28 #include <olp/core/client/OlpClientSettings.h>
29 #include <olp/core/porting/deprecated.h>
30 
31 #include <olp/dataservice/write/DataServiceWriteApi.h>
32 #include <olp/dataservice/write/generated/model/Publication.h>
33 #include <olp/dataservice/write/generated/model/ResponseOk.h>
34 #include <olp/dataservice/write/generated/model/ResponseOkSingle.h>
35 #include <olp/dataservice/write/model/CheckDataExistsRequest.h>
36 #include <olp/dataservice/write/model/PublishPartitionDataRequest.h>
37 #include <olp/dataservice/write/model/StartBatchRequest.h>
38 #include <olp/dataservice/write/model/VersionResponse.h>
39 
40 namespace olp {
41 namespace dataservice {
42 namespace write {
43 
44 using StartBatchResult = model::Publication;
45 using StartBatchResponse =
46  client::ApiResponse<StartBatchResult, client::ApiError>;
47 using StartBatchCallback = std::function<void(StartBatchResponse)>;
48 
49 using GetBaseVersionResult = model::VersionResponse;
50 using GetBaseVersionResponse =
51  client::ApiResponse<GetBaseVersionResult, client::ApiError>;
52 using GetBaseVersionCallback = std::function<void(GetBaseVersionResponse)>;
53 
54 using GetBatchResult = model::Publication;
55 using GetBatchResponse = client::ApiResponse<GetBatchResult, client::ApiError>;
56 using GetBatchCallback = std::function<void(GetBatchResponse)>;
57 
58 using CompleteBatchResult = client::ApiNoResult;
59 using CompleteBatchResponse =
60  client::ApiResponse<CompleteBatchResult, client::ApiError>;
61 using CompleteBatchCallback =
62  std::function<void(CompleteBatchResponse response)>;
63 
64 using CancelBatchResult = client::ApiNoResult;
65 using CancelBatchResponse =
66  client::ApiResponse<CancelBatchResult, client::ApiError>;
67 using CancelBatchCallback = std::function<void(CancelBatchResponse response)>;
68 
69 using PublishPartitionDataResponse =
70  client::ApiResponse<model::ResponseOkSingle, client::ApiError>;
71 using PublishPartitionDataCallback =
72  std::function<void(PublishPartitionDataResponse response)>;
73 
74 using CheckDataExistsStatusCode = int;
75 using CheckDataExistsResponse =
76  client::ApiResponse<CheckDataExistsStatusCode, client::ApiError>;
77 using CheckDataExistsCallback =
78  std::function<void(CheckDataExistsResponse response)>;
79 
80 class VersionedLayerClientImpl;
81 
83 class DATASERVICE_WRITE_API VersionedLayerClient {
84  public:
93 
102  model::StartBatchRequest request);
103 
115  StartBatchCallback callback);
116 
124 
135  GetBaseVersionCallback callback);
136 
146  const model::Publication& pub);
147 
159  GetBatchCallback callback);
160 
169  const model::Publication& pub);
170 
182  CompleteBatchCallback callback);
183 
192  const model::Publication& pub);
193 
205  CancelBatchCallback callback);
206 
215 
228  const model::Publication& pub,
230 
247  PublishPartitionDataCallback callback);
248 
258 
270  model::CheckDataExistsRequest request, CheckDataExistsCallback callback);
271 
272  private:
273  std::shared_ptr<VersionedLayerClientImpl> impl_;
274 };
275 
276 } // namespace write
277 } // namespace dataservice
278 } // namespace olp
A wrapper template that you can use to cancel a request or wait for it to finalize.
Definition: ApiResponse.h:281
Cancels service requests.
Definition: CancellationToken.h:33
Allows a Here Resource Name (HRN) to be passed to the operations that require it.
Definition: HRN.h:34
Publishes data to a versioned layers.
Definition: VersionedLayerClient.h:83
olp::client::CancellableFuture< CancelBatchResponse > CancelBatch(const model::Publication &pub)
Cancels the batch operation.
olp::client::CancellableFuture< PublishPartitionDataResponse > PublishToBatch(const model::Publication &pub, model::PublishPartitionDataRequest request)
Publishes data to the versioned layer.
olp::client::CancellableFuture< CompleteBatchResponse > CompleteBatch(const model::Publication &pub)
Completes the batch operation and commits it to the HERE platform.
olp::client::CancellableFuture< GetBaseVersionResponse > GetBaseVersion()
Gets the latest version number of the catalog.
olp::client::CancellationToken GetBatch(const model::Publication &pub, GetBatchCallback callback)
Gets the details of the batch publication.
olp::client::CancellableFuture< GetBatchResponse > GetBatch(const model::Publication &pub)
Gets the details of the batch publication.
olp::client::CancellationToken CancelBatch(const model::Publication &pub, CancelBatchCallback callback)
Cancels the batch operation.
VersionedLayerClient(client::HRN catalog, client::OlpClientSettings settings)
Creates the VersionedLayerClient instance.
olp::client::CancellationToken PublishToBatch(const model::Publication &pub, model::PublishPartitionDataRequest request, PublishPartitionDataCallback callback)
Publishes data to the versioned layer.
olp::client::CancellationToken GetBaseVersion(GetBaseVersionCallback callback)
Gets the latest version number of the catalog.
olp::client::CancellationToken StartBatch(model::StartBatchRequest request, StartBatchCallback callback)
Starts the batch operation.
olp::client::CancellableFuture< CheckDataExistsResponse > CheckDataExists(model::CheckDataExistsRequest request)
Checks whether the data handle exits.
void CancelPendingRequests()
Cancels all the ongoing operations that this client started.
olp::client::CancellableFuture< StartBatchResponse > StartBatch(model::StartBatchRequest request)
Starts the batch operation.
olp::client::CancellationToken CheckDataExists(model::CheckDataExistsRequest request, CheckDataExistsCallback callback)
Checks whether the data handle exits.
olp::client::CancellationToken CompleteBatch(const model::Publication &pub, CompleteBatchCallback callback)
Completes the batch operation and commits it to the HERE platform.
Checks whether data is present in a layer.
Definition: CheckDataExistsRequest.h:34
Contains information on a publication.
Definition: Publication.h:37
Publishes data to a versioned and volatile layer.
Definition: PublishPartitionDataRequest.h:36
Starts a versioned batch operation.
Definition: StartBatchRequest.h:37
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
Configures the behavior of the OlpClient class.
Definition: OlpClientSettings.h:180