olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
OlpClientSettings.h
1/*
2 * Copyright (C) 2019-2024 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 <chrono>
23#include <functional>
24#include <memory>
25#include <string>
26
27#include <olp/core/client/CancellationContext.h>
28#include <olp/core/client/DefaultLookupEndpointProvider.h>
29#include <olp/core/client/HRN.h>
30#include <olp/core/client/HttpResponse.h>
31#include <olp/core/client/OauthToken.h>
32#include <olp/core/client/RetrySettings.h>
33#include <olp/core/http/Network.h>
34#include <olp/core/porting/optional.h>
35
36namespace olp {
37namespace cache {
38class KeyValueCache;
39} // namespace cache
40
41namespace thread {
42class TaskScheduler;
43} // namespace thread
44
45namespace http {
46class Network;
47} // namespace http
48
49namespace client {
55using NetworkAsyncCallback = std::function<void(HttpResponse)>;
56
62using NetworkAsyncCancel = std::function<void()>;
63
73struct CORE_API AuthenticationSettings {
75 using ApiKeyProviderType = std::function<std::string()>;
76
96
103 TokenProviderCancellableCallback token_provider = nullptr;
104
115 ApiKeyProviderType api_key_provider = nullptr;
116};
117
121struct CORE_API ApiLookupSettings {
133 using LookupEndpointProvider = std::function<std::string(const std::string&)>;
134
148 using CatalogEndpointProvider = std::function<std::string(const HRN&)>;
149
159 LookupEndpointProvider lookup_endpoint_provider =
161
172 CatalogEndpointProvider catalog_endpoint_provider = nullptr;
173};
174
178struct CORE_API OlpClientSettings {
183
188
194 porting::optional<http::NetworkProxySettings> proxy_settings = porting::none;
195
202 porting::optional<AuthenticationSettings> authentication_settings =
203 porting::none;
204
210 std::shared_ptr<thread::TaskScheduler> task_scheduler = nullptr;
211
217 std::shared_ptr<http::Network> network_request_handler = nullptr;
218
226 std::shared_ptr<cache::KeyValueCache> cache = nullptr;
227
240 std::chrono::seconds default_cache_expiration = std::chrono::seconds::max();
241
248 bool propagate_all_cache_errors = false;
249};
250
251} // namespace client
252} // namespace olp
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
Allows a Here Resource Name (HRN) to be passed to the operations that require it.
Definition HRN.h:34
This class represents the HTTP response created from the NetworkResponse and the request body.
Definition HttpResponse.h:89
std::function< void()> NetworkAsyncCancel
An alias for the cancel function.
Definition OlpClientSettings.h:62
std::function< void(HttpResponse)> NetworkAsyncCallback
An alias for the asynchronous network callback.
Definition OlpClientSettings.h:55
Rules all the other namespaces.
Definition AppleSignInProperties.h:24
Settings to provide URLs for API lookup requests.
Definition OlpClientSettings.h:121
std::function< std::string(const std::string &)> LookupEndpointProvider
An alias for the lookup provider function.
Definition OlpClientSettings.h:133
std::function< std::string(const HRN &)> CatalogEndpointProvider
An alias for the catalog endpoint provider function.
Definition OlpClientSettings.h:148
A set of settings that manages the TokenProviderCallback and TokenProviderCancelCallback functions.
Definition OlpClientSettings.h:73
std::function< std::string()> ApiKeyProviderType
An alias for the ApiKey provider.
Definition OlpClientSettings.h:75
std::function< OauthTokenResponse(CancellationContext &)> TokenProviderCancellableCallback
Implemented by the client that should return the OAuth2 bearer access token if the operation is succe...
Definition OlpClientSettings.h:95
The default implementation of the lookup API endpoint provider.
Definition DefaultLookupEndpointProvider.h:35
Configures the behavior of the OlpClient class.
Definition OlpClientSettings.h:178
RetrySettings retry_settings
The retry settings.
Definition OlpClientSettings.h:182
ApiLookupSettings api_lookup_settings
API Lookup settings.
Definition OlpClientSettings.h:187
A collection of settings that controls how failed requests should be treated by the Data SDK.
Definition RetrySettings.h:47