olp-cpp-sdk  1.22.0
StreamLayerClient.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 #include <string>
24 #include <vector>
25 
26 #include <olp/core/client/ApiError.h>
27 #include <olp/core/client/ApiResponse.h>
28 #include <olp/core/client/OlpClientSettings.h>
29 #include <olp/core/porting/deprecated.h>
30 #include <olp/dataservice/write/DataServiceWriteApi.h>
31 #include <olp/dataservice/write/StreamLayerClientSettings.h>
32 #include <olp/dataservice/write/generated/model/ResponseOk.h>
33 #include <olp/dataservice/write/generated/model/ResponseOkSingle.h>
34 #include <olp/dataservice/write/model/FlushRequest.h>
35 #include <olp/dataservice/write/model/PublishDataRequest.h>
36 #include <olp/dataservice/write/model/PublishSdiiRequest.h>
37 
38 namespace olp {
39 namespace client {
40 struct Error;
41 class HRN;
42 } // namespace client
43 
44 namespace dataservice {
45 namespace write {
46 class StreamLayerClientImpl;
47 
48 using PublishDataResult = olp::dataservice::write::model::ResponseOkSingle;
49 using PublishDataResponse =
50  client::ApiResponse<PublishDataResult, client::ApiError>;
51 using PublishDataCallback = std::function<void(PublishDataResponse response)>;
52 
53 using PublishSdiiResult = olp::dataservice::write::model::ResponseOk;
54 using PublishSdiiResponse =
55  client::ApiResponse<PublishSdiiResult, client::ApiError>;
56 using PublishSdiiCallback = std::function<void(PublishSdiiResponse response)>;
57 
59 class DATASERVICE_WRITE_API StreamLayerClient {
60  public:
62  using FlushResponse = std::vector<PublishDataResponse>;
63 
65  using FlushCallback = std::function<void(FlushResponse response)>;
66 
78  StreamLayerClientSettings client_settings,
79  client::OlpClientSettings settings);
80 
92 
104  model::PublishDataRequest request);
105 
120  PublishDataCallback callback);
121 
130  boost::optional<std::string> Queue(model::PublishDataRequest request);
131 
140  model::FlushRequest request);
141 
153  FlushCallback callback);
154 
168  model::PublishSdiiRequest request);
169 
186  PublishSdiiCallback callback);
187 
188  private:
189  std::shared_ptr<StreamLayerClientImpl> impl_;
190 };
191 
192 } // namespace write
193 } // namespace dataservice
194 } // 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 stream layer.
Definition: StreamLayerClient.h:59
olp::client::CancellableFuture< PublishDataResponse > PublishData(model::PublishDataRequest request)
Publishes data to the stream layer.
olp::client::CancellableFuture< FlushResponse > Flush(model::FlushRequest request)
Flushes PublishDataRequests that are queued via the Queue API.
olp::client::CancellationToken PublishSdii(model::PublishSdiiRequest request, PublishSdiiCallback callback)
Sends a list of SDII messages to a stream layer.
void CancelPendingRequests()
Cancels all the ongoing publish operations that this client started.
std::vector< PublishDataResponse > FlushResponse
An alias for the flush response.
Definition: StreamLayerClient.h:62
olp::client::CancellationToken Flush(model::FlushRequest request, FlushCallback callback)
Flushes PublishDataRequests that are queued via the Queue API.
olp::client::CancellableFuture< PublishSdiiResponse > PublishSdii(model::PublishSdiiRequest request)
Sends a list of SDII messages to a stream layer.
boost::optional< std::string > Queue(model::PublishDataRequest request)
Enqueues PublishDataRequest that is sent over the wire.
std::function< void(FlushResponse response)> FlushCallback
An alias for the flush callback.
Definition: StreamLayerClient.h:65
olp::client::CancellationToken PublishData(model::PublishDataRequest request, PublishDataCallback callback)
Publishes data to the stream layer.
StreamLayerClient(client::HRN catalog, StreamLayerClientSettings client_settings, client::OlpClientSettings settings)
Creates the StreamLayerClient insatnce.
Flushes requests in a stream layer.
Definition: FlushRequest.h:29
Publishes data to a stream layer.
Definition: PublishDataRequest.h:36
Sends a list of SDII messages to a stream layer.
Definition: PublishSdiiRequest.h:45
Represents a response to a successful data upload operation to a catalog layer.
Definition: ResponseOkSingle.h:34
Contians a response to a successful ingestSDII call.
Definition: ResponseOk.h:113
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
Configures the behavior of the OlpClient class.
Definition: OlpClientSettings.h:180
Configures the behavior of the StreamLayerClient specific logic.
Definition: StreamLayerClientSettings.h:32