Skip to content

Commit ea46be0

Browse files
author
Liubov Didkivska
authored
Remove fetch option from list versions request. (#914)
List versions works only online. Relates-To: OLPEDGE-1606 Signed-off-by: Liubov Didkivska <[email protected]>
1 parent 0cbe525 commit ea46be0

File tree

6 files changed

+10
-101
lines changed

6 files changed

+10
-101
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ class DATASERVICE_READ_API CatalogClient final {
141141
/**
142142
* @brief Gets the catalog versions list.
143143
*
144+
* @note Request of catalog versions list works only online.
145+
*
144146
* @param request The `VersionsRequest` instance that contains
145147
* a complete set of request parameters.
146148
* @param callback The `VersionsResponseCallback` object that is invoked if
@@ -154,6 +156,8 @@ class DATASERVICE_READ_API CatalogClient final {
154156
/**
155157
* @brief Gets the catalog versions list.
156158
*
159+
* @note Request of catalog versions list works only online.
160+
*
157161
* @param request The `VersionsRequest` instance that contains
158162
* a complete set of request parameters.
159163
*

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -136,31 +136,6 @@ class DATASERVICE_READ_API VersionsRequest final {
136136
return *this;
137137
}
138138

139-
/**
140-
* @brief Gets the fetch option that controls how requests are handled.
141-
*
142-
* The default option is `OnlineIfNotFound` that queries the network if
143-
* the requested resource is not in the cache.
144-
*
145-
* @return The fetch option.
146-
*/
147-
inline FetchOptions GetFetchOption() const { return fetch_option_; }
148-
149-
/**
150-
* @brief Sets the fetch option that you can use to set the source from
151-
* which data should be fetched.
152-
*
153-
* @see `GetFetchOption()` for information on usage and format.
154-
*
155-
* @param fetch_option The `FetchOption` enum.
156-
*
157-
* @return A reference to the updated `VersionsRequest` instance.
158-
*/
159-
inline VersionsRequest& WithFetchOption(FetchOptions fetch_option) {
160-
fetch_option_ = fetch_option;
161-
return *this;
162-
}
163-
164139
/**
165140
* @brief Creates a readable format for the request.
166141
*
@@ -174,15 +149,13 @@ class DATASERVICE_READ_API VersionsRequest final {
174149
if (GetBillingTag()) {
175150
out << "$" << GetBillingTag().get();
176151
}
177-
out << "^" << GetFetchOption();
178152
return out.str();
179153
}
180154

181155
private:
182156
std::int64_t start_version_;
183157
std::int64_t end_version_;
184158
boost::optional<std::string> billing_tag_;
185-
FetchOptions fetch_option_{OnlineIfNotFound};
186159
};
187160

188161
} // namespace read

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ client::CancellationToken CatalogClientImpl::ListVersions(
130130
VersionsRequest request, VersionsResponseCallback callback) {
131131
auto versions_list_task =
132132
[=](client::CancellationContext context) -> VersionsResponse {
133-
if (request.GetFetchOption() == CacheWithUpdate) {
134-
return {{client::ErrorCode::InvalidArgument,
135-
"CacheWithUpdate option can not be used for versioned catalog"}};
136-
}
137133
return repository::CatalogRepository::GetVersionsList(catalog_, context,
138134
request, settings_);
139135
};

olp-cpp-sdk-dataservice-read/src/repositories/CatalogRepository.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,8 @@ VersionsResponse CatalogRepository::GetVersionsList(
157157
const client::HRN& catalog,
158158
client::CancellationContext cancellation_context,
159159
const VersionsRequest& request, const client::OlpClientSettings& settings) {
160-
auto fetch_option = request.GetFetchOption();
161-
repository::CatalogCacheRepository repository(catalog, settings.cache);
162-
if (fetch_option == CacheOnly) {
163-
OLP_SDK_LOG_INFO_F(
164-
kLogTag,
165-
"GetVersionsList not supporting CacheOnly option, hrn='%s', key='%s'",
166-
catalog.ToCatalogHRNString().c_str(), request.CreateKey().c_str());
167-
return {{client::ErrorCode::InvalidArgument, "CacheOnly not supported"}};
168-
}
169-
170160
auto metadata_api = ApiClientLookup::LookupApi(
171-
std::move(catalog), cancellation_context, "metadata", "v1", fetch_option,
161+
std::move(catalog), cancellation_context, "metadata", "v1", OnlineOnly,
172162
std::move(settings));
173163

174164
if (!metadata_api.IsSuccessful()) {

olp-cpp-sdk-dataservice-read/tests/CatalogRepositoryTest.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ constexpr auto kResponseLatestCatalogVersion =
4040
R"jsonString({"version":4})jsonString";
4141
constexpr auto kUrlConfig =
4242
R"(https://config.data.api.platform.in.here.com/config/v1/catalogs/hrn:here:data::olp-here-test:hereos-internal-test-v2)";
43-
constexpr auto kResponseConfig =
43+
constexpr auto
44+
kResponseConfig =
4445
R"jsonString({"id":"hereos-internal-test","hrn":"hrn:here-dev:data:::hereos-internal-test","name":"hereos-internal-test","summary":"Internal test for hereos","description":"Used for internal testing on the staging olp.","contacts":{},"owner":{"creator":{"id":"HERE-88c95a7e-4123-4dcd-ae0e-4682aa5c3db4"},"organisation":{"id":"olp-here"}},"tags":[],"billingTags":[],"created":"2018-07-13T20:50:08.425Z","layers":[{"id":"hype-test-prefetch","hrn":"hrn:here-dev:data:::hereos-internal-test:hype-test-prefetch","name":"Hype Test Prefetch","summary":"hype prefetch testing","description":"Layer for hype prefetch testing","coverage":{"adminAreas":[]},"owner":{"creator":{"id":"HERE-88c95a7e-4123-4dcd-ae0e-4682aa5c3db4"},"organisation":{"id":"olp-here"}},"partitioningScheme":"heretile","partitioning":{"tileLevels":[],"scheme":"heretile"},"contentType":"application/x-protobuf","volume":{"volumeType":"durable"},"tags":[],"billingTags":[],"created":"2018-07-13T20:56:19.181Z","layerType":"versioned"},{"id":"testlayer_res","hrn":"hrn:here-dev:data:::hereos-internal-test:testlayer_res","name":"Resource Test Layer","summary":"testlayer_res","description":"testlayer_res","coverage":{"adminAreas":[]},"owner":{"creator":{"id":"HERE-88c95a7e-4123-4dcd-ae0e-4682aa5c3db4"},"organisation":{"id":"olp-here"}},"partitioningScheme":"generic","partitioning":{"scheme":"generic"},"contentType":"application/x-protobuf","volume":{"volumeType":"durable"},"tags":["TEST"],"billingTags":[],"created":"2018-07-13T20:56:19.181Z","layerType":"versioned"},{"id":"testlayer","hrn":"hrn:here-dev:data:::hereos-internal-test:testlayer","name":"Test Layer","summary":"A test layer","description":"A simple test layer","coverage":{"adminAreas":[]},"owner":{"creator":{"id":"HERE-88c95a7e-4123-4dcd-ae0e-4682aa5c3db4"},"organisation":{"id":"olp-here"}},"partitioningScheme":"generic","partitioning":{"scheme":"generic"},"contentType":"application/x-protobuf","volume":{"volumeType":"durable"},"tags":["TEST"],"billingTags":[],"created":"2018-07-13T20:56:19.181Z","layerType":"versioned"},{"id":"testlayer_volatile","ttl":1000,"hrn":"hrn:here-dev:data:::hereos-internal-test:testlayer","name":"Test Layer","summary":"A test layer","description":"A simple test layer","coverage":{"adminAreas":[]},"owner":{"creator":{"id":"HERE-88c95a7e-4123-4dcd-ae0e-4682aa5c3db4"},"organisation":{"id":"olp-here"}},"partitioningScheme":"generic","partitioning":{"scheme":"generic"},"contentType":"application/x-protobuf","volume":{"volumeType":"durable"},"tags":["TEST"],"billingTags":[],"created":"2018-07-13T20:56:19.181Z","layerType":"volatile"},{"id":"testlayer_stream","hrn":"hrn:here-dev:data:::hereos-internal-test:testlayer","name":"Test Layer","summary":"A test layer","description":"A simple test layer","coverage":{"adminAreas":[]},"owner":{"creator":{"id":"HERE-88c95a7e-4123-4dcd-ae0e-4682aa5c3db4"},"organisation":{"id":"olp-here"}},"partitioningScheme":"generic","partitioning":{"scheme":"generic"},"contentType":"application/x-protobuf","volume":{"volumeType":"durable"},"tags":["TEST"],"billingTags":[],"created":"2018-07-13T20:56:19.181Z","layerType":"stream"},{"id":"multilevel_testlayer","hrn":"hrn:here-dev:data:::hereos-internal-test:multilevel_testlayer","name":"Multi Level Test Layer","summary":"Multi Level Test Layer","description":"A multi level test layer just for testing","coverage":{"adminAreas":[]},"owner":{"creator":{"id":"HERE-88c95a7e-4123-4dcd-ae0e-4682aa5c3db4"},"organisation":{"id":"olp-here"}},"partitioningScheme":"generic","partitioning":{"scheme":"generic"},"contentType":"application/x-protobuf","volume":{"volumeType":"durable"},"tags":["TEST"],"billingTags":[],"created":"2018-07-13T20:56:19.181Z","layerType":"versioned"},{"id":"hype-test-prefetch-2","hrn":"hrn:here-dev:data:::hereos-internal-test:hype-test-prefetch-2","name":"Hype Test Prefetch2","summary":"Layer for testing hype2 prefetching","description":"Layer for testing hype2 prefetching","coverage":{"adminAreas":[]},"owner":{"creator":{"id":"HERE-88c95a7e-4123-4dcd-ae0e-4682aa5c3db4"},"organisation":{"id":"olp-here"}},"partitioningScheme":"heretile","partitioning":{"tileLevels":[],"scheme":"heretile"},"contentType":"application/x-protobuf","volume":{"volumeType":"durable"},"tags":["TEST"],"billingTags":[],"created":"2018-07-24T17:52:23.818Z","layerType":"versioned"}],"version":3})jsonString";
4546
constexpr auto kUrlLookupConfig =
4647
R"(https://api-lookup.data.api.platform.here.com/lookup/v1/platform/apis)";
@@ -644,24 +645,6 @@ TEST_F(CatalogRepositoryTest, GetVersionsList) {
644645
ASSERT_EQ(2u, result.GetVersions().front().GetDependencies().size());
645646
ASSERT_EQ(6u, result.GetVersions().front().GetPartitionCounts().size());
646647
}
647-
{
648-
SCOPED_TRACE("Get versions list cache only");
649-
650-
olp::client::CancellationContext context;
651-
auto request = read::VersionsRequest()
652-
.WithStartVersion(kStartVersion)
653-
.WithEndVersion(kEndVersion)
654-
.WithFetchOption(read::CacheOnly);
655-
656-
EXPECT_CALL(*cache_, Get(kVersionInfosCacheKey)).Times(0);
657-
658-
auto response = repository::CatalogRepository::GetVersionsList(
659-
kHrn, context, request, settings_);
660-
661-
ASSERT_FALSE(response.IsSuccessful());
662-
EXPECT_EQ(olp::client::ErrorCode::InvalidArgument,
663-
response.GetError().GetErrorCode());
664-
}
665648
{
666649
SCOPED_TRACE("Get versions list response forbiden");
667650

tests/integration/olp-cpp-sdk-dataservice-read/CatalogClientTest.cpp

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -567,31 +567,12 @@ TEST_F(CatalogClientTest, GetVersionsList) {
567567
6u,
568568
response.GetResult().GetVersions().front().GetPartitionCounts().size());
569569
}
570-
{
571-
SCOPED_TRACE("Get versions list from cache");
572-
573-
auto request =
574-
olp::dataservice::read::VersionsRequest()
575-
.WithStartVersion(kStartVersion)
576-
.WithEndVersion(kEndVersion)
577-
.WithFetchOption(olp::dataservice::read::FetchOptions::CacheOnly);
578-
579-
auto future = client.ListVersions(request);
580-
auto response = future.GetFuture().get();
581-
582-
ASSERT_FALSE(response.IsSuccessful());
583-
584-
ASSERT_EQ(olp::client::ErrorCode::InvalidArgument,
585-
response.GetError().GetErrorCode());
586-
}
587570
{
588571
SCOPED_TRACE("Get versions list error");
589572

590-
auto request =
591-
olp::dataservice::read::VersionsRequest()
592-
.WithStartVersion(kStartVersion)
593-
.WithEndVersion(kEndVersion)
594-
.WithFetchOption(olp::dataservice::read::FetchOptions::OnlineOnly);
573+
auto request = olp::dataservice::read::VersionsRequest()
574+
.WithStartVersion(kStartVersion)
575+
.WithEndVersion(kEndVersion);
595576

596577
EXPECT_CALL(*network_mock_,
597578
Send(common::IsGetRequest(kUrlVersionsList), _, _, _, _))
@@ -609,24 +590,6 @@ TEST_F(CatalogClientTest, GetVersionsList) {
609590
ASSERT_EQ(static_cast<int>(olp::http::HttpStatusCode::TOO_MANY_REQUESTS),
610591
response.GetError().GetHttpStatusCode());
611592
}
612-
{
613-
SCOPED_TRACE("Get versions list cache with update");
614-
615-
auto request =
616-
olp::dataservice::read::VersionsRequest()
617-
.WithStartVersion(kStartVersion)
618-
.WithEndVersion(kEndVersion)
619-
.WithFetchOption(olp::dataservice::read::CacheWithUpdate);
620-
621-
auto future = client.ListVersions(request);
622-
auto response = future.GetFuture().get();
623-
624-
ASSERT_FALSE(response.IsSuccessful())
625-
<< ApiErrorToString(response.GetError());
626-
627-
ASSERT_EQ(olp::client::ErrorCode::InvalidArgument,
628-
response.GetError().GetErrorCode());
629-
}
630593
}
631594

632595
TEST_F(CatalogClientTest, GetVersionsListCancel) {

0 commit comments

Comments
 (0)