nx_metadata_sdk 1.0 Metadata SDK

i_utility_provider.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #pragma once
4
5 #include <nx/sdk/i_string.h>
6 #include <nx/sdk/interface.h>
7 #include <nx/sdk/result.h>
8
9 namespace nx::sdk {
10
21 class IUtilityProvider0: public Interface<IUtilityProvider0>
22 {
23 public:
24 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider"); }
25
30 virtual int64_t vmsSystemTimeSinceEpochMs() const = 0;
31
33 protected: virtual const IString* getHomeDir() const = 0;
45 public: std::string homeDir() const { return Ptr(getHomeDir())->str(); }
46 };
47
48 class IUtilityProvider1: public Interface<IUtilityProvider1, IUtilityProvider0>
49 {
50 public:
51 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider1"); }
52
54 protected: virtual const IString* getServerSdkVersion() const = 0;
58 public: std::string serverSdkVersion() const { return Ptr(getServerSdkVersion())->str(); }
59 };
60
61 class IUtilityProvider2: public Interface<IUtilityProvider2, IUtilityProvider1>
62 {
63 public:
64 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider2"); }
65
66 virtual const char* serverId() const = 0;
67 };
68
69 class IUtilityProvider3: public Interface<IUtilityProvider3, IUtilityProvider2>
70 {
71 public:
72 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider3"); }
73
74 virtual IString* cloudSystemId() const = 0;
75 virtual IString* cloudAuthKey() const = 0;
76 };
77
78 class IUtilityProvider: public Interface<IUtilityProvider, IUtilityProvider3>
79 {
80 public:
81 static auto interfaceId() { return makeId("nx::sdk::IUtilityProvider4"); }
82
83 enum class HttpDomainName: int
84 {
85 cloud,
86 vms,
87 };
88
93 class IHttpRequestCompletionHandler: public Interface<IHttpRequestCompletionHandler>
94 {
95 public:
96 static auto interfaceId() { return makeId("nx::sdk::IHttpRequestCompletionHandler"); }
97
98 virtual void execute(Result<IString*> response) = 0;
99 };
100 using IHttpRequestCompletionHandler0 = IHttpRequestCompletionHandler;
101
103 protected: virtual void doSendHttpRequest(
104 HttpDomainName requestDomainName,
105 const char* url,
106 const char* httpMethod,
107 const char* mimeType,
108 const char* requestBody,
109 IHttpRequestCompletionHandler* callback) const = 0;
116 public: void sendHttpRequest(
117 HttpDomainName requestDomainName,
118 const char* url,
119 const char* httpMethod,
120 const char* mimeType,
121 const char* requestBody,
122 Ptr<IHttpRequestCompletionHandler> callback) const
123 {
124 doSendHttpRequest(
125 requestDomainName, url, httpMethod, mimeType, requestBody, callback.get());
126 }
127 };
128 using IUtilityProvider4 = IUtilityProvider;
129
130 } // namespace nx::sdk
nx::sdk::IUtilityProvider2
Definition: i_utility_provider.h:61
nx::sdk::Interface
Definition: interface.h:48
nx::sdk::IUtilityProvider0::getHomeDir
virtual const IString * getHomeDir() const =0
nx::sdk::IUtilityProvider1::serverSdkVersion
std::string serverSdkVersion() const
Definition: i_utility_provider.h:58
nx::sdk::IUtilityProvider3
Definition: i_utility_provider.h:69
nx::sdk::IUtilityProvider1
Definition: i_utility_provider.h:48
nx::sdk::Ptr
Definition: ptr.h:18
nx::sdk::IUtilityProvider0::homeDir
std::string homeDir() const
Definition: i_utility_provider.h:45
nx::sdk::IUtilityProvider0::vmsSystemTimeSinceEpochMs
virtual int64_t vmsSystemTimeSinceEpochMs() const =0
nx::sdk::IString
Definition: i_string.h:9
nx::sdk::IUtilityProvider::IHttpRequestCompletionHandler
Definition: i_utility_provider.h:93
nx::sdk::Result
Definition: result.h:48
nx::sdk::IUtilityProvider
Definition: i_utility_provider.h:78
nx::sdk::IUtilityProvider0
Definition: i_utility_provider.h:21
nx::sdk
Definition: device_agent.h:12
nx::sdk::IUtilityProvider::sendHttpRequest
void sendHttpRequest(HttpDomainName requestDomainName, const char *url, const char *httpMethod, const char *mimeType, const char *requestBody, Ptr< IHttpRequestCompletionHandler > callback) const
Definition: i_utility_provider.h:116
nx::sdk::IUtilityProvider::doSendHttpRequest
virtual void doSendHttpRequest(HttpDomainName requestDomainName, const char *url, const char *httpMethod, const char *mimeType, const char *requestBody, IHttpRequestCompletionHandler *callback) const =0
nx::sdk::IUtilityProvider1::getServerSdkVersion
virtual const IString * getServerSdkVersion() const =0
nx::sdk::IRefCountable::makeId
static const InterfaceId * makeId(const char(&charArray)[len])
Definition: i_ref_countable.h:77