10Duke Enterprise C++ Client
Loading...
Searching...
No Matches
FluentLicenseCheckoutBuilder.h
1#ifndef TENDUKE_EE_LICENSING_FLUENTCHECKOUTBUILDER_H
2#define TENDUKE_EE_LICENSING_FLUENTCHECKOUTBUILDER_H
3
4#include "../../config/ClientProperties.h"
5#include "./LicenseCheckoutParameters.h"
6
7#include <string>
8#include <utility>
9#include <vector>
10
11namespace tenduke { namespace ee { namespace licensing {
12
17template<typename BUILDER>
19{
20public:
26 : clientProperties(std::move(clientProperties))
27 , consumeCount(tenduke::ee::licensing::LicenseCheckoutParameters::DEFAULT_CONSUME_COUNT)
28 , consumeDuration(tenduke::ee::licensing::LicenseCheckoutParameters::DEFAULT_CONSUME_DURATION)
29 , consumptionMode(tenduke::ee::licensing::LicenseCheckoutParameters::ConsumptionMode::DEFAULT)
30 , entitlementId("")
31 , organizationId("")
32 {}
33
48 BUILDER & seat(
49 const std::string &productName,
50 const std::string &requestedVersion = "",
51 const std::string &licenseId = ""
52 ) {
53 return item(productName, requestedVersion, licenseId);
54 }
55
66 BUILDER & item(
67 const std::string &itemName,
68 const std::string &requestedVersion = "",
69 const std::string &licenseId = ""
70 ) {
71 items.emplace_back(itemName, requestedVersion, licenseId);
72 return static_cast<BUILDER&>(*this);
73 }
74
81 BUILDER & count(std::uint64_t pConsumeCount)
82 {
83 this->consumeCount = pConsumeCount;
84 return static_cast<BUILDER&>(*this);
85 }
86
87
93 BUILDER & duration(std::uint64_t pConsumeDuration)
94 {
95 this->consumeDuration = pConsumeDuration;
96 return static_cast<BUILDER&>(*this);
97 }
98
99
107 BUILDER & fromEntitlement(const std::string &pEntitlementId)
108 {
109 this->entitlementId = pEntitlementId;
110 return static_cast<BUILDER&>(*this);
111 }
112
113
121 BUILDER & fromOrganization(const std::string &pOrganizationId)
122 {
123 this->organizationId = pOrganizationId;
124 return static_cast<BUILDER&>(*this);
125 }
126
127
135 {
136 this->consumptionMode = pConsumptionMode;
137 return static_cast<BUILDER&>(*this);
138 }
139
140
148 BUILDER & version(const std::string &pGlobalVersion)
149 {
150 this->globalVersion = pGlobalVersion;
151 return static_cast<BUILDER&>(*this);
152 }
153
154
155protected:
161 {
163 items,
164 consumptionMode,
165 globalVersion,
166 clientProperties,
167 consumeDuration,
168 consumeCount,
169 entitlementId,
170 organizationId
171 );
172 }
173
174private:
175 ::tenduke::ee::ClientProperties clientProperties;
176 std::uint64_t consumeCount;
177 std::uint64_t consumeDuration;
179 std::string entitlementId;
180 std::string globalVersion;
181 std::string organizationId;
182 std::vector<tenduke::ee::licensing::LicenseCheckoutItem> items;
183};
184
185}}}
186
187#endif //TENDUKE_EE_LICENSING_FLUENTCHECKOUTBUILDER_H
Inheritable base class building checkout request parameters fluently.
Definition FluentLicenseCheckoutBuilder.h:19
BUILDER & count(std::uint64_t pConsumeCount)
Sets "The requested number of units to be consumed from the license’s use count.".
Definition FluentLicenseCheckoutBuilder.h:81
FluentLicenseCheckoutBuilder(::tenduke::ee::ClientProperties clientProperties)
Constructs new instance.
Definition FluentLicenseCheckoutBuilder.h:25
BUILDER & mode(enum tenduke::ee::licensing::LicenseCheckoutParameters::ConsumptionMode pConsumptionMode)
Sets "The license consumption mode requested." (See the enumeration for the documentation of the valu...
Definition FluentLicenseCheckoutBuilder.h:134
BUILDER & fromEntitlement(const std::string &pEntitlementId)
Sets id of the Entitlement, from which the licenses will be checked from.
Definition FluentLicenseCheckoutBuilder.h:107
BUILDER & item(const std::string &itemName, const std::string &requestedVersion="", const std::string &licenseId="")
Adds an item to checkout.
Definition FluentLicenseCheckoutBuilder.h:66
BUILDER & duration(std::uint64_t pConsumeDuration)
Sets "The requested duration of the license token (and the lease) in milliseconds....
Definition FluentLicenseCheckoutBuilder.h:93
BUILDER & version(const std::string &pGlobalVersion)
Sets default version to checkout.
Definition FluentLicenseCheckoutBuilder.h:148
virtual tenduke::ee::licensing::LicenseCheckoutParameters buildParameters()
Builds the parameters.
Definition FluentLicenseCheckoutBuilder.h:160
BUILDER & seat(const std::string &productName, const std::string &requestedVersion="", const std::string &licenseId="")
Adds "checkout one seat for product" to the request.
Definition FluentLicenseCheckoutBuilder.h:48
BUILDER & fromOrganization(const std::string &pOrganizationId)
Sets id of the Organization, from which the licenses will be checked from.
Definition FluentLicenseCheckoutBuilder.h:121
Parameters for license checkout request.
Definition LicenseCheckoutParameters.h:18
ConsumptionMode
License consumption modes.
Definition LicenseCheckoutParameters.h:21
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4
Client properties.
Definition ClientProperties.h:14