olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
VersionsRequest.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 <sstream>
23#include <string>
24#include <utility>
25
26#include <olp/core/porting/optional.h>
27#include <olp/dataservice/read/DataServiceReadApi.h>
28
29namespace olp {
30namespace dataservice {
31namespace read {
32
37class DATASERVICE_READ_API VersionsRequest final {
38 public:
52 VersionsRequest& WithStartVersion(std::int64_t version) {
53 start_version_ = version;
54 return *this;
55 }
56
64 std::int64_t GetStartVersion() const { return start_version_; }
65
80 VersionsRequest& WithEndVersion(std::int64_t version) {
81 end_version_ = version;
82 return *this;
83 }
84
92 std::int64_t GetEndVersion() const { return end_version_; }
93
104 const porting::optional<std::string>& GetBillingTag() const {
105 return billing_tag_;
106 }
107
117 template <class T = porting::optional<std::string>>
119 billing_tag_ = std::forward<T>(tag);
120 return *this;
121 }
122
133 VersionsRequest& WithBillingTag(std::string tag) {
134 billing_tag_ = std::move(tag);
135 return *this;
136 }
137
143 std::string CreateKey() const {
144 std::stringstream out;
145 out << "[";
146 out << GetStartVersion() << ", " << GetEndVersion();
147 out << "]";
148 if (GetBillingTag()) {
149 out << "$" << *GetBillingTag();
150 }
151 return out.str();
152 }
153
154 private:
155 std::int64_t start_version_ = -1;
156 std::int64_t end_version_ = -1;
157 porting::optional<std::string> billing_tag_;
158};
159
160} // namespace read
161} // namespace dataservice
162} // namespace olp
Encapsulates the fields required to request a list of versions for the given catalog.
Definition VersionsRequest.h:37
std::int64_t GetStartVersion() const
Gets the catalog metadata start version of the requested versions list.
Definition VersionsRequest.h:64
VersionsRequest & WithEndVersion(std::int64_t version)
Sets the catalog metadata end version.
Definition VersionsRequest.h:80
std::string CreateKey() const
Creates a readable format for the request.
Definition VersionsRequest.h:143
VersionsRequest & WithBillingTag(T &&tag)
Sets the billing tag for the request.
Definition VersionsRequest.h:118
const porting::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition VersionsRequest.h:104
VersionsRequest & WithBillingTag(std::string tag)
Sets the billing tag for the request.
Definition VersionsRequest.h:133
VersionsRequest & WithStartVersion(std::int64_t version)
Sets the catalog metadata start version.
Definition VersionsRequest.h:52
std::int64_t GetEndVersion() const
Gets the catalog metadata end version of the requested versions list.
Definition VersionsRequest.h:92
Rules all the other namespaces.
Definition AppleSignInProperties.h:24