olp-cpp-sdk  1.22.0
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/deprecated.h>
27 #include <olp/dataservice/read/DataServiceReadApi.h>
28 #include <olp/dataservice/read/FetchOptions.h>
29 #include <boost/optional.hpp>
30 
31 namespace olp {
32 namespace dataservice {
33 namespace read {
34 
39 class DATASERVICE_READ_API VersionsRequest final {
40  public:
54  inline VersionsRequest& WithStartVersion(std::int64_t version) {
55  start_version_ = version;
56  return *this;
57  }
58 
66  inline std::int64_t GetStartVersion() const { return start_version_; }
67 
82  inline VersionsRequest& WithEndVersion(std::int64_t version) {
83  end_version_ = version;
84  return *this;
85  }
86 
94  inline std::int64_t GetEndVersion() const { return end_version_; }
95 
106  inline const boost::optional<std::string>& GetBillingTag() const {
107  return billing_tag_;
108  }
109 
119  inline VersionsRequest& WithBillingTag(boost::optional<std::string> tag) {
120  billing_tag_ = std::move(tag);
121  return *this;
122  }
123 
134  inline VersionsRequest& WithBillingTag(std::string tag) {
135  billing_tag_ = std::move(tag);
136  return *this;
137  }
138 
144  inline std::string CreateKey() const {
145  std::stringstream out;
146  out << "[";
147  out << GetStartVersion() << ", " << GetEndVersion();
148  out << "]";
149  if (GetBillingTag()) {
150  out << "$" << GetBillingTag().get();
151  }
152  return out.str();
153  }
154 
155  private:
156  std::int64_t start_version_;
157  std::int64_t end_version_;
158  boost::optional<std::string> billing_tag_;
159 };
160 
161 } // namespace read
162 } // namespace dataservice
163 } // namespace olp
Encapsulates the fields required to request a list of versions for the given catalog.
Definition: VersionsRequest.h:39
const boost::optional< std::string > & GetBillingTag() const
Gets the billing tag to group billing records together.
Definition: VersionsRequest.h:106
std::int64_t GetStartVersion() const
Gets the catalog metadata start version of the requested versions list.
Definition: VersionsRequest.h:66
VersionsRequest & WithBillingTag(boost::optional< std::string > tag)
Sets the billing tag for the request.
Definition: VersionsRequest.h:119
VersionsRequest & WithBillingTag(std::string tag)
Sets the billing tag for the request.
Definition: VersionsRequest.h:134
VersionsRequest & WithEndVersion(std::int64_t version)
Sets the catalog metadata end version.
Definition: VersionsRequest.h:82
VersionsRequest & WithStartVersion(std::int64_t version)
Sets the catalog metadata start version.
Definition: VersionsRequest.h:54
std::string CreateKey() const
Creates a readable format for the request.
Definition: VersionsRequest.h:144
std::int64_t GetEndVersion() const
Gets the catalog metadata end version of the requested versions list.
Definition: VersionsRequest.h:94
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24