googlelicensing.pp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. unit googlelicensing;
  2. {
  3. **********************************************************************
  4. This file is part of the Free Component Library (FCL)
  5. Copyright (c) 2015 The free pascal team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************
  12. }
  13. //Generated on: 16-5-15 08:53:05
  14. {$MODE objfpc}
  15. {$H+}
  16. interface
  17. uses sysutils, classes, googleservice, restbase, googlebase;
  18. type
  19. //Top-level schema types
  20. TLicenseAssignment = Class;
  21. TLicenseAssignmentInsert = Class;
  22. TLicenseAssignmentList = Class;
  23. TLicenseAssignmentArray = Array of TLicenseAssignment;
  24. TLicenseAssignmentInsertArray = Array of TLicenseAssignmentInsert;
  25. TLicenseAssignmentListArray = Array of TLicenseAssignmentList;
  26. //Anonymous types, using auto-generated names
  27. TLicenseAssignmentListTypeitemsArray = Array of TLicenseAssignment;
  28. { --------------------------------------------------------------------
  29. TLicenseAssignment
  30. --------------------------------------------------------------------}
  31. TLicenseAssignment = Class(TGoogleBaseObject)
  32. Private
  33. Fetags : String;
  34. Fkind : String;
  35. FproductId : String;
  36. FselfLink : String;
  37. FskuId : String;
  38. FuserId : String;
  39. Protected
  40. //Property setters
  41. Procedure Setetags(AIndex : Integer; AValue : String); virtual;
  42. Procedure Setkind(AIndex : Integer; AValue : String); virtual;
  43. Procedure SetproductId(AIndex : Integer; AValue : String); virtual;
  44. Procedure SetselfLink(AIndex : Integer; AValue : String); virtual;
  45. Procedure SetskuId(AIndex : Integer; AValue : String); virtual;
  46. Procedure SetuserId(AIndex : Integer; AValue : String); virtual;
  47. Public
  48. Published
  49. Property etags : String Index 0 Read Fetags Write Setetags;
  50. Property kind : String Index 8 Read Fkind Write Setkind;
  51. Property productId : String Index 16 Read FproductId Write SetproductId;
  52. Property selfLink : String Index 24 Read FselfLink Write SetselfLink;
  53. Property skuId : String Index 32 Read FskuId Write SetskuId;
  54. Property userId : String Index 40 Read FuserId Write SetuserId;
  55. end;
  56. TLicenseAssignmentClass = Class of TLicenseAssignment;
  57. { --------------------------------------------------------------------
  58. TLicenseAssignmentInsert
  59. --------------------------------------------------------------------}
  60. TLicenseAssignmentInsert = Class(TGoogleBaseObject)
  61. Private
  62. FuserId : String;
  63. Protected
  64. //Property setters
  65. Procedure SetuserId(AIndex : Integer; AValue : String); virtual;
  66. Public
  67. Published
  68. Property userId : String Index 0 Read FuserId Write SetuserId;
  69. end;
  70. TLicenseAssignmentInsertClass = Class of TLicenseAssignmentInsert;
  71. { --------------------------------------------------------------------
  72. TLicenseAssignmentList
  73. --------------------------------------------------------------------}
  74. TLicenseAssignmentList = Class(TGoogleBaseObject)
  75. Private
  76. Fetag : String;
  77. Fitems : TLicenseAssignmentListTypeitemsArray;
  78. Fkind : String;
  79. FnextPageToken : String;
  80. Protected
  81. //Property setters
  82. Procedure Setetag(AIndex : Integer; AValue : String); virtual;
  83. Procedure Setitems(AIndex : Integer; AValue : TLicenseAssignmentListTypeitemsArray); virtual;
  84. Procedure Setkind(AIndex : Integer; AValue : String); virtual;
  85. Procedure SetnextPageToken(AIndex : Integer; AValue : String); virtual;
  86. //2.6.4. bug workaround
  87. {$IFDEF VER2_6}
  88. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  89. {$ENDIF VER2_6}
  90. Public
  91. Published
  92. Property etag : String Index 0 Read Fetag Write Setetag;
  93. Property items : TLicenseAssignmentListTypeitemsArray Index 8 Read Fitems Write Setitems;
  94. Property kind : String Index 16 Read Fkind Write Setkind;
  95. Property nextPageToken : String Index 24 Read FnextPageToken Write SetnextPageToken;
  96. end;
  97. TLicenseAssignmentListClass = Class of TLicenseAssignmentList;
  98. { --------------------------------------------------------------------
  99. TLicenseAssignmentsResource
  100. --------------------------------------------------------------------}
  101. //Optional query Options for TLicenseAssignmentsResource, method ListForProduct
  102. TLicenseAssignmentsListForProductOptions = Record
  103. customerId : String;
  104. maxResults : integer;
  105. pageToken : String;
  106. end;
  107. //Optional query Options for TLicenseAssignmentsResource, method ListForProductAndSku
  108. TLicenseAssignmentsListForProductAndSkuOptions = Record
  109. customerId : String;
  110. maxResults : integer;
  111. pageToken : String;
  112. end;
  113. TLicenseAssignmentsResource = Class(TGoogleResource)
  114. Public
  115. Class Function ResourceName : String; override;
  116. Class Function DefaultAPI : TGoogleAPIClass; override;
  117. Procedure Delete(productId: string; skuId: string; userId: string);
  118. Function Get(productId: string; skuId: string; userId: string) : TLicenseAssignment;
  119. Function Insert(productId: string; skuId: string; aLicenseAssignmentInsert : TLicenseAssignmentInsert) : TLicenseAssignment;
  120. Function ListForProduct(productId: string; AQuery : string = '') : TLicenseAssignmentList;
  121. Function ListForProduct(productId: string; AQuery : TLicenseAssignmentslistForProductOptions) : TLicenseAssignmentList;
  122. Function ListForProductAndSku(productId: string; skuId: string; AQuery : string = '') : TLicenseAssignmentList;
  123. Function ListForProductAndSku(productId: string; skuId: string; AQuery : TLicenseAssignmentslistForProductAndSkuOptions) : TLicenseAssignmentList;
  124. Function Patch(productId: string; skuId: string; userId: string; aLicenseAssignment : TLicenseAssignment) : TLicenseAssignment;
  125. Function Update(productId: string; skuId: string; userId: string; aLicenseAssignment : TLicenseAssignment) : TLicenseAssignment;
  126. end;
  127. { --------------------------------------------------------------------
  128. TLicensingAPI
  129. --------------------------------------------------------------------}
  130. TLicensingAPI = Class(TGoogleAPI)
  131. Private
  132. FLicenseAssignmentsInstance : TLicenseAssignmentsResource;
  133. Function GetLicenseAssignmentsInstance : TLicenseAssignmentsResource;virtual;
  134. Public
  135. //Override class functions with API info
  136. Class Function APIName : String; override;
  137. Class Function APIVersion : String; override;
  138. Class Function APIRevision : String; override;
  139. Class Function APIID : String; override;
  140. Class Function APITitle : String; override;
  141. Class Function APIDescription : String; override;
  142. Class Function APIOwnerDomain : String; override;
  143. Class Function APIOwnerName : String; override;
  144. Class Function APIIcon16 : String; override;
  145. Class Function APIIcon32 : String; override;
  146. Class Function APIdocumentationLink : String; override;
  147. Class Function APIrootUrl : string; override;
  148. Class Function APIbasePath : string;override;
  149. Class Function APIbaseURL : String;override;
  150. Class Function APIProtocol : string;override;
  151. Class Function APIservicePath : string;override;
  152. Class Function APIbatchPath : String;override;
  153. Class Function APIAuthScopes : TScopeInfoArray;override;
  154. Class Function APINeedsAuth : Boolean;override;
  155. Class Procedure RegisterAPIResources; override;
  156. //Add create function for resources
  157. Function CreateLicenseAssignmentsResource(AOwner : TComponent) : TLicenseAssignmentsResource;virtual;overload;
  158. Function CreateLicenseAssignmentsResource : TLicenseAssignmentsResource;virtual;overload;
  159. //Add default on-demand instances for resources
  160. Property LicenseAssignmentsResource : TLicenseAssignmentsResource Read GetLicenseAssignmentsInstance;
  161. end;
  162. implementation
  163. { --------------------------------------------------------------------
  164. TLicenseAssignment
  165. --------------------------------------------------------------------}
  166. Procedure TLicenseAssignment.Setetags(AIndex : Integer; AValue : String);
  167. begin
  168. If (Fetags=AValue) then exit;
  169. Fetags:=AValue;
  170. MarkPropertyChanged(AIndex);
  171. end;
  172. Procedure TLicenseAssignment.Setkind(AIndex : Integer; AValue : String);
  173. begin
  174. If (Fkind=AValue) then exit;
  175. Fkind:=AValue;
  176. MarkPropertyChanged(AIndex);
  177. end;
  178. Procedure TLicenseAssignment.SetproductId(AIndex : Integer; AValue : String);
  179. begin
  180. If (FproductId=AValue) then exit;
  181. FproductId:=AValue;
  182. MarkPropertyChanged(AIndex);
  183. end;
  184. Procedure TLicenseAssignment.SetselfLink(AIndex : Integer; AValue : String);
  185. begin
  186. If (FselfLink=AValue) then exit;
  187. FselfLink:=AValue;
  188. MarkPropertyChanged(AIndex);
  189. end;
  190. Procedure TLicenseAssignment.SetskuId(AIndex : Integer; AValue : String);
  191. begin
  192. If (FskuId=AValue) then exit;
  193. FskuId:=AValue;
  194. MarkPropertyChanged(AIndex);
  195. end;
  196. Procedure TLicenseAssignment.SetuserId(AIndex : Integer; AValue : String);
  197. begin
  198. If (FuserId=AValue) then exit;
  199. FuserId:=AValue;
  200. MarkPropertyChanged(AIndex);
  201. end;
  202. { --------------------------------------------------------------------
  203. TLicenseAssignmentInsert
  204. --------------------------------------------------------------------}
  205. Procedure TLicenseAssignmentInsert.SetuserId(AIndex : Integer; AValue : String);
  206. begin
  207. If (FuserId=AValue) then exit;
  208. FuserId:=AValue;
  209. MarkPropertyChanged(AIndex);
  210. end;
  211. { --------------------------------------------------------------------
  212. TLicenseAssignmentList
  213. --------------------------------------------------------------------}
  214. Procedure TLicenseAssignmentList.Setetag(AIndex : Integer; AValue : String);
  215. begin
  216. If (Fetag=AValue) then exit;
  217. Fetag:=AValue;
  218. MarkPropertyChanged(AIndex);
  219. end;
  220. Procedure TLicenseAssignmentList.Setitems(AIndex : Integer; AValue : TLicenseAssignmentListTypeitemsArray);
  221. begin
  222. If (Fitems=AValue) then exit;
  223. Fitems:=AValue;
  224. MarkPropertyChanged(AIndex);
  225. end;
  226. Procedure TLicenseAssignmentList.Setkind(AIndex : Integer; AValue : String);
  227. begin
  228. If (Fkind=AValue) then exit;
  229. Fkind:=AValue;
  230. MarkPropertyChanged(AIndex);
  231. end;
  232. Procedure TLicenseAssignmentList.SetnextPageToken(AIndex : Integer; AValue : String);
  233. begin
  234. If (FnextPageToken=AValue) then exit;
  235. FnextPageToken:=AValue;
  236. MarkPropertyChanged(AIndex);
  237. end;
  238. //2.6.4. bug workaround
  239. {$IFDEF VER2_6}
  240. Procedure TLicenseAssignmentList.SetArrayLength(Const AName : String; ALength : Longint);
  241. begin
  242. Case AName of
  243. 'items' : SetLength(Fitems,ALength);
  244. else
  245. Inherited SetArrayLength(AName,ALength);
  246. end;
  247. end;
  248. {$ENDIF VER2_6}
  249. { --------------------------------------------------------------------
  250. TLicenseAssignmentsResource
  251. --------------------------------------------------------------------}
  252. Class Function TLicenseAssignmentsResource.ResourceName : String;
  253. begin
  254. Result:='licenseAssignments';
  255. end;
  256. Class Function TLicenseAssignmentsResource.DefaultAPI : TGoogleAPIClass;
  257. begin
  258. Result:=TlicensingAPI;
  259. end;
  260. Procedure TLicenseAssignmentsResource.Delete(productId: string; skuId: string; userId: string);
  261. Const
  262. _HTTPMethod = 'DELETE';
  263. _Path = '{productId}/sku/{skuId}/user/{userId}';
  264. _Methodid = 'licensing.licenseAssignments.delete';
  265. Var
  266. _P : String;
  267. begin
  268. _P:=SubstitutePath(_Path,['productId',productId,'skuId',skuId,'userId',userId]);
  269. ServiceCall(_HTTPMethod,_P,'',Nil,Nil);
  270. end;
  271. Function TLicenseAssignmentsResource.Get(productId: string; skuId: string; userId: string) : TLicenseAssignment;
  272. Const
  273. _HTTPMethod = 'GET';
  274. _Path = '{productId}/sku/{skuId}/user/{userId}';
  275. _Methodid = 'licensing.licenseAssignments.get';
  276. Var
  277. _P : String;
  278. begin
  279. _P:=SubstitutePath(_Path,['productId',productId,'skuId',skuId,'userId',userId]);
  280. Result:=ServiceCall(_HTTPMethod,_P,'',Nil,TLicenseAssignment) as TLicenseAssignment;
  281. end;
  282. Function TLicenseAssignmentsResource.Insert(productId: string; skuId: string; aLicenseAssignmentInsert : TLicenseAssignmentInsert) : TLicenseAssignment;
  283. Const
  284. _HTTPMethod = 'POST';
  285. _Path = '{productId}/sku/{skuId}/user';
  286. _Methodid = 'licensing.licenseAssignments.insert';
  287. Var
  288. _P : String;
  289. begin
  290. _P:=SubstitutePath(_Path,['productId',productId,'skuId',skuId]);
  291. Result:=ServiceCall(_HTTPMethod,_P,'',aLicenseAssignmentInsert,TLicenseAssignment) as TLicenseAssignment;
  292. end;
  293. Function TLicenseAssignmentsResource.ListForProduct(productId: string; AQuery : string = '') : TLicenseAssignmentList;
  294. Const
  295. _HTTPMethod = 'GET';
  296. _Path = '{productId}/users';
  297. _Methodid = 'licensing.licenseAssignments.listForProduct';
  298. Var
  299. _P : String;
  300. begin
  301. _P:=SubstitutePath(_Path,['productId',productId]);
  302. Result:=ServiceCall(_HTTPMethod,_P,AQuery,Nil,TLicenseAssignmentList) as TLicenseAssignmentList;
  303. end;
  304. Function TLicenseAssignmentsResource.ListForProduct(productId: string; AQuery : TLicenseAssignmentslistForProductOptions) : TLicenseAssignmentList;
  305. Var
  306. _Q : String;
  307. begin
  308. _Q:='';
  309. AddToQuery(_Q,'customerId',AQuery.customerId);
  310. AddToQuery(_Q,'maxResults',AQuery.maxResults);
  311. AddToQuery(_Q,'pageToken',AQuery.pageToken);
  312. Result:=ListForProduct(productId,_Q);
  313. end;
  314. Function TLicenseAssignmentsResource.ListForProductAndSku(productId: string; skuId: string; AQuery : string = '') : TLicenseAssignmentList;
  315. Const
  316. _HTTPMethod = 'GET';
  317. _Path = '{productId}/sku/{skuId}/users';
  318. _Methodid = 'licensing.licenseAssignments.listForProductAndSku';
  319. Var
  320. _P : String;
  321. begin
  322. _P:=SubstitutePath(_Path,['productId',productId,'skuId',skuId]);
  323. Result:=ServiceCall(_HTTPMethod,_P,AQuery,Nil,TLicenseAssignmentList) as TLicenseAssignmentList;
  324. end;
  325. Function TLicenseAssignmentsResource.ListForProductAndSku(productId: string; skuId: string; AQuery : TLicenseAssignmentslistForProductAndSkuOptions) : TLicenseAssignmentList;
  326. Var
  327. _Q : String;
  328. begin
  329. _Q:='';
  330. AddToQuery(_Q,'customerId',AQuery.customerId);
  331. AddToQuery(_Q,'maxResults',AQuery.maxResults);
  332. AddToQuery(_Q,'pageToken',AQuery.pageToken);
  333. Result:=ListForProductAndSku(productId,skuId,_Q);
  334. end;
  335. Function TLicenseAssignmentsResource.Patch(productId: string; skuId: string; userId: string; aLicenseAssignment : TLicenseAssignment) : TLicenseAssignment;
  336. Const
  337. _HTTPMethod = 'PATCH';
  338. _Path = '{productId}/sku/{skuId}/user/{userId}';
  339. _Methodid = 'licensing.licenseAssignments.patch';
  340. Var
  341. _P : String;
  342. begin
  343. _P:=SubstitutePath(_Path,['productId',productId,'skuId',skuId,'userId',userId]);
  344. Result:=ServiceCall(_HTTPMethod,_P,'',aLicenseAssignment,TLicenseAssignment) as TLicenseAssignment;
  345. end;
  346. Function TLicenseAssignmentsResource.Update(productId: string; skuId: string; userId: string; aLicenseAssignment : TLicenseAssignment) : TLicenseAssignment;
  347. Const
  348. _HTTPMethod = 'PUT';
  349. _Path = '{productId}/sku/{skuId}/user/{userId}';
  350. _Methodid = 'licensing.licenseAssignments.update';
  351. Var
  352. _P : String;
  353. begin
  354. _P:=SubstitutePath(_Path,['productId',productId,'skuId',skuId,'userId',userId]);
  355. Result:=ServiceCall(_HTTPMethod,_P,'',aLicenseAssignment,TLicenseAssignment) as TLicenseAssignment;
  356. end;
  357. { --------------------------------------------------------------------
  358. TLicensingAPI
  359. --------------------------------------------------------------------}
  360. Class Function TLicensingAPI.APIName : String;
  361. begin
  362. Result:='licensing';
  363. end;
  364. Class Function TLicensingAPI.APIVersion : String;
  365. begin
  366. Result:='v1';
  367. end;
  368. Class Function TLicensingAPI.APIRevision : String;
  369. begin
  370. Result:='20140122';
  371. end;
  372. Class Function TLicensingAPI.APIID : String;
  373. begin
  374. Result:='licensing:v1';
  375. end;
  376. Class Function TLicensingAPI.APITitle : String;
  377. begin
  378. Result:='Enterprise License Manager API';
  379. end;
  380. Class Function TLicensingAPI.APIDescription : String;
  381. begin
  382. Result:='Licensing API to view and manage license for your domain.';
  383. end;
  384. Class Function TLicensingAPI.APIOwnerDomain : String;
  385. begin
  386. Result:='google.com';
  387. end;
  388. Class Function TLicensingAPI.APIOwnerName : String;
  389. begin
  390. Result:='Google';
  391. end;
  392. Class Function TLicensingAPI.APIIcon16 : String;
  393. begin
  394. Result:='http://www.google.com/images/icons/product/search-16.gif';
  395. end;
  396. Class Function TLicensingAPI.APIIcon32 : String;
  397. begin
  398. Result:='http://www.google.com/images/icons/product/search-32.gif';
  399. end;
  400. Class Function TLicensingAPI.APIdocumentationLink : String;
  401. begin
  402. Result:='https://developers.google.com/google-apps/licensing/';
  403. end;
  404. Class Function TLicensingAPI.APIrootUrl : string;
  405. begin
  406. Result:='https://www.googleapis.com:443/';
  407. end;
  408. Class Function TLicensingAPI.APIbasePath : string;
  409. begin
  410. Result:='/apps/licensing/v1/product/';
  411. end;
  412. Class Function TLicensingAPI.APIbaseURL : String;
  413. begin
  414. Result:='https://www.googleapis.com:443/apps/licensing/v1/product/';
  415. end;
  416. Class Function TLicensingAPI.APIProtocol : string;
  417. begin
  418. Result:='rest';
  419. end;
  420. Class Function TLicensingAPI.APIservicePath : string;
  421. begin
  422. Result:='apps/licensing/v1/product/';
  423. end;
  424. Class Function TLicensingAPI.APIbatchPath : String;
  425. begin
  426. Result:='batch';
  427. end;
  428. Class Function TLicensingAPI.APIAuthScopes : TScopeInfoArray;
  429. begin
  430. SetLength(Result,1);
  431. Result[0].Name:='https://www.googleapis.com/auth/apps.licensing';
  432. Result[0].Description:='View and manage Google Apps licenses for your domain';
  433. end;
  434. Class Function TLicensingAPI.APINeedsAuth : Boolean;
  435. begin
  436. Result:=True;
  437. end;
  438. Class Procedure TLicensingAPI.RegisterAPIResources;
  439. begin
  440. TLicenseAssignment.RegisterObject;
  441. TLicenseAssignmentInsert.RegisterObject;
  442. TLicenseAssignmentList.RegisterObject;
  443. end;
  444. Function TLicensingAPI.GetLicenseAssignmentsInstance : TLicenseAssignmentsResource;
  445. begin
  446. if (FLicenseAssignmentsInstance=Nil) then
  447. FLicenseAssignmentsInstance:=CreateLicenseAssignmentsResource;
  448. Result:=FLicenseAssignmentsInstance;
  449. end;
  450. Function TLicensingAPI.CreateLicenseAssignmentsResource : TLicenseAssignmentsResource;
  451. begin
  452. Result:=CreateLicenseAssignmentsResource(Self);
  453. end;
  454. Function TLicensingAPI.CreateLicenseAssignmentsResource(AOwner : TComponent) : TLicenseAssignmentsResource;
  455. begin
  456. Result:=TLicenseAssignmentsResource.Create(AOwner);
  457. Result.API:=Self.API;
  458. end;
  459. initialization
  460. TLicensingAPI.RegisterAPI;
  461. end.