| Qore GoogleDataProvider Module Reference 2.0

Loading...
Searching...
No Matches
GoogleDataProviderBase.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
24
26 namespace GoogleDataProvider {
28 class GoogleDataProviderBase : public DataProvider::AbstractDataProvider {
29
30 public:
32 const DiscoveryUrlBase = "https://discovery.googleapis.com/discovery/v1/apis";
33
35 const InitTimeout = 10s;
36
37 protected:
39 *RestClient::RestClient rest;
40
42 static hash<string, string> api_map;
43
45 static hash<string, hash<auto>> info_map;
46
48 static hash<string, hash<string, AbstractDataProviderType>> input_schema_map;
49
51 static hash<string, hash<string, AbstractDataProviderType>> output_schema_map;
52
54 // {request_type -> type, response_type -> type, http_method -> string, path -> string}
55 static hash<string, hash<auto>> request_map;
56
58 static Mutex m();
59
60 public:
61
63 constructor();
64
65
67 constructor(RestClient::RestClient rest);
68
69
71 setLogger(*LoggerInterface logger);
72
73
75
83 *hash<auto> prepareRequest(auto req, *hash<string, softstring> implicit_path_args, *bool backfill_request_body);
84
85
87
90 updateConnectionObjects(object conn, object connobj);
91
92
94 setRestClient(RestClient rest);
95
96
97 RestClient getRestClient();
98
99
101 protected:
102 bool needsBackfillRequestBody();
103 public:
104
105
107
115 *hash<auto> prepareRequestIntern(AbstractDataProviderType request_type, auto req0, *hash<string, softstring> implicit_path_args, *bool backfill_request_body);
116
117
118 string getQueryValue(string key, AbstractDataProviderType type, auto val);
119
120
122 static string cap(string word);
123
125 protected:
126 hash<auto> backfillRequestBody(auto req);
127 public:
128
129
131 static RestClient::RestClient getRestConnection(*hash<auto> options);
132
133 static hash<auto> getRequestInfoForResource(string api, string resource);
134
136 static string getPathForSchema(string api, string resource);
137
139 static string getMethodForSchema(string api, string path);
140
142 static DataProvider::AbstractDataProviderType getResponseTypeForSchema(string api, string resource);
143
145 static DataProvider::AbstractDataProviderType getRequestTypeForSchema(string api, string resource, ...);
146
148 static checkResource(string api, list<string> resource_path);
149
151 static *hash<string, bool> getMethodsForResource(string api, list<string> resource_path, *hash<auto> path_args);
152
154 static DataProvider::AbstractDataProviderType getRequestTypeForSchemaArgs(string api, string path, *list<auto> args);
155
157 static DataProvider::AbstractDataProviderType getTypeForSchema(string api, string schema);
158
160 static DataProvider::AbstractDataProviderType getInputTypeForSchema(string api, string schema);
161
163 static hash<auto> getRequestInfo(string api);
164
166 protected:
167 static hash<auto> processRequests(string api, hash<auto> h, TypeResolverHelper unresolved);
168 public:
169
170
172 static hash<auto> processRequest(string key, hash<auto> info, TypeResolverHelper unresolved);
173
175 static hash<string, AbstractDataProviderType> getApi(string api);
176
178 static hash<string, AbstractDataProviderType> getInputSchemasForApi(string api);
179
181 static hash<string, AbstractDataProviderType> getInputSchemaMap(string api, hash<auto> api_info);
182
184 static hash<string, AbstractDataProviderType> getOutputSchemaMap(string api, hash<auto> api_info);
185
186 static hash<auto> getSchemaInfo(string api);
187
189 protected:
190 static AbstractDataProviderType makeTypeFromSchemaInfo(HashDataType type, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
191 public:
192
193
195 protected:
196 static AbstractDataProviderType makeTypeFromSchemaInfo(ListDataType type, string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
197 public:
198
199
201 protected:
202 static AbstractDataProviderType makeTypeFromSchemaInfo(QoreDataField field, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
203 public:
204
205
207 protected:
208 static AbstractDataProviderType makeTypeFromSchemaInfo(string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
209 public:
210
211
213 static ListDataType makeListFromSchemaInfo(string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
214
216 static HashDataType makeHashFromSchemaInfo(string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
217
219 static QoreDataField makeFieldFromProperty(HashDataType h, string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
220
222 static string getUrlForApi(string api, RestClient::RestClient rest);
223};
224};
225
226 namespace Priv {
227 class TypeResolverHelper {
228
229 public:
230
231
232 protected:
234 list<hash<auto>> lists;
235
237 list<hash<auto>> hashes;
238
240 list<hash<auto>> fields;
241
243 list<hash<auto>> requests;
244
246 list<hash<auto>> responses;
247
248 public:
249
250 addRequestTypeReference(string key, string ref, *bool required);
251
252
253 addResponseTypeReference(string key, string ref, *bool required);
254
255
256 AbstractDataProviderType addReference(HashDataType type, string ref, *bool required);
257
258
259 AbstractDataProviderType addReference(ListDataType type, string ref);
260
261
262 AbstractDataProviderType addReference(QoreDataField field, string ref);
263
264
265 resolve(hash<string, AbstractDataProviderType> schemas);
266
267
268 hash<auto> resolveRequests(string api, hash<auto> req, hash<string, hash<string, AbstractDataProviderType>> input_schema_map, hash<string, hash<string, AbstractDataProviderType>> output_schema_map);
269
270
271 static AbstractDataProviderType getType(string ref, hash<string, AbstractDataProviderType> schemas, *bool required);
272};
273};
DataProvider::AbstractDataProvider
DataProvider::AbstractDataProviderType
GoogleDataProvider::GoogleDataProviderBase
The Google data provider base class.
Definition GoogleDataProviderBase.qc.dox.h:28
GoogleDataProvider::GoogleDataProviderBase::cap
static string cap(string word)
Returns the given word capitalized.
GoogleDataProvider::GoogleDataProviderBase::makeTypeFromSchemaInfo
static AbstractDataProviderType makeTypeFromSchemaInfo(ListDataType type, string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a type from a Google schema description.
GoogleDataProvider::GoogleDataProviderBase::getInputTypeForSchema
static DataProvider::AbstractDataProviderType getInputTypeForSchema(string api, string schema)
Returns an input / inbound data type for the given Google schema.
GoogleDataProvider::GoogleDataProviderBase::getResponseTypeForSchema
static DataProvider::AbstractDataProviderType getResponseTypeForSchema(string api, string resource)
Returns a response data type for the given API.
GoogleDataProvider::GoogleDataProviderBase::getRequestTypeForSchema
static DataProvider::AbstractDataProviderType getRequestTypeForSchema(string api, string resource,...)
Returns a request data type for the given API.
GoogleDataProvider::GoogleDataProviderBase::request_map
static hash< string, hash< auto > > request_map
schema cache; API -> request path ->
Definition GoogleDataProviderBase.qc.dox.h:55
GoogleDataProvider::GoogleDataProviderBase::m
static Mutex m()
schema cache lock
GoogleDataProvider::GoogleDataProviderBase::getApi
static hash< string, AbstractDataProviderType > getApi(string api)
Returns all output schemas for the given API.
GoogleDataProvider::GoogleDataProviderBase::rest
*RestClient::RestClient rest
The REST client object for API calls.
Definition GoogleDataProviderBase.qc.dox.h:39
GoogleDataProvider::GoogleDataProviderBase::input_schema_map
static hash< string, hash< string, AbstractDataProviderType > > input_schema_map
input schema cache; API -> schema name -> type
Definition GoogleDataProviderBase.qc.dox.h:48
GoogleDataProvider::GoogleDataProviderBase::getRequestTypeForSchemaArgs
static DataProvider::AbstractDataProviderType getRequestTypeForSchemaArgs(string api, string path, *list< auto > args)
Returns a data type for the given request.
GoogleDataProvider::GoogleDataProviderBase::prepareRequest
*hash< auto > prepareRequest(auto req, *hash< string, softstring > implicit_path_args, *bool backfill_request_body)
Prepares a request with a request type created from the Discovery API.
GoogleDataProvider::GoogleDataProviderBase::getMethodForSchema
static string getMethodForSchema(string api, string path)
Returns the HTTP method for the given API.
GoogleDataProvider::GoogleDataProviderBase::makeHashFromSchemaInfo
static HashDataType makeHashFromSchemaInfo(string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a hash from a Google schema description.
GoogleDataProvider::GoogleDataProviderBase::makeTypeFromSchemaInfo
static AbstractDataProviderType makeTypeFromSchemaInfo(string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a type from a Google schema description.
GoogleDataProvider::GoogleDataProviderBase::prepareRequestIntern
*hash< auto > prepareRequestIntern(AbstractDataProviderType request_type, auto req0, *hash< string, softstring > implicit_path_args, *bool backfill_request_body)
Prepares a request with a request type created from the Discovery API.
GoogleDataProvider::GoogleDataProviderBase::output_schema_map
static hash< string, hash< string, AbstractDataProviderType > > output_schema_map
output schema cache; API -> schema name -> type
Definition GoogleDataProviderBase.qc.dox.h:51
GoogleDataProvider::GoogleDataProviderBase::getRequestInfo
static hash< auto > getRequestInfo(string api)
Returns all request types for the given API.
GoogleDataProvider::GoogleDataProviderBase::getUrlForApi
static string getUrlForApi(string api, RestClient::RestClient rest)
Returns the URL for the given API.
GoogleDataProvider::GoogleDataProviderBase::constructor
constructor()
Creates the object.
GoogleDataProvider::GoogleDataProviderBase::makeTypeFromSchemaInfo
static AbstractDataProviderType makeTypeFromSchemaInfo(HashDataType type, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a type from a Google schema description.
GoogleDataProvider::GoogleDataProviderBase::InitTimeout
const InitTimeout
Initialization I/O timeout.
Definition GoogleDataProviderBase.qc.dox.h:35
GoogleDataProvider::GoogleDataProviderBase::setRestClient
setRestClient(RestClient rest)
Override REST client.
GoogleDataProvider::GoogleDataProviderBase::getTypeForSchema
static DataProvider::AbstractDataProviderType getTypeForSchema(string api, string schema)
Returns a data type for the given Google schema.
GoogleDataProvider::GoogleDataProviderBase::getInputSchemasForApi
static hash< string, AbstractDataProviderType > getInputSchemasForApi(string api)
Returns all input schemas for the given API.
GoogleDataProvider::GoogleDataProviderBase::constructor
constructor(RestClient::RestClient rest)
Creates the object.
GoogleDataProvider::GoogleDataProviderBase::backfillRequestBody
hash< auto > backfillRequestBody(auto req)
Used to set attributes in the request body that are not set in the request.
GoogleDataProvider::GoogleDataProviderBase::checkResource
static checkResource(string api, list< string > resource_path)
Check the given path for resources.
GoogleDataProvider::GoogleDataProviderBase::updateConnectionObjects
updateConnectionObjects(object conn, object connobj)
Update any connection used by the data provider.
GoogleDataProvider::GoogleDataProviderBase::getPathForSchema
static string getPathForSchema(string api, string resource)
Returns the path for the given API.
GoogleDataProvider::GoogleDataProviderBase::makeListFromSchemaInfo
static ListDataType makeListFromSchemaInfo(string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a list from a Google schema description.
GoogleDataProvider::GoogleDataProviderBase::makeFieldFromProperty
static QoreDataField makeFieldFromProperty(HashDataType h, string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a hash from a Google schema description.
GoogleDataProvider::GoogleDataProviderBase::getOutputSchemaMap
static hash< string, AbstractDataProviderType > getOutputSchemaMap(string api, hash< auto > api_info)
Creates the output schema map for the given API.
GoogleDataProvider::GoogleDataProviderBase::needsBackfillRequestBody
bool needsBackfillRequestBody()
If the request body should be populated with missing values.
GoogleDataProvider::GoogleDataProviderBase::getRestConnection
static RestClient::RestClient getRestConnection(*hash< auto > options)
Returns a GoogleRestClient connection from the options.
GoogleDataProvider::GoogleDataProviderBase::processRequests
static hash< auto > processRequests(string api, hash< auto > h, TypeResolverHelper unresolved)
Process requests.
GoogleDataProvider::GoogleDataProviderBase::setLogger
setLogger(*LoggerInterface logger)
Accepts a LoggerInterface object for logging (or clears it)
GoogleDataProvider::GoogleDataProviderBase::api_map
static hash< string, string > api_map
API -> URL map.
Definition GoogleDataProviderBase.qc.dox.h:42
GoogleDataProvider::GoogleDataProviderBase::processRequest
static hash< auto > processRequest(string key, hash< auto > info, TypeResolverHelper unresolved)
Returns a hash from a Google schema description.
GoogleDataProvider::GoogleDataProviderBase::getMethodsForResource
static *hash< string, bool > getMethodsForResource(string api, list< string > resource_path, *hash< auto > path_args)
Returns a hash of all non-subscription methods for the given resource.
GoogleDataProvider::GoogleDataProviderBase::DiscoveryUrlBase
const DiscoveryUrlBase
Discovery URL base.
Definition GoogleDataProviderBase.qc.dox.h:32
GoogleDataProvider::GoogleDataProviderBase::makeTypeFromSchemaInfo
static AbstractDataProviderType makeTypeFromSchemaInfo(QoreDataField field, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a type from a Google schema description.
GoogleDataProvider::GoogleDataProviderBase::info_map
static hash< string, hash< auto > > info_map
Schema info: API -> info.
Definition GoogleDataProviderBase.qc.dox.h:45
GoogleDataProvider::GoogleDataProviderBase::getInputSchemaMap
static hash< string, AbstractDataProviderType > getInputSchemaMap(string api, hash< auto > api_info)
Creates the input schema map for the given API.
RestClient::RestClient
GoogleDataProvider
Qore GoogleDataProvider module definition.
Definition GoogleApiDataProvider.qc.dox.h:26
Priv
RestClient