googlecloudlatencytest.pp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. unit googlecloudlatencytest;
  2. {$MODE objfpc}
  3. {$H+}
  4. interface
  5. uses sysutils, classes, googleservice, restbase, googlebase;
  6. type
  7. //Top-level schema types
  8. TAggregatedStats = Class;
  9. TAggregatedStatsReply = Class;
  10. TDoubleValue = Class;
  11. TIntValue = Class;
  12. TStats = Class;
  13. TStatsReply = Class;
  14. TStringValue = Class;
  15. TAggregatedStatsArray = Array of TAggregatedStats;
  16. TAggregatedStatsReplyArray = Array of TAggregatedStatsReply;
  17. TDoubleValueArray = Array of TDoubleValue;
  18. TIntValueArray = Array of TIntValue;
  19. TStatsArray = Array of TStats;
  20. TStatsReplyArray = Array of TStatsReply;
  21. TStringValueArray = Array of TStringValue;
  22. //Anonymous types, using auto-generated names
  23. TAggregatedStatsTypestatsArray = Array of TStats;
  24. TStatsTypedoubleValuesArray = Array of TDoubleValue;
  25. TStatsTypeintValuesArray = Array of TIntValue;
  26. TStatsTypestringValuesArray = Array of TStringValue;
  27. { --------------------------------------------------------------------
  28. TAggregatedStats
  29. --------------------------------------------------------------------}
  30. TAggregatedStats = Class(TGoogleBaseObject)
  31. Private
  32. Fstats : TAggregatedStatsTypestatsArray;
  33. Protected
  34. //Property setters
  35. Procedure Setstats(AIndex : Integer; const AValue : TAggregatedStatsTypestatsArray); virtual;
  36. //2.6.4. bug workaround
  37. {$IFDEF VER2_6}
  38. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  39. {$ENDIF VER2_6}
  40. Public
  41. Published
  42. Property stats : TAggregatedStatsTypestatsArray Index 0 Read Fstats Write Setstats;
  43. end;
  44. TAggregatedStatsClass = Class of TAggregatedStats;
  45. { --------------------------------------------------------------------
  46. TAggregatedStatsReply
  47. --------------------------------------------------------------------}
  48. TAggregatedStatsReply = Class(TGoogleBaseObject)
  49. Private
  50. FtestValue : String;
  51. Protected
  52. //Property setters
  53. Procedure SettestValue(AIndex : Integer; const AValue : String); virtual;
  54. Public
  55. Published
  56. Property testValue : String Index 0 Read FtestValue Write SettestValue;
  57. end;
  58. TAggregatedStatsReplyClass = Class of TAggregatedStatsReply;
  59. { --------------------------------------------------------------------
  60. TDoubleValue
  61. --------------------------------------------------------------------}
  62. TDoubleValue = Class(TGoogleBaseObject)
  63. Private
  64. F_label : String;
  65. Fvalue : integer;
  66. Protected
  67. Class Function ExportPropertyName(Const AName : String) : string; override;
  68. //Property setters
  69. Procedure Set_label(AIndex : Integer; const AValue : String); virtual;
  70. Procedure Setvalue(AIndex : Integer; const AValue : integer); virtual;
  71. Public
  72. Published
  73. Property _label : String Index 0 Read F_label Write Set_label;
  74. Property value : integer Index 8 Read Fvalue Write Setvalue;
  75. end;
  76. TDoubleValueClass = Class of TDoubleValue;
  77. { --------------------------------------------------------------------
  78. TIntValue
  79. --------------------------------------------------------------------}
  80. TIntValue = Class(TGoogleBaseObject)
  81. Private
  82. F_label : String;
  83. Fvalue : String;
  84. Protected
  85. Class Function ExportPropertyName(Const AName : String) : string; override;
  86. //Property setters
  87. Procedure Set_label(AIndex : Integer; const AValue : String); virtual;
  88. Procedure Setvalue(AIndex : Integer; const AValue : String); virtual;
  89. Public
  90. Published
  91. Property _label : String Index 0 Read F_label Write Set_label;
  92. Property value : String Index 8 Read Fvalue Write Setvalue;
  93. end;
  94. TIntValueClass = Class of TIntValue;
  95. { --------------------------------------------------------------------
  96. TStats
  97. --------------------------------------------------------------------}
  98. TStats = Class(TGoogleBaseObject)
  99. Private
  100. FdoubleValues : TStatsTypedoubleValuesArray;
  101. FintValues : TStatsTypeintValuesArray;
  102. FstringValues : TStatsTypestringValuesArray;
  103. Ftime : double;
  104. Protected
  105. //Property setters
  106. Procedure SetdoubleValues(AIndex : Integer; const AValue : TStatsTypedoubleValuesArray); virtual;
  107. Procedure SetintValues(AIndex : Integer; const AValue : TStatsTypeintValuesArray); virtual;
  108. Procedure SetstringValues(AIndex : Integer; const AValue : TStatsTypestringValuesArray); virtual;
  109. Procedure Settime(AIndex : Integer; const AValue : double); virtual;
  110. //2.6.4. bug workaround
  111. {$IFDEF VER2_6}
  112. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  113. {$ENDIF VER2_6}
  114. Public
  115. Published
  116. Property doubleValues : TStatsTypedoubleValuesArray Index 0 Read FdoubleValues Write SetdoubleValues;
  117. Property intValues : TStatsTypeintValuesArray Index 8 Read FintValues Write SetintValues;
  118. Property stringValues : TStatsTypestringValuesArray Index 16 Read FstringValues Write SetstringValues;
  119. Property time : double Index 24 Read Ftime Write Settime;
  120. end;
  121. TStatsClass = Class of TStats;
  122. { --------------------------------------------------------------------
  123. TStatsReply
  124. --------------------------------------------------------------------}
  125. TStatsReply = Class(TGoogleBaseObject)
  126. Private
  127. FtestValue : String;
  128. Protected
  129. //Property setters
  130. Procedure SettestValue(AIndex : Integer; const AValue : String); virtual;
  131. Public
  132. Published
  133. Property testValue : String Index 0 Read FtestValue Write SettestValue;
  134. end;
  135. TStatsReplyClass = Class of TStatsReply;
  136. { --------------------------------------------------------------------
  137. TStringValue
  138. --------------------------------------------------------------------}
  139. TStringValue = Class(TGoogleBaseObject)
  140. Private
  141. F_label : String;
  142. Fvalue : String;
  143. Protected
  144. Class Function ExportPropertyName(Const AName : String) : string; override;
  145. //Property setters
  146. Procedure Set_label(AIndex : Integer; const AValue : String); virtual;
  147. Procedure Setvalue(AIndex : Integer; const AValue : String); virtual;
  148. Public
  149. Published
  150. Property _label : String Index 0 Read F_label Write Set_label;
  151. Property value : String Index 8 Read Fvalue Write Setvalue;
  152. end;
  153. TStringValueClass = Class of TStringValue;
  154. { --------------------------------------------------------------------
  155. TStatscollectionResource
  156. --------------------------------------------------------------------}
  157. TStatscollectionResource = Class(TGoogleResource)
  158. Public
  159. Class Function ResourceName : String; override;
  160. Class Function DefaultAPI : TGoogleAPIClass; override;
  161. Function Updateaggregatedstats(aAggregatedStats : TAggregatedStats) : TAggregatedStatsReply;
  162. Function Updatestats(aStats : TStats) : TStatsReply;
  163. end;
  164. { --------------------------------------------------------------------
  165. TCloudlatencytestAPI
  166. --------------------------------------------------------------------}
  167. TCloudlatencytestAPI = Class(TGoogleAPI)
  168. Private
  169. FStatscollectionInstance : TStatscollectionResource;
  170. Function GetStatscollectionInstance : TStatscollectionResource;virtual;
  171. Public
  172. //Override class functions with API info
  173. Class Function APIName : String; override;
  174. Class Function APIVersion : String; override;
  175. Class Function APIRevision : String; override;
  176. Class Function APIID : String; override;
  177. Class Function APITitle : String; override;
  178. Class Function APIDescription : String; override;
  179. Class Function APIOwnerDomain : String; override;
  180. Class Function APIOwnerName : String; override;
  181. Class Function APIIcon16 : String; override;
  182. Class Function APIIcon32 : String; override;
  183. Class Function APIdocumentationLink : String; override;
  184. Class Function APIrootUrl : string; override;
  185. Class Function APIbasePath : string;override;
  186. Class Function APIbaseURL : String;override;
  187. Class Function APIProtocol : string;override;
  188. Class Function APIservicePath : string;override;
  189. Class Function APIbatchPath : String;override;
  190. Class Function APIAuthScopes : TScopeInfoArray;override;
  191. Class Function APINeedsAuth : Boolean;override;
  192. Class Procedure RegisterAPIResources; override;
  193. //Add create function for resources
  194. Function CreateStatscollectionResource(AOwner : TComponent) : TStatscollectionResource;virtual;overload;
  195. Function CreateStatscollectionResource : TStatscollectionResource;virtual;overload;
  196. //Add default on-demand instances for resources
  197. Property StatscollectionResource : TStatscollectionResource Read GetStatscollectionInstance;
  198. end;
  199. implementation
  200. { --------------------------------------------------------------------
  201. TAggregatedStats
  202. --------------------------------------------------------------------}
  203. Procedure TAggregatedStats.Setstats(AIndex : Integer; const AValue : TAggregatedStatsTypestatsArray);
  204. begin
  205. If (Fstats=AValue) then exit;
  206. Fstats:=AValue;
  207. MarkPropertyChanged(AIndex);
  208. end;
  209. //2.6.4. bug workaround
  210. {$IFDEF VER2_6}
  211. Procedure TAggregatedStats.SetArrayLength(Const AName : String; ALength : Longint);
  212. begin
  213. Case AName of
  214. 'stats' : SetLength(Fstats,ALength);
  215. else
  216. Inherited SetArrayLength(AName,ALength);
  217. end;
  218. end;
  219. {$ENDIF VER2_6}
  220. { --------------------------------------------------------------------
  221. TAggregatedStatsReply
  222. --------------------------------------------------------------------}
  223. Procedure TAggregatedStatsReply.SettestValue(AIndex : Integer; const AValue : String);
  224. begin
  225. If (FtestValue=AValue) then exit;
  226. FtestValue:=AValue;
  227. MarkPropertyChanged(AIndex);
  228. end;
  229. { --------------------------------------------------------------------
  230. TDoubleValue
  231. --------------------------------------------------------------------}
  232. Procedure TDoubleValue.Set_label(AIndex : Integer; const AValue : String);
  233. begin
  234. If (F_label=AValue) then exit;
  235. F_label:=AValue;
  236. MarkPropertyChanged(AIndex);
  237. end;
  238. Procedure TDoubleValue.Setvalue(AIndex : Integer; const AValue : integer);
  239. begin
  240. If (Fvalue=AValue) then exit;
  241. Fvalue:=AValue;
  242. MarkPropertyChanged(AIndex);
  243. end;
  244. Class Function TDoubleValue.ExportPropertyName(Const AName : String) :String;
  245. begin
  246. Case AName of
  247. '_label' : Result:='label';
  248. else
  249. Result:=Inherited ExportPropertyName(AName);
  250. end;
  251. end;
  252. { --------------------------------------------------------------------
  253. TIntValue
  254. --------------------------------------------------------------------}
  255. Procedure TIntValue.Set_label(AIndex : Integer; const AValue : String);
  256. begin
  257. If (F_label=AValue) then exit;
  258. F_label:=AValue;
  259. MarkPropertyChanged(AIndex);
  260. end;
  261. Procedure TIntValue.Setvalue(AIndex : Integer; const AValue : String);
  262. begin
  263. If (Fvalue=AValue) then exit;
  264. Fvalue:=AValue;
  265. MarkPropertyChanged(AIndex);
  266. end;
  267. Class Function TIntValue.ExportPropertyName(Const AName : String) :String;
  268. begin
  269. Case AName of
  270. '_label' : Result:='label';
  271. else
  272. Result:=Inherited ExportPropertyName(AName);
  273. end;
  274. end;
  275. { --------------------------------------------------------------------
  276. TStats
  277. --------------------------------------------------------------------}
  278. Procedure TStats.SetdoubleValues(AIndex : Integer; const AValue : TStatsTypedoubleValuesArray);
  279. begin
  280. If (FdoubleValues=AValue) then exit;
  281. FdoubleValues:=AValue;
  282. MarkPropertyChanged(AIndex);
  283. end;
  284. Procedure TStats.SetintValues(AIndex : Integer; const AValue : TStatsTypeintValuesArray);
  285. begin
  286. If (FintValues=AValue) then exit;
  287. FintValues:=AValue;
  288. MarkPropertyChanged(AIndex);
  289. end;
  290. Procedure TStats.SetstringValues(AIndex : Integer; const AValue : TStatsTypestringValuesArray);
  291. begin
  292. If (FstringValues=AValue) then exit;
  293. FstringValues:=AValue;
  294. MarkPropertyChanged(AIndex);
  295. end;
  296. Procedure TStats.Settime(AIndex : Integer; const AValue : double);
  297. begin
  298. If (Ftime=AValue) then exit;
  299. Ftime:=AValue;
  300. MarkPropertyChanged(AIndex);
  301. end;
  302. //2.6.4. bug workaround
  303. {$IFDEF VER2_6}
  304. Procedure TStats.SetArrayLength(Const AName : String; ALength : Longint);
  305. begin
  306. Case AName of
  307. 'doublevalues' : SetLength(FdoubleValues,ALength);
  308. 'intvalues' : SetLength(FintValues,ALength);
  309. 'stringvalues' : SetLength(FstringValues,ALength);
  310. else
  311. Inherited SetArrayLength(AName,ALength);
  312. end;
  313. end;
  314. {$ENDIF VER2_6}
  315. { --------------------------------------------------------------------
  316. TStatsReply
  317. --------------------------------------------------------------------}
  318. Procedure TStatsReply.SettestValue(AIndex : Integer; const AValue : String);
  319. begin
  320. If (FtestValue=AValue) then exit;
  321. FtestValue:=AValue;
  322. MarkPropertyChanged(AIndex);
  323. end;
  324. { --------------------------------------------------------------------
  325. TStringValue
  326. --------------------------------------------------------------------}
  327. Procedure TStringValue.Set_label(AIndex : Integer; const AValue : String);
  328. begin
  329. If (F_label=AValue) then exit;
  330. F_label:=AValue;
  331. MarkPropertyChanged(AIndex);
  332. end;
  333. Procedure TStringValue.Setvalue(AIndex : Integer; const AValue : String);
  334. begin
  335. If (Fvalue=AValue) then exit;
  336. Fvalue:=AValue;
  337. MarkPropertyChanged(AIndex);
  338. end;
  339. Class Function TStringValue.ExportPropertyName(Const AName : String) :String;
  340. begin
  341. Case AName of
  342. '_label' : Result:='label';
  343. else
  344. Result:=Inherited ExportPropertyName(AName);
  345. end;
  346. end;
  347. { --------------------------------------------------------------------
  348. TStatscollectionResource
  349. --------------------------------------------------------------------}
  350. Class Function TStatscollectionResource.ResourceName : String;
  351. begin
  352. Result:='statscollection';
  353. end;
  354. Class Function TStatscollectionResource.DefaultAPI : TGoogleAPIClass;
  355. begin
  356. Result:=TcloudlatencytestAPI;
  357. end;
  358. Function TStatscollectionResource.Updateaggregatedstats(aAggregatedStats : TAggregatedStats) : TAggregatedStatsReply;
  359. Const
  360. _HTTPMethod = 'POST';
  361. _Path = 'updateaggregatedstats';
  362. _Methodid = 'cloudlatencytest.statscollection.updateaggregatedstats';
  363. begin
  364. Result:=ServiceCall(_HTTPMethod,_Path,'',aAggregatedStats,TAggregatedStatsReply) as TAggregatedStatsReply;
  365. end;
  366. Function TStatscollectionResource.Updatestats(aStats : TStats) : TStatsReply;
  367. Const
  368. _HTTPMethod = 'POST';
  369. _Path = 'updatestats';
  370. _Methodid = 'cloudlatencytest.statscollection.updatestats';
  371. begin
  372. Result:=ServiceCall(_HTTPMethod,_Path,'',aStats,TStatsReply) as TStatsReply;
  373. end;
  374. { --------------------------------------------------------------------
  375. TCloudlatencytestAPI
  376. --------------------------------------------------------------------}
  377. Class Function TCloudlatencytestAPI.APIName : String;
  378. begin
  379. Result:='cloudlatencytest';
  380. end;
  381. Class Function TCloudlatencytestAPI.APIVersion : String;
  382. begin
  383. Result:='v2';
  384. end;
  385. Class Function TCloudlatencytestAPI.APIRevision : String;
  386. begin
  387. Result:='20160309';
  388. end;
  389. Class Function TCloudlatencytestAPI.APIID : String;
  390. begin
  391. Result:='cloudlatencytest:v2';
  392. end;
  393. Class Function TCloudlatencytestAPI.APITitle : String;
  394. begin
  395. Result:='Google Cloud Network Performance Monitoring API';
  396. end;
  397. Class Function TCloudlatencytestAPI.APIDescription : String;
  398. begin
  399. Result:='Reports latency data.';
  400. end;
  401. Class Function TCloudlatencytestAPI.APIOwnerDomain : String;
  402. begin
  403. Result:='google.com';
  404. end;
  405. Class Function TCloudlatencytestAPI.APIOwnerName : String;
  406. begin
  407. Result:='Google';
  408. end;
  409. Class Function TCloudlatencytestAPI.APIIcon16 : String;
  410. begin
  411. Result:='http://www.google.com/images/icons/product/search-16.gif';
  412. end;
  413. Class Function TCloudlatencytestAPI.APIIcon32 : String;
  414. begin
  415. Result:='http://www.google.com/images/icons/product/search-32.gif';
  416. end;
  417. Class Function TCloudlatencytestAPI.APIdocumentationLink : String;
  418. begin
  419. Result:='';
  420. end;
  421. Class Function TCloudlatencytestAPI.APIrootUrl : string;
  422. begin
  423. Result:='https://cloudlatencytest-pa.googleapis.com/';
  424. end;
  425. Class Function TCloudlatencytestAPI.APIbasePath : string;
  426. begin
  427. Result:='/v2/statscollection/';
  428. end;
  429. Class Function TCloudlatencytestAPI.APIbaseURL : String;
  430. begin
  431. Result:='https://cloudlatencytest-pa.googleapis.com/v2/statscollection/';
  432. end;
  433. Class Function TCloudlatencytestAPI.APIProtocol : string;
  434. begin
  435. Result:='rest';
  436. end;
  437. Class Function TCloudlatencytestAPI.APIservicePath : string;
  438. begin
  439. Result:='v2/statscollection/';
  440. end;
  441. Class Function TCloudlatencytestAPI.APIbatchPath : String;
  442. begin
  443. Result:='batch';
  444. end;
  445. Class Function TCloudlatencytestAPI.APIAuthScopes : TScopeInfoArray;
  446. begin
  447. SetLength(Result,1);
  448. Result[0].Name:='https://www.googleapis.com/auth/monitoring.readonly';
  449. Result[0].Description:='View monitoring data for all of your Google Cloud and API projects';
  450. end;
  451. Class Function TCloudlatencytestAPI.APINeedsAuth : Boolean;
  452. begin
  453. Result:=True;
  454. end;
  455. Class Procedure TCloudlatencytestAPI.RegisterAPIResources;
  456. begin
  457. TAggregatedStats.RegisterObject;
  458. TAggregatedStatsReply.RegisterObject;
  459. TDoubleValue.RegisterObject;
  460. TIntValue.RegisterObject;
  461. TStats.RegisterObject;
  462. TStatsReply.RegisterObject;
  463. TStringValue.RegisterObject;
  464. end;
  465. Function TCloudlatencytestAPI.GetStatscollectionInstance : TStatscollectionResource;
  466. begin
  467. if (FStatscollectionInstance=Nil) then
  468. FStatscollectionInstance:=CreateStatscollectionResource;
  469. Result:=FStatscollectionInstance;
  470. end;
  471. Function TCloudlatencytestAPI.CreateStatscollectionResource : TStatscollectionResource;
  472. begin
  473. Result:=CreateStatscollectionResource(Self);
  474. end;
  475. Function TCloudlatencytestAPI.CreateStatscollectionResource(AOwner : TComponent) : TStatscollectionResource;
  476. begin
  477. Result:=TStatscollectionResource.Create(AOwner);
  478. Result.API:=Self.API;
  479. end;
  480. initialization
  481. TCloudlatencytestAPI.RegisterAPI;
  482. end.