10Duke Enterprise C++ Client
Loading...
Searching...
No Matches
FluentLicenseRenewBuilder.h
1#ifndef TENDUKE_EE_LICENSING_FLUENTLICENSERENEWBUILDER_H
2#define TENDUKE_EE_LICENSING_FLUENTLICENSERENEWBUILDER_H
3
4#include "./LicenseRenewItem.h"
5#include "./LicenseRenewParameters.h"
6#include "../Lease.h"
7
8#include <cstdint>
9#include <map>
10#include <string>
11#include <vector>
12
13namespace tenduke { namespace ee { namespace licensing {
14
19template<typename BUILDER>
21{
22public:
28 BUILDER & lease(const ::tenduke::ee::licensing::Lease &lease)
29 {
30 leasesToRenew.emplace_back(::tenduke::ee::licensing::LicenseRenewItem(
31 lease.name,
32 lease.leaseId
33 ));
34 return static_cast<BUILDER&>(*this);
35 }
36
42 BUILDER & leases(const std::vector<::tenduke::ee::licensing::Lease> &pLeases)
43 {
44 for (auto const &leaseToRenew : pLeases) {
45 lease(leaseToRenew);
46 }
47 return static_cast<BUILDER&>(*this);
48 }
49
57 BUILDER & leases(const std::map<std::string, ::tenduke::ee::licensing::Lease> &pLeases)
58 {
59 for (auto const &leaseToRenew : pLeases) {
60 lease(leaseToRenew.second);
61 }
62 return static_cast<BUILDER&>(*this);
63 }
64
65
71 BUILDER & duration(std::uint64_t pConsumeDuration)
72 {
73 this->consumeDuration = pConsumeDuration;
74 return static_cast<BUILDER&>(*this);
75 }
76
77
78protected:
83 virtual ::tenduke::ee::licensing::LicenseRenewParameters buildParameters()
84 {
85 return ::tenduke::ee::licensing::LicenseRenewParameters(
86 leasesToRenew,
87 consumeDuration
88 );
89 }
90
91private:
92 std::uint64_t consumeDuration;
93 std::vector<::tenduke::ee::licensing::LicenseRenewItem> leasesToRenew;
94};
95
96}}}
97
98#endif //TENDUKE_EE_LICENSING_FLUENTLICENSERENEWBUILDER_H
Inheritable base class building renew request parameters fluently.
Definition FluentLicenseRenewBuilder.h:21
BUILDER & leases(const std::map< std::string, ::tenduke::ee::licensing::Lease > &pLeases)
Adds leases to renew to the request.
Definition FluentLicenseRenewBuilder.h:57
BUILDER & lease(const ::tenduke::ee::licensing::Lease &lease)
Adds lease to renew to the request.
Definition FluentLicenseRenewBuilder.h:28
BUILDER & duration(std::uint64_t pConsumeDuration)
Sets "The requested duration of the license token (and the lease) in milliseconds....
Definition FluentLicenseRenewBuilder.h:71
virtual ::tenduke::ee::licensing::LicenseRenewParameters buildParameters()
Builds the parameters.
Definition FluentLicenseRenewBuilder.h:83
BUILDER & leases(const std::vector<::tenduke::ee::licensing::Lease > &pLeases)
Adds leases to renew to the request.
Definition FluentLicenseRenewBuilder.h:42
A license lease to renew.
Definition LicenseRenewItem.h:12
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4