googlecloudbilling.pp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. unit googlecloudbilling;
  2. {$MODE objfpc}
  3. {$H+}
  4. interface
  5. uses sysutils, classes, googleservice, restbase, googlebase;
  6. type
  7. //Top-level schema types
  8. TBillingAccount = Class;
  9. TListBillingAccountsResponse = Class;
  10. TListProjectBillingInfoResponse = Class;
  11. TProjectBillingInfo = Class;
  12. TBillingAccountArray = Array of TBillingAccount;
  13. TListBillingAccountsResponseArray = Array of TListBillingAccountsResponse;
  14. TListProjectBillingInfoResponseArray = Array of TListProjectBillingInfoResponse;
  15. TProjectBillingInfoArray = Array of TProjectBillingInfo;
  16. //Anonymous types, using auto-generated names
  17. TListBillingAccountsResponseTypebillingAccountsArray = Array of TBillingAccount;
  18. TListProjectBillingInfoResponseTypeprojectBillingInfoArray = Array of TProjectBillingInfo;
  19. { --------------------------------------------------------------------
  20. TBillingAccount
  21. --------------------------------------------------------------------}
  22. TBillingAccount = Class(TGoogleBaseObject)
  23. Private
  24. Fname : String;
  25. Fopen : boolean;
  26. FdisplayName : String;
  27. Protected
  28. //Property setters
  29. Procedure Setname(AIndex : Integer; const AValue : String); virtual;
  30. Procedure Setopen(AIndex : Integer; const AValue : boolean); virtual;
  31. Procedure SetdisplayName(AIndex : Integer; const AValue : String); virtual;
  32. Public
  33. Published
  34. Property name : String Index 0 Read Fname Write Setname;
  35. Property open : boolean Index 8 Read Fopen Write Setopen;
  36. Property displayName : String Index 16 Read FdisplayName Write SetdisplayName;
  37. end;
  38. TBillingAccountClass = Class of TBillingAccount;
  39. { --------------------------------------------------------------------
  40. TListBillingAccountsResponse
  41. --------------------------------------------------------------------}
  42. TListBillingAccountsResponse = Class(TGoogleBaseObject)
  43. Private
  44. FbillingAccounts : TListBillingAccountsResponseTypebillingAccountsArray;
  45. FnextPageToken : String;
  46. Protected
  47. //Property setters
  48. Procedure SetbillingAccounts(AIndex : Integer; const AValue : TListBillingAccountsResponseTypebillingAccountsArray); virtual;
  49. Procedure SetnextPageToken(AIndex : Integer; const AValue : String); virtual;
  50. //2.6.4. bug workaround
  51. {$IFDEF VER2_6}
  52. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  53. {$ENDIF VER2_6}
  54. Public
  55. Published
  56. Property billingAccounts : TListBillingAccountsResponseTypebillingAccountsArray Index 0 Read FbillingAccounts Write SetbillingAccounts;
  57. Property nextPageToken : String Index 8 Read FnextPageToken Write SetnextPageToken;
  58. end;
  59. TListBillingAccountsResponseClass = Class of TListBillingAccountsResponse;
  60. { --------------------------------------------------------------------
  61. TListProjectBillingInfoResponse
  62. --------------------------------------------------------------------}
  63. TListProjectBillingInfoResponse = Class(TGoogleBaseObject)
  64. Private
  65. FprojectBillingInfo : TListProjectBillingInfoResponseTypeprojectBillingInfoArray;
  66. FnextPageToken : String;
  67. Protected
  68. //Property setters
  69. Procedure SetprojectBillingInfo(AIndex : Integer; const AValue : TListProjectBillingInfoResponseTypeprojectBillingInfoArray); virtual;
  70. Procedure SetnextPageToken(AIndex : Integer; const AValue : String); virtual;
  71. //2.6.4. bug workaround
  72. {$IFDEF VER2_6}
  73. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  74. {$ENDIF VER2_6}
  75. Public
  76. Published
  77. Property projectBillingInfo : TListProjectBillingInfoResponseTypeprojectBillingInfoArray Index 0 Read FprojectBillingInfo Write SetprojectBillingInfo;
  78. Property nextPageToken : String Index 8 Read FnextPageToken Write SetnextPageToken;
  79. end;
  80. TListProjectBillingInfoResponseClass = Class of TListProjectBillingInfoResponse;
  81. { --------------------------------------------------------------------
  82. TProjectBillingInfo
  83. --------------------------------------------------------------------}
  84. TProjectBillingInfo = Class(TGoogleBaseObject)
  85. Private
  86. Fname : String;
  87. FprojectId : String;
  88. FbillingAccountName : String;
  89. FbillingEnabled : boolean;
  90. Protected
  91. //Property setters
  92. Procedure Setname(AIndex : Integer; const AValue : String); virtual;
  93. Procedure SetprojectId(AIndex : Integer; const AValue : String); virtual;
  94. Procedure SetbillingAccountName(AIndex : Integer; const AValue : String); virtual;
  95. Procedure SetbillingEnabled(AIndex : Integer; const AValue : boolean); virtual;
  96. Public
  97. Published
  98. Property name : String Index 0 Read Fname Write Setname;
  99. Property projectId : String Index 8 Read FprojectId Write SetprojectId;
  100. Property billingAccountName : String Index 16 Read FbillingAccountName Write SetbillingAccountName;
  101. Property billingEnabled : boolean Index 24 Read FbillingEnabled Write SetbillingEnabled;
  102. end;
  103. TProjectBillingInfoClass = Class of TProjectBillingInfo;
  104. { --------------------------------------------------------------------
  105. TBillingAccountsProjectsResource
  106. --------------------------------------------------------------------}
  107. //Optional query Options for TBillingAccountsProjectsResource, method List
  108. TBillingAccountsProjectsListOptions = Record
  109. pageSize : integer;
  110. pageToken : String;
  111. end;
  112. TBillingAccountsProjectsResource = Class(TGoogleResource)
  113. Public
  114. Class Function ResourceName : String; override;
  115. Class Function DefaultAPI : TGoogleAPIClass; override;
  116. Function List(_name: string; AQuery : string = '') : TListProjectBillingInfoResponse;
  117. Function List(_name: string; AQuery : TBillingAccountsProjectslistOptions) : TListProjectBillingInfoResponse;
  118. end;
  119. { --------------------------------------------------------------------
  120. TBillingAccountsResource
  121. --------------------------------------------------------------------}
  122. //Optional query Options for TBillingAccountsResource, method List
  123. TBillingAccountsListOptions = Record
  124. pageSize : integer;
  125. pageToken : String;
  126. end;
  127. TBillingAccountsResource = Class(TGoogleResource)
  128. Private
  129. FProjectsInstance : TBillingAccountsProjectsResource;
  130. Function GetProjectsInstance : TBillingAccountsProjectsResource;virtual;
  131. Public
  132. Class Function ResourceName : String; override;
  133. Class Function DefaultAPI : TGoogleAPIClass; override;
  134. Function Get(_name: string) : TBillingAccount;
  135. Function List(AQuery : string = '') : TListBillingAccountsResponse;
  136. Function List(AQuery : TBillingAccountslistOptions) : TListBillingAccountsResponse;
  137. Function CreateProjectsResource(AOwner : TComponent) : TBillingAccountsProjectsResource;virtual;overload;
  138. Function CreateProjectsResource : TBillingAccountsProjectsResource;virtual;overload;
  139. Property ProjectsResource : TBillingAccountsProjectsResource Read GetProjectsInstance;
  140. end;
  141. { --------------------------------------------------------------------
  142. TProjectsResource
  143. --------------------------------------------------------------------}
  144. TProjectsResource = Class(TGoogleResource)
  145. Public
  146. Class Function ResourceName : String; override;
  147. Class Function DefaultAPI : TGoogleAPIClass; override;
  148. Function GetBillingInfo(_name: string) : TProjectBillingInfo;
  149. Function UpdateBillingInfo(_name: string; aProjectBillingInfo : TProjectBillingInfo) : TProjectBillingInfo;
  150. end;
  151. { --------------------------------------------------------------------
  152. TCloudbillingAPI
  153. --------------------------------------------------------------------}
  154. TCloudbillingAPI = Class(TGoogleAPI)
  155. Private
  156. FBillingAccountsProjectsInstance : TBillingAccountsProjectsResource;
  157. FBillingAccountsInstance : TBillingAccountsResource;
  158. FProjectsInstance : TProjectsResource;
  159. Function GetBillingAccountsProjectsInstance : TBillingAccountsProjectsResource;virtual;
  160. Function GetBillingAccountsInstance : TBillingAccountsResource;virtual;
  161. Function GetProjectsInstance : TProjectsResource;virtual;
  162. Public
  163. //Override class functions with API info
  164. Class Function APIName : String; override;
  165. Class Function APIVersion : String; override;
  166. Class Function APIRevision : String; override;
  167. Class Function APIID : String; override;
  168. Class Function APITitle : String; override;
  169. Class Function APIDescription : String; override;
  170. Class Function APIOwnerDomain : String; override;
  171. Class Function APIOwnerName : String; override;
  172. Class Function APIIcon16 : String; override;
  173. Class Function APIIcon32 : String; override;
  174. Class Function APIdocumentationLink : String; override;
  175. Class Function APIrootUrl : string; override;
  176. Class Function APIbasePath : string;override;
  177. Class Function APIbaseURL : String;override;
  178. Class Function APIProtocol : string;override;
  179. Class Function APIservicePath : string;override;
  180. Class Function APIbatchPath : String;override;
  181. Class Function APIAuthScopes : TScopeInfoArray;override;
  182. Class Function APINeedsAuth : Boolean;override;
  183. Class Procedure RegisterAPIResources; override;
  184. //Add create function for resources
  185. Function CreateBillingAccountsProjectsResource(AOwner : TComponent) : TBillingAccountsProjectsResource;virtual;overload;
  186. Function CreateBillingAccountsProjectsResource : TBillingAccountsProjectsResource;virtual;overload;
  187. Function CreateBillingAccountsResource(AOwner : TComponent) : TBillingAccountsResource;virtual;overload;
  188. Function CreateBillingAccountsResource : TBillingAccountsResource;virtual;overload;
  189. Function CreateProjectsResource(AOwner : TComponent) : TProjectsResource;virtual;overload;
  190. Function CreateProjectsResource : TProjectsResource;virtual;overload;
  191. //Add default on-demand instances for resources
  192. Property BillingAccountsProjectsResource : TBillingAccountsProjectsResource Read GetBillingAccountsProjectsInstance;
  193. Property BillingAccountsResource : TBillingAccountsResource Read GetBillingAccountsInstance;
  194. Property ProjectsResource : TProjectsResource Read GetProjectsInstance;
  195. end;
  196. implementation
  197. { --------------------------------------------------------------------
  198. TBillingAccount
  199. --------------------------------------------------------------------}
  200. Procedure TBillingAccount.Setname(AIndex : Integer; const AValue : String);
  201. begin
  202. If (Fname=AValue) then exit;
  203. Fname:=AValue;
  204. MarkPropertyChanged(AIndex);
  205. end;
  206. Procedure TBillingAccount.Setopen(AIndex : Integer; const AValue : boolean);
  207. begin
  208. If (Fopen=AValue) then exit;
  209. Fopen:=AValue;
  210. MarkPropertyChanged(AIndex);
  211. end;
  212. Procedure TBillingAccount.SetdisplayName(AIndex : Integer; const AValue : String);
  213. begin
  214. If (FdisplayName=AValue) then exit;
  215. FdisplayName:=AValue;
  216. MarkPropertyChanged(AIndex);
  217. end;
  218. { --------------------------------------------------------------------
  219. TListBillingAccountsResponse
  220. --------------------------------------------------------------------}
  221. Procedure TListBillingAccountsResponse.SetbillingAccounts(AIndex : Integer; const AValue : TListBillingAccountsResponseTypebillingAccountsArray);
  222. begin
  223. If (FbillingAccounts=AValue) then exit;
  224. FbillingAccounts:=AValue;
  225. MarkPropertyChanged(AIndex);
  226. end;
  227. Procedure TListBillingAccountsResponse.SetnextPageToken(AIndex : Integer; const AValue : String);
  228. begin
  229. If (FnextPageToken=AValue) then exit;
  230. FnextPageToken:=AValue;
  231. MarkPropertyChanged(AIndex);
  232. end;
  233. //2.6.4. bug workaround
  234. {$IFDEF VER2_6}
  235. Procedure TListBillingAccountsResponse.SetArrayLength(Const AName : String; ALength : Longint);
  236. begin
  237. Case AName of
  238. 'billingaccounts' : SetLength(FbillingAccounts,ALength);
  239. else
  240. Inherited SetArrayLength(AName,ALength);
  241. end;
  242. end;
  243. {$ENDIF VER2_6}
  244. { --------------------------------------------------------------------
  245. TListProjectBillingInfoResponse
  246. --------------------------------------------------------------------}
  247. Procedure TListProjectBillingInfoResponse.SetprojectBillingInfo(AIndex : Integer; const AValue : TListProjectBillingInfoResponseTypeprojectBillingInfoArray);
  248. begin
  249. If (FprojectBillingInfo=AValue) then exit;
  250. FprojectBillingInfo:=AValue;
  251. MarkPropertyChanged(AIndex);
  252. end;
  253. Procedure TListProjectBillingInfoResponse.SetnextPageToken(AIndex : Integer; const AValue : String);
  254. begin
  255. If (FnextPageToken=AValue) then exit;
  256. FnextPageToken:=AValue;
  257. MarkPropertyChanged(AIndex);
  258. end;
  259. //2.6.4. bug workaround
  260. {$IFDEF VER2_6}
  261. Procedure TListProjectBillingInfoResponse.SetArrayLength(Const AName : String; ALength : Longint);
  262. begin
  263. Case AName of
  264. 'projectbillinginfo' : SetLength(FprojectBillingInfo,ALength);
  265. else
  266. Inherited SetArrayLength(AName,ALength);
  267. end;
  268. end;
  269. {$ENDIF VER2_6}
  270. { --------------------------------------------------------------------
  271. TProjectBillingInfo
  272. --------------------------------------------------------------------}
  273. Procedure TProjectBillingInfo.Setname(AIndex : Integer; const AValue : String);
  274. begin
  275. If (Fname=AValue) then exit;
  276. Fname:=AValue;
  277. MarkPropertyChanged(AIndex);
  278. end;
  279. Procedure TProjectBillingInfo.SetprojectId(AIndex : Integer; const AValue : String);
  280. begin
  281. If (FprojectId=AValue) then exit;
  282. FprojectId:=AValue;
  283. MarkPropertyChanged(AIndex);
  284. end;
  285. Procedure TProjectBillingInfo.SetbillingAccountName(AIndex : Integer; const AValue : String);
  286. begin
  287. If (FbillingAccountName=AValue) then exit;
  288. FbillingAccountName:=AValue;
  289. MarkPropertyChanged(AIndex);
  290. end;
  291. Procedure TProjectBillingInfo.SetbillingEnabled(AIndex : Integer; const AValue : boolean);
  292. begin
  293. If (FbillingEnabled=AValue) then exit;
  294. FbillingEnabled:=AValue;
  295. MarkPropertyChanged(AIndex);
  296. end;
  297. { --------------------------------------------------------------------
  298. TBillingAccountsProjectsResource
  299. --------------------------------------------------------------------}
  300. Class Function TBillingAccountsProjectsResource.ResourceName : String;
  301. begin
  302. Result:='projects';
  303. end;
  304. Class Function TBillingAccountsProjectsResource.DefaultAPI : TGoogleAPIClass;
  305. begin
  306. Result:=TcloudbillingAPI;
  307. end;
  308. Function TBillingAccountsProjectsResource.List(_name: string; AQuery : string = '') : TListProjectBillingInfoResponse;
  309. Const
  310. _HTTPMethod = 'GET';
  311. _Path = 'v1/{+name}/projects';
  312. _Methodid = 'cloudbilling.billingAccounts.projects.list';
  313. Var
  314. _P : String;
  315. begin
  316. _P:=SubstitutePath(_Path,['name',_name]);
  317. Result:=ServiceCall(_HTTPMethod,_P,AQuery,Nil,TListProjectBillingInfoResponse) as TListProjectBillingInfoResponse;
  318. end;
  319. Function TBillingAccountsProjectsResource.List(_name: string; AQuery : TBillingAccountsProjectslistOptions) : TListProjectBillingInfoResponse;
  320. Var
  321. _Q : String;
  322. begin
  323. _Q:='';
  324. AddToQuery(_Q,'pageSize',AQuery.pageSize);
  325. AddToQuery(_Q,'pageToken',AQuery.pageToken);
  326. Result:=List(_name,_Q);
  327. end;
  328. { --------------------------------------------------------------------
  329. TBillingAccountsResource
  330. --------------------------------------------------------------------}
  331. Class Function TBillingAccountsResource.ResourceName : String;
  332. begin
  333. Result:='billingAccounts';
  334. end;
  335. Class Function TBillingAccountsResource.DefaultAPI : TGoogleAPIClass;
  336. begin
  337. Result:=TcloudbillingAPI;
  338. end;
  339. Function TBillingAccountsResource.Get(_name: string) : TBillingAccount;
  340. Const
  341. _HTTPMethod = 'GET';
  342. _Path = 'v1/{+name}';
  343. _Methodid = 'cloudbilling.billingAccounts.get';
  344. Var
  345. _P : String;
  346. begin
  347. _P:=SubstitutePath(_Path,['name',_name]);
  348. Result:=ServiceCall(_HTTPMethod,_P,'',Nil,TBillingAccount) as TBillingAccount;
  349. end;
  350. Function TBillingAccountsResource.List(AQuery : string = '') : TListBillingAccountsResponse;
  351. Const
  352. _HTTPMethod = 'GET';
  353. _Path = 'v1/billingAccounts';
  354. _Methodid = 'cloudbilling.billingAccounts.list';
  355. begin
  356. Result:=ServiceCall(_HTTPMethod,_Path,AQuery,Nil,TListBillingAccountsResponse) as TListBillingAccountsResponse;
  357. end;
  358. Function TBillingAccountsResource.List(AQuery : TBillingAccountslistOptions) : TListBillingAccountsResponse;
  359. Var
  360. _Q : String;
  361. begin
  362. _Q:='';
  363. AddToQuery(_Q,'pageSize',AQuery.pageSize);
  364. AddToQuery(_Q,'pageToken',AQuery.pageToken);
  365. Result:=List(_Q);
  366. end;
  367. Function TBillingAccountsResource.GetProjectsInstance : TBillingAccountsProjectsResource;
  368. begin
  369. if (FProjectsInstance=Nil) then
  370. FProjectsInstance:=CreateProjectsResource;
  371. Result:=FProjectsInstance;
  372. end;
  373. Function TBillingAccountsResource.CreateProjectsResource : TBillingAccountsProjectsResource;
  374. begin
  375. Result:=CreateProjectsResource(Self);
  376. end;
  377. Function TBillingAccountsResource.CreateProjectsResource(AOwner : TComponent) : TBillingAccountsProjectsResource;
  378. begin
  379. Result:=TBillingAccountsProjectsResource.Create(AOwner);
  380. Result.API:=Self.API;
  381. end;
  382. { --------------------------------------------------------------------
  383. TProjectsResource
  384. --------------------------------------------------------------------}
  385. Class Function TProjectsResource.ResourceName : String;
  386. begin
  387. Result:='projects';
  388. end;
  389. Class Function TProjectsResource.DefaultAPI : TGoogleAPIClass;
  390. begin
  391. Result:=TcloudbillingAPI;
  392. end;
  393. Function TProjectsResource.GetBillingInfo(_name: string) : TProjectBillingInfo;
  394. Const
  395. _HTTPMethod = 'GET';
  396. _Path = 'v1/{+name}/billingInfo';
  397. _Methodid = 'cloudbilling.projects.getBillingInfo';
  398. Var
  399. _P : String;
  400. begin
  401. _P:=SubstitutePath(_Path,['name',_name]);
  402. Result:=ServiceCall(_HTTPMethod,_P,'',Nil,TProjectBillingInfo) as TProjectBillingInfo;
  403. end;
  404. Function TProjectsResource.UpdateBillingInfo(_name: string; aProjectBillingInfo : TProjectBillingInfo) : TProjectBillingInfo;
  405. Const
  406. _HTTPMethod = 'PUT';
  407. _Path = 'v1/{+name}/billingInfo';
  408. _Methodid = 'cloudbilling.projects.updateBillingInfo';
  409. Var
  410. _P : String;
  411. begin
  412. _P:=SubstitutePath(_Path,['name',_name]);
  413. Result:=ServiceCall(_HTTPMethod,_P,'',aProjectBillingInfo,TProjectBillingInfo) as TProjectBillingInfo;
  414. end;
  415. { --------------------------------------------------------------------
  416. TCloudbillingAPI
  417. --------------------------------------------------------------------}
  418. Class Function TCloudbillingAPI.APIName : String;
  419. begin
  420. Result:='cloudbilling';
  421. end;
  422. Class Function TCloudbillingAPI.APIVersion : String;
  423. begin
  424. Result:='v1';
  425. end;
  426. Class Function TCloudbillingAPI.APIRevision : String;
  427. begin
  428. Result:='20151222';
  429. end;
  430. Class Function TCloudbillingAPI.APIID : String;
  431. begin
  432. Result:='cloudbilling:v1';
  433. end;
  434. Class Function TCloudbillingAPI.APITitle : String;
  435. begin
  436. Result:='Google Cloud Billing API';
  437. end;
  438. Class Function TCloudbillingAPI.APIDescription : String;
  439. begin
  440. Result:='Retrieves Google Developers Console billing accounts and associates them with projects.';
  441. end;
  442. Class Function TCloudbillingAPI.APIOwnerDomain : String;
  443. begin
  444. Result:='google.com';
  445. end;
  446. Class Function TCloudbillingAPI.APIOwnerName : String;
  447. begin
  448. Result:='Google';
  449. end;
  450. Class Function TCloudbillingAPI.APIIcon16 : String;
  451. begin
  452. Result:='http://www.google.com/images/icons/product/search-16.gif';
  453. end;
  454. Class Function TCloudbillingAPI.APIIcon32 : String;
  455. begin
  456. Result:='http://www.google.com/images/icons/product/search-32.gif';
  457. end;
  458. Class Function TCloudbillingAPI.APIdocumentationLink : String;
  459. begin
  460. Result:='https://cloud.google.com/billing/';
  461. end;
  462. Class Function TCloudbillingAPI.APIrootUrl : string;
  463. begin
  464. Result:='https://cloudbilling.googleapis.com/';
  465. end;
  466. Class Function TCloudbillingAPI.APIbasePath : string;
  467. begin
  468. Result:='';
  469. end;
  470. Class Function TCloudbillingAPI.APIbaseURL : String;
  471. begin
  472. Result:='https://cloudbilling.googleapis.com/';
  473. end;
  474. Class Function TCloudbillingAPI.APIProtocol : string;
  475. begin
  476. Result:='rest';
  477. end;
  478. Class Function TCloudbillingAPI.APIservicePath : string;
  479. begin
  480. Result:='';
  481. end;
  482. Class Function TCloudbillingAPI.APIbatchPath : String;
  483. begin
  484. Result:='batch';
  485. end;
  486. Class Function TCloudbillingAPI.APIAuthScopes : TScopeInfoArray;
  487. begin
  488. SetLength(Result,1);
  489. Result[0].Name:='https://www.googleapis.com/auth/cloud-platform';
  490. Result[0].Description:='View and manage your data across Google Cloud Platform services';
  491. end;
  492. Class Function TCloudbillingAPI.APINeedsAuth : Boolean;
  493. begin
  494. Result:=True;
  495. end;
  496. Class Procedure TCloudbillingAPI.RegisterAPIResources;
  497. begin
  498. TBillingAccount.RegisterObject;
  499. TListBillingAccountsResponse.RegisterObject;
  500. TListProjectBillingInfoResponse.RegisterObject;
  501. TProjectBillingInfo.RegisterObject;
  502. end;
  503. Function TCloudbillingAPI.GetBillingAccountsProjectsInstance : TBillingAccountsProjectsResource;
  504. begin
  505. if (FBillingAccountsProjectsInstance=Nil) then
  506. FBillingAccountsProjectsInstance:=CreateBillingAccountsProjectsResource;
  507. Result:=FBillingAccountsProjectsInstance;
  508. end;
  509. Function TCloudbillingAPI.CreateBillingAccountsProjectsResource : TBillingAccountsProjectsResource;
  510. begin
  511. Result:=CreateBillingAccountsProjectsResource(Self);
  512. end;
  513. Function TCloudbillingAPI.CreateBillingAccountsProjectsResource(AOwner : TComponent) : TBillingAccountsProjectsResource;
  514. begin
  515. Result:=TBillingAccountsProjectsResource.Create(AOwner);
  516. Result.API:=Self.API;
  517. end;
  518. Function TCloudbillingAPI.GetBillingAccountsInstance : TBillingAccountsResource;
  519. begin
  520. if (FBillingAccountsInstance=Nil) then
  521. FBillingAccountsInstance:=CreateBillingAccountsResource;
  522. Result:=FBillingAccountsInstance;
  523. end;
  524. Function TCloudbillingAPI.CreateBillingAccountsResource : TBillingAccountsResource;
  525. begin
  526. Result:=CreateBillingAccountsResource(Self);
  527. end;
  528. Function TCloudbillingAPI.CreateBillingAccountsResource(AOwner : TComponent) : TBillingAccountsResource;
  529. begin
  530. Result:=TBillingAccountsResource.Create(AOwner);
  531. Result.API:=Self.API;
  532. end;
  533. Function TCloudbillingAPI.GetProjectsInstance : TProjectsResource;
  534. begin
  535. if (FProjectsInstance=Nil) then
  536. FProjectsInstance:=CreateProjectsResource;
  537. Result:=FProjectsInstance;
  538. end;
  539. Function TCloudbillingAPI.CreateProjectsResource : TProjectsResource;
  540. begin
  541. Result:=CreateProjectsResource(Self);
  542. end;
  543. Function TCloudbillingAPI.CreateProjectsResource(AOwner : TComponent) : TProjectsResource;
  544. begin
  545. Result:=TProjectsResource.Create(AOwner);
  546. Result.API:=Self.API;
  547. end;
  548. initialization
  549. TCloudbillingAPI.RegisterAPI;
  550. end.