Skip to content

Commit 89c5962

Browse files
Add functionality for GetCompatibleVersions (#1300)
- Add functionality to allow to query compatible versions for the given catalog. - Update Azure Pipelines to use new macOS-10.15 version Resolves: OAM-1338 Signed-off-by: Serhii Lozynskyi <[email protected]>
1 parent a9fb579 commit 89c5962

File tree

15 files changed

+442
-10
lines changed

15 files changed

+442
-10
lines changed

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ jobs:
2929

3030
- job: MacOS_build
3131
pool:
32-
vmImage: 'macOS-10.14'
32+
vmImage: 'macOS-10.15'
3333
steps:
3434
- bash: scripts/macos/psv/azure_macos_build_psv.sh
3535
displayName: 'MacOS Build'
3636

3737
- job: iOS_build
3838
pool:
39-
vmImage: 'macOS-10.14'
39+
vmImage: 'macOS-10.15'
4040
steps:
4141
- bash: scripts/ios/azure_ios_build_psv.sh
4242
displayName: 'iOS Build'
@@ -55,7 +55,7 @@ jobs:
5555

5656
- job: Android_Emulator
5757
pool:
58-
vmImage: 'macOS-10.14'
58+
vmImage: 'macOS-10.15'
5959
condition: eq(variables['Build.Reason'], 'Manual')
6060
variables:
6161
ANDROID_NDK_HOME: $(ANDROID_HOME)/ndk-bundle

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/CatalogClient.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,40 @@ class DATASERVICE_READ_API CatalogClient final {
189189
client::CancellableFuture<VersionsResponse> ListVersions(
190190
VersionsRequest request);
191191

192+
/**
193+
* @brief Gets the list of the current catalog versions that are compatible
194+
* with the dependencies provided by the request.
195+
*
196+
* @note This request is online only. It does not support
197+
* multiple pages and returns only the first page.
198+
*
199+
* @param request The `CompatibleVersionsRequest` instance that contains a
200+
* complete set of the request parameters.
201+
* @param callback The `CompatibleVersionsCallback` object that is invoked if
202+
* the compatible versions are available or an error occurred.
203+
*
204+
* @return A token that can be used to cancel this request.
205+
*/
206+
client::CancellationToken GetCompatibleVersions(
207+
CompatibleVersionsRequest request, CompatibleVersionsCallback callback);
208+
209+
/**
210+
* @brief Gets the list of the current catalog versions that are compatible
211+
* with the dependencies provided by the request.
212+
*
213+
* @note This request is online only. It does not support
214+
* multiple pages and returns only the first page.
215+
*
216+
* @param request The `CompatibleVersionsRequest` instance that contains a
217+
* complete set of the request parameters.
218+
*
219+
* @return `CancellableFuture` that contains the `VersionsResponse`
220+
* instance with the list of versions or an error. You can also
221+
* use `CancellableFuture` to cancel this request.
222+
*/
223+
client::CancellableFuture<CompatibleVersionsResponse> GetCompatibleVersions(
224+
CompatibleVersionsRequest request);
225+
192226
private:
193227
std::unique_ptr<CatalogClientImpl> impl_;
194228
};

olp-cpp-sdk-dataservice-read/include/olp/dataservice/read/Types.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2022 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -138,8 +138,16 @@ using VersionsResponse = Response<VersionsResult>;
138138
/// The versions list of metadata callback type for the versioned client.
139139
using VersionsResponseCallback = Callback<VersionsResult>;
140140

141+
/// An alias for the compatible versions response.
142+
using CompatibleVersionsResult = model::VersionsResponse;
143+
/// The compatible versions list response type for the versioned client.
144+
using CompatibleVersionsResponse = Response<CompatibleVersionsResult>;
145+
/// The compatible versions list response type for the versioned client.
146+
using CompatibleVersionsCallback = Callback<CompatibleVersionsResult>;
147+
141148
/// The list of tile keys.
142149
using TileKeys = std::vector<geo::TileKey>;
150+
143151
} // namespace read
144152
} // namespace dataservice
145153
} // namespace olp

olp-cpp-sdk-dataservice-read/src/CatalogClient.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2022 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -71,6 +71,17 @@ client::CancellableFuture<VersionsResponse> CatalogClient::ListVersions(
7171
VersionsRequest request) {
7272
return impl_->ListVersions(std::move(request));
7373
}
74+
75+
client::CancellationToken CatalogClient::GetCompatibleVersions(
76+
CompatibleVersionsRequest request, CompatibleVersionsCallback callback) {
77+
return impl_->GetCompatibleVersions(std::move(request), std::move(callback));
78+
}
79+
80+
client::CancellableFuture<CompatibleVersionsResponse>
81+
CatalogClient::GetCompatibleVersions(CompatibleVersionsRequest request) {
82+
return impl_->GetCompatibleVersions(std::move(request));
83+
}
84+
7485
} // namespace read
7586
} // namespace dataservice
7687
} // namespace olp

olp-cpp-sdk-dataservice-read/src/CatalogClientImpl.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2022 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -147,6 +147,34 @@ client::CancellableFuture<VersionsResponse> CatalogClientImpl::ListVersions(
147147
return client::CancellableFuture<VersionsResponse>(std::move(cancel_token),
148148
std::move(promise));
149149
}
150+
151+
client::CancellationToken CatalogClientImpl::GetCompatibleVersions(
152+
CompatibleVersionsRequest request, CompatibleVersionsCallback callback) {
153+
auto catalog = catalog_;
154+
auto settings = settings_;
155+
auto lookup_client = lookup_client_;
156+
157+
auto get_dependency_task =
158+
[=](client::CancellationContext context) -> CompatibleVersionsResponse {
159+
repository::CatalogRepository repository(catalog, settings, lookup_client);
160+
return repository.GetCompatibleVersions(request, std::move(context));
161+
};
162+
163+
return task_sink_.AddTask(std::move(get_dependency_task), std::move(callback),
164+
thread::NORMAL);
165+
}
166+
167+
client::CancellableFuture<CompatibleVersionsResponse>
168+
CatalogClientImpl::GetCompatibleVersions(CompatibleVersionsRequest request) {
169+
auto promise = std::make_shared<std::promise<CompatibleVersionsResponse>>();
170+
auto cancel_token = GetCompatibleVersions(
171+
std::move(request), [promise](CompatibleVersionsResponse response) {
172+
promise->set_value(std::move(response));
173+
});
174+
return client::CancellableFuture<CompatibleVersionsResponse>(
175+
std::move(cancel_token), std::move(promise));
176+
}
177+
150178
} // namespace read
151179
} // namespace dataservice
152180
} // namespace olp

olp-cpp-sdk-dataservice-read/src/CatalogClientImpl.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2022 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
2828
#include <olp/core/client/OlpClientSettings.h>
2929
#include <olp/dataservice/read/CatalogRequest.h>
3030
#include <olp/dataservice/read/CatalogVersionRequest.h>
31+
#include <olp/dataservice/read/CompatibleVersionsRequest.h>
3132
#include <olp/dataservice/read/Types.h>
3233
#include <olp/dataservice/read/VersionsRequest.h>
3334

@@ -69,6 +70,12 @@ class CatalogClientImpl final {
6970
client::CancellableFuture<VersionsResponse> ListVersions(
7071
VersionsRequest request);
7172

73+
client::CancellationToken GetCompatibleVersions(
74+
CompatibleVersionsRequest request, CompatibleVersionsCallback callback);
75+
76+
client::CancellableFuture<CompatibleVersionsResponse> GetCompatibleVersions(
77+
CompatibleVersionsRequest request);
78+
7279
private:
7380
client::HRN catalog_;
7481
client::OlpClientSettings settings_;

olp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 HERE Europe B.V.
2+
* Copyright (C) 2019-2022 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,11 +27,14 @@
2727
#include <olp/core/client/OlpClient.h>
2828

2929
// clang-format off
30+
#include "generated/parser/VersionsResponseParser.h"
3031
#include "generated/parser/LayerVersionsParser.h"
3132
#include "generated/parser/PartitionsParser.h"
3233
#include "generated/parser/VersionResponseParser.h"
3334
#include "generated/parser/VersionInfosParser.h"
3435
#include "JsonResultParser.h"
36+
#include "generated/serializer/CatalogVersionsSerializer.h"
37+
#include "generated/serializer/JsonSerializer.h"
3538
// clang-format on
3639

3740
namespace {
@@ -180,6 +183,36 @@ MetadataApi::VersionsResponse MetadataApi::ListVersions(
180183
return parser::parse_result<VersionsResponse>(api_response.response);
181184
}
182185

186+
MetadataApi::CompatibleVersionsResponse MetadataApi::GetCompatibleVersions(
187+
const client::OlpClient& client, const CatalogVersions& dependencies,
188+
int32_t limit, const client::CancellationContext& context) {
189+
std::string metadata_uri = "/versions/compatibles";
190+
191+
std::multimap<std::string, std::string> header_params;
192+
header_params.emplace("Accept", "application/json");
193+
194+
std::multimap<std::string, std::string> query_params;
195+
query_params.emplace("limit", std::to_string(limit));
196+
197+
rapidjson::Value value;
198+
199+
const auto serialized_dependencies = serializer::serialize(dependencies);
200+
201+
const auto data = std::make_shared<std::vector<unsigned char>>(
202+
serialized_dependencies.begin(), serialized_dependencies.end());
203+
204+
auto api_response =
205+
client.CallApi(metadata_uri, "POST", query_params, header_params, {},
206+
data, "application/json", context);
207+
208+
if (api_response.status != http::HttpStatusCode::OK) {
209+
return {{api_response.status, api_response.response.str()}};
210+
}
211+
212+
return parser::parse_result<CompatibleVersionsResponse>(
213+
api_response.response);
214+
}
215+
183216
} // namespace read
184217

185218
} // namespace dataservice

olp-cpp-sdk-dataservice-read/src/generated/api/MetadataApi.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2021 HERE Europe B.V.
2+
* Copyright (C) 2019-2022 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
#include "olp/dataservice/read/model/Partitions.h"
3131
#include "olp/dataservice/read/model/VersionInfos.h"
3232
#include "olp/dataservice/read/model/VersionResponse.h"
33+
#include "olp/dataservice/read/model/VersionsResponse.h"
3334

3435
namespace olp {
3536
namespace client {
@@ -57,6 +58,11 @@ class MetadataApi {
5758
ExtendedApiResponse<model::Partitions, client::ApiError,
5859
client::NetworkStatistics>;
5960

61+
using CatalogVersions = std::vector<model::CatalogVersion>;
62+
63+
using CompatibleVersionsResponse =
64+
client::ApiResponse<model::VersionsResponse, client::ApiError>;
65+
6066
/**
6167
* @brief Retrieves the latest metadata version for each layer of a specified
6268
* catalog metadata version.
@@ -128,6 +134,10 @@ class MetadataApi {
128134
const client::OlpClient& client, int64_t start_version,
129135
int64_t end_version, boost::optional<std::string> billing_tag,
130136
const client::CancellationContext& context);
137+
138+
static CompatibleVersionsResponse GetCompatibleVersions(
139+
const client::OlpClient& client, const CatalogVersions& dependencies,
140+
int32_t limit, const client::CancellationContext& context);
131141
};
132142

133143
} // namespace read
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2022 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+
#include "VersionsResponseParser.h"
21+
22+
#include <olp/core/generated/parser/ParserWrapper.h>
23+
24+
namespace olp {
25+
namespace parser {
26+
27+
using VersionsResponse = olp::dataservice::read::model::VersionsResponse;
28+
using VersionsResponseEntry =
29+
olp::dataservice::read::model::VersionsResponseEntry;
30+
using CatalogVersion = olp::dataservice::read::model::CatalogVersion;
31+
32+
void from_json(const rapidjson::Value& value, CatalogVersion& x) {
33+
x.SetHrn(parse<std::string>(value, "hrn"));
34+
x.SetVersion(parse<int64_t>(value, "version"));
35+
}
36+
37+
void from_json(const rapidjson::Value& value, VersionsResponseEntry& x) {
38+
x.SetVersion(parse<int64_t>(value, "version"));
39+
x.SetCatalogVersions(
40+
parse<std::vector<CatalogVersion>>(value, "sharedDependencies"));
41+
}
42+
43+
void from_json(const rapidjson::Value& value, VersionsResponse& x) {
44+
x.SetVersionResponseEntries(
45+
parse<std::vector<VersionsResponseEntry>>(value, "versions"));
46+
}
47+
48+
} // namespace parser
49+
} // namespace olp
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (C) 2022 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 <string>
23+
24+
#include <rapidjson/document.h>
25+
#include "olp/dataservice/read/model/VersionsResponse.h"
26+
27+
28+
namespace olp {
29+
namespace parser {
30+
31+
void from_json(const rapidjson::Value& value,
32+
olp::dataservice::read::model::CatalogVersion& x);
33+
void from_json(const rapidjson::Value& value,
34+
olp::dataservice::read::model::VersionsResponseEntry& x);
35+
void from_json(const rapidjson::Value& value,
36+
olp::dataservice::read::model::VersionsResponse& x);
37+
38+
} // namespace parser
39+
} // namespace olp

0 commit comments

Comments
 (0)