olp-cpp-sdk  1.21.0
ApiLookupClient.h
1 /*
2  * Copyright (C) 2020 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 
25 #include <olp/core/CoreApi.h>
26 #include <olp/core/client/ApiError.h>
27 #include <olp/core/client/ApiResponse.h>
28 #include <olp/core/client/CancellationContext.h>
29 #include <olp/core/client/FetchOptions.h>
30 #include <olp/core/client/HRN.h>
31 #include <olp/core/client/OlpClient.h>
32 #include <olp/core/client/OlpClientSettings.h>
33 
34 namespace olp {
35 namespace client {
36 class ApiLookupClientImpl;
37 
39 class CORE_API ApiLookupClient final {
40  public:
44  using LookupApiCallback = std::function<void(LookupApiResponse)>;
45 
52  explicit ApiLookupClient(const HRN& catalog,
53  const OlpClientSettings& settings);
54 
55  ~ApiLookupClient();
56 
71  LookupApiResponse LookupApi(const std::string& service,
72  const std::string& service_version,
73  FetchOptions options,
74  CancellationContext context);
75 
96  CancellationToken LookupApi(const std::string& service,
97  const std::string& service_version,
98  FetchOptions options, LookupApiCallback callback);
99 
100  private:
101  std::shared_ptr<ApiLookupClientImpl> impl_;
102 };
103 
104 } // namespace client
105 } // namespace olp
A client for API lookup requests.
Definition: ApiLookupClient.h:39
ApiLookupClient(const HRN &catalog, const OlpClientSettings &settings)
Creates the ApiLookupClient instance.
std::function< void(LookupApiResponse)> LookupApiCallback
Alias for the lookup API callback.
Definition: ApiLookupClient.h:44
CancellationToken LookupApi(const std::string &service, const std::string &service_version, FetchOptions options, LookupApiCallback callback)
Gets an API for a single service asynchronously.
LookupApiResponse LookupApi(const std::string &service, const std::string &service_version, FetchOptions options, CancellationContext context)
Gets a API for a single service sync, internally uses ApiLookupSettings from OlpClientSettings.
Represents a request outcome.
Definition: ApiResponse.h:65
A wrapper that manages the cancellation state of an asynchronous operation in a thread-safe way.
Definition: CancellationContext.h:40
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
FetchOptions
Fetch options that control how requests are handled.
Definition: FetchOptions.h:26
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
Configures the behavior of the OlpClient class.
Definition: OlpClientSettings.h:180