Qore GoogleDataProvider Module Reference 2.0
Loading...
Searching...
No Matches
GoogleDataProviderBase.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
26namespace GoogleDataProvider {
28class GoogleDataProviderBase : public DataProvider::AbstractDataProvider {
29
30public:
32 const DiscoveryUrlBase = "https://discovery.googleapis.com/discovery/v1/apis";
33
35 const InitTimeout = 10s;
36
37protected:
39 *GoogleRestClient::GoogleRestClient 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
60public:
61
64
65
67 constructor(GoogleRestClient::GoogleRestClient 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
94protected:
96public:
97
98
100
108 *hash<auto> prepareRequestIntern(AbstractDataProviderType request_type, auto req0, *hash<string, softstring> implicit_path_args, *bool backfill_request_body);
109
110
111 string getQueryValue(string key, AbstractDataProviderType type, auto val);
112
113
115 static string cap(string word);
116
118protected:
119 hash<auto> backfillRequestBody(auto req);
120public:
121
122
124 static GoogleRestClient::GoogleRestClient getRestConnection(*hash<auto> options);
125
126 static hash<auto> getRequestInfoForResource(string api, string resource);
127
129 static string getPathForSchema(string api, string resource);
130
132 static string getMethodForSchema(string api, string path);
133
135 static DataProvider::AbstractDataProviderType getResponseTypeForSchema(string api, string resource);
136
138 static DataProvider::AbstractDataProviderType getRequestTypeForSchema(string api, string resource, ...);
139
141 static checkResource(string api, list<string> resource_path);
142
144 static *hash<string, bool> getMethodsForResource(string api, list<string> resource_path, *hash<auto> path_args);
145
147 static DataProvider::AbstractDataProviderType getRequestTypeForSchemaArgs(string api, string path, *list<auto> args);
148
150 static DataProvider::AbstractDataProviderType getTypeForSchema(string api, string schema);
151
153 static DataProvider::AbstractDataProviderType getInputTypeForSchema(string api, string schema);
154
156 static hash<auto> getRequestInfo(string api);
157
159protected:
160 static hash<auto> processRequests(string api, hash<auto> h, TypeResolverHelper unresolved);
161public:
162
163
165 static hash<auto> processRequest(string key, hash<auto> info, TypeResolverHelper unresolved);
166
168 static hash<string, AbstractDataProviderType> getApi(string api);
169
171 static hash<string, AbstractDataProviderType> getInputSchemasForApi(string api);
172
174 static hash<string, AbstractDataProviderType> getInputSchemaMap(string api, hash<auto> api_info);
175
177 static hash<string, AbstractDataProviderType> getOutputSchemaMap(string api, hash<auto> api_info);
178
179 static hash<auto> getSchemaInfo(string api);
180
182protected:
183 static AbstractDataProviderType makeTypeFromSchemaInfo(HashDataType type, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
184public:
185
186
188protected:
189 static AbstractDataProviderType makeTypeFromSchemaInfo(ListDataType type, string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
190public:
191
192
194protected:
195 static AbstractDataProviderType makeTypeFromSchemaInfo(QoreDataField field, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
196public:
197
198
200protected:
201 static AbstractDataProviderType makeTypeFromSchemaInfo(string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
202public:
203
204
206 static ListDataType makeListFromSchemaInfo(string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
207
209 static HashDataType makeHashFromSchemaInfo(string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
210
212 static QoreDataField makeFieldFromProperty(HashDataType h, string key, hash<auto> info, TypeResolverHelper unresolved, *bool for_input);
213
215 static string getUrlForApi(string api, RestClient::RestClient rest);
216};
217};
218
219namespace Priv {
220class TypeResolverHelper {
221
222public:
223
224
225protected:
227 list<hash<auto>> lists;
228
230 list<hash<auto>> hashes;
231
233 list<hash<auto>> fields;
234
236 list<hash<auto>> requests;
237
239 list<hash<auto>> responses;
240
241public:
242
243 addRequestTypeReference(string key, string ref, *bool required);
244
245
246 addResponseTypeReference(string key, string ref, *bool required);
247
248
249 AbstractDataProviderType addReference(HashDataType type, string ref, *bool required);
250
251
252 AbstractDataProviderType addReference(ListDataType type, string ref);
253
254
255 AbstractDataProviderType addReference(QoreDataField field, string ref);
256
257
258 resolve(hash<string, AbstractDataProviderType> schemas);
259
260
261 hash<auto> resolveRequests(string api, hash<auto> req, hash<string, hash<string, AbstractDataProviderType>> input_schema_map, hash<string, hash<string, AbstractDataProviderType>> output_schema_map);
262
263
264 static AbstractDataProviderType getType(string ref, hash<string, AbstractDataProviderType> schemas, *bool required);
265};
266};
The Google data provider base class.
Definition GoogleDataProviderBase.qc.dox.h:28
static string cap(string word)
Returns the given word capitalized.
static AbstractDataProviderType makeTypeFromSchemaInfo(ListDataType type, string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a type from a Google schema description.
static DataProvider::AbstractDataProviderType getInputTypeForSchema(string api, string schema)
Returns an input / inbound data type for the given Google schema.
static DataProvider::AbstractDataProviderType getResponseTypeForSchema(string api, string resource)
Returns a response data type for the given API.
static DataProvider::AbstractDataProviderType getRequestTypeForSchema(string api, string resource,...)
Returns a request data type for the given API.
static hash< string, hash< auto > > request_map
schema cache; API -> request path ->
Definition GoogleDataProviderBase.qc.dox.h:55
static Mutex m()
schema cache lock
static hash< string, AbstractDataProviderType > getApi(string api)
Returns all output schemas for the given API.
static hash< string, hash< string, AbstractDataProviderType > > input_schema_map
input schema cache; API -> schema name -> type
Definition GoogleDataProviderBase.qc.dox.h:48
static DataProvider::AbstractDataProviderType getRequestTypeForSchemaArgs(string api, string path, *list< auto > args)
Returns a data type for the given request.
*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.
static string getMethodForSchema(string api, string path)
Returns the HTTP method for the given API.
static GoogleRestClient::GoogleRestClient getRestConnection(*hash< auto > options)
Returns a GoogleRestClient connection from the options.
static HashDataType makeHashFromSchemaInfo(string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a hash from a Google schema description.
static AbstractDataProviderType makeTypeFromSchemaInfo(string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a type from a Google schema description.
*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.
static hash< string, hash< string, AbstractDataProviderType > > output_schema_map
output schema cache; API -> schema name -> type
Definition GoogleDataProviderBase.qc.dox.h:51
*GoogleRestClient::GoogleRestClient rest
The REST client object for API calls.
Definition GoogleDataProviderBase.qc.dox.h:39
static hash< auto > getRequestInfo(string api)
Returns all request types for the given API.
static string getUrlForApi(string api, RestClient::RestClient rest)
Returns the URL for the given API.
static AbstractDataProviderType makeTypeFromSchemaInfo(HashDataType type, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a type from a Google schema description.
const InitTimeout
Initialization I/O timeout.
Definition GoogleDataProviderBase.qc.dox.h:35
static DataProvider::AbstractDataProviderType getTypeForSchema(string api, string schema)
Returns a data type for the given Google schema.
static hash< string, AbstractDataProviderType > getInputSchemasForApi(string api)
Returns all input schemas for the given API.
hash< auto > backfillRequestBody(auto req)
Used to set attributes in the request body that are not set in the request.
static checkResource(string api, list< string > resource_path)
Check the given path for resources.
updateConnectionObjects(object conn, object connobj)
Update any connection used by the data provider.
static string getPathForSchema(string api, string resource)
Returns the path for the given API.
static ListDataType makeListFromSchemaInfo(string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a list from a Google schema description.
static QoreDataField makeFieldFromProperty(HashDataType h, string key, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a hash from a Google schema description.
static hash< string, AbstractDataProviderType > getOutputSchemaMap(string api, hash< auto > api_info)
Creates the output schema map for the given API.
bool needsBackfillRequestBody()
If the request body should be populated with missing values.
constructor(GoogleRestClient::GoogleRestClient rest)
Creates the object.
static hash< auto > processRequests(string api, hash< auto > h, TypeResolverHelper unresolved)
Process requests.
setLogger(*LoggerInterface logger)
Accepts a LoggerInterface object for logging (or clears it)
static hash< string, string > api_map
API -> URL map.
Definition GoogleDataProviderBase.qc.dox.h:42
static hash< auto > processRequest(string key, hash< auto > info, TypeResolverHelper unresolved)
Returns a hash from a Google schema description.
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.
const DiscoveryUrlBase
Discovery URL base.
Definition GoogleDataProviderBase.qc.dox.h:32
static AbstractDataProviderType makeTypeFromSchemaInfo(QoreDataField field, hash< auto > info, TypeResolverHelper unresolved, *bool for_input)
Returns a type from a Google schema description.
static hash< string, hash< auto > > info_map
Schema info: API -> info.
Definition GoogleDataProviderBase.qc.dox.h:45
static hash< string, AbstractDataProviderType > getInputSchemaMap(string api, hash< auto > api_info)
Creates the input schema map for the given API.
Qore GoogleDataProvider module definition.
Definition GoogleApiDataProvider.qc.dox.h:26