ari_model_validators.c 139 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013, Digium, Inc.
  5. *
  6. * See http://www.asterisk.org for more information about
  7. * the Asterisk project. Please do not directly contact
  8. * any of the maintainers of this project for assistance;
  9. * the project provides a web site, mailing lists and IRC
  10. * channels for your use.
  11. *
  12. * This program is free software, distributed under the terms of
  13. * the GNU General Public License Version 2. See the LICENSE file
  14. * at the top of the source tree.
  15. */
  16. /*! \file
  17. *
  18. * \brief Generated file - Build validators for ARI model objects.
  19. */
  20. /*
  21. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  22. * !!!!! DO NOT EDIT !!!!!
  23. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  24. * This file is generated by a mustache template. Please see the original
  25. * template in rest-api-templates/ari_model_validators.h.mustache
  26. */
  27. #include "asterisk.h"
  28. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  29. #include "asterisk/logger.h"
  30. #include "asterisk/module.h"
  31. #include "ari_model_validators.h"
  32. int ast_ari_validate_asterisk_info(struct ast_json *json)
  33. {
  34. int res = 1;
  35. struct ast_json_iter *iter;
  36. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  37. if (strcmp("build", ast_json_object_iter_key(iter)) == 0) {
  38. int prop_is_valid;
  39. prop_is_valid = ast_ari_validate_build_info(
  40. ast_json_object_iter_value(iter));
  41. if (!prop_is_valid) {
  42. ast_log(LOG_ERROR, "ARI AsteriskInfo field build failed validation\n");
  43. res = 0;
  44. }
  45. } else
  46. if (strcmp("config", ast_json_object_iter_key(iter)) == 0) {
  47. int prop_is_valid;
  48. prop_is_valid = ast_ari_validate_config_info(
  49. ast_json_object_iter_value(iter));
  50. if (!prop_is_valid) {
  51. ast_log(LOG_ERROR, "ARI AsteriskInfo field config failed validation\n");
  52. res = 0;
  53. }
  54. } else
  55. if (strcmp("status", ast_json_object_iter_key(iter)) == 0) {
  56. int prop_is_valid;
  57. prop_is_valid = ast_ari_validate_status_info(
  58. ast_json_object_iter_value(iter));
  59. if (!prop_is_valid) {
  60. ast_log(LOG_ERROR, "ARI AsteriskInfo field status failed validation\n");
  61. res = 0;
  62. }
  63. } else
  64. if (strcmp("system", ast_json_object_iter_key(iter)) == 0) {
  65. int prop_is_valid;
  66. prop_is_valid = ast_ari_validate_system_info(
  67. ast_json_object_iter_value(iter));
  68. if (!prop_is_valid) {
  69. ast_log(LOG_ERROR, "ARI AsteriskInfo field system failed validation\n");
  70. res = 0;
  71. }
  72. } else
  73. {
  74. ast_log(LOG_ERROR,
  75. "ARI AsteriskInfo has undocumented field %s\n",
  76. ast_json_object_iter_key(iter));
  77. res = 0;
  78. }
  79. }
  80. return res;
  81. }
  82. ari_validator ast_ari_validate_asterisk_info_fn(void)
  83. {
  84. return ast_ari_validate_asterisk_info;
  85. }
  86. int ast_ari_validate_build_info(struct ast_json *json)
  87. {
  88. int res = 1;
  89. struct ast_json_iter *iter;
  90. int has_date = 0;
  91. int has_kernel = 0;
  92. int has_machine = 0;
  93. int has_options = 0;
  94. int has_os = 0;
  95. int has_user = 0;
  96. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  97. if (strcmp("date", ast_json_object_iter_key(iter)) == 0) {
  98. int prop_is_valid;
  99. has_date = 1;
  100. prop_is_valid = ast_ari_validate_string(
  101. ast_json_object_iter_value(iter));
  102. if (!prop_is_valid) {
  103. ast_log(LOG_ERROR, "ARI BuildInfo field date failed validation\n");
  104. res = 0;
  105. }
  106. } else
  107. if (strcmp("kernel", ast_json_object_iter_key(iter)) == 0) {
  108. int prop_is_valid;
  109. has_kernel = 1;
  110. prop_is_valid = ast_ari_validate_string(
  111. ast_json_object_iter_value(iter));
  112. if (!prop_is_valid) {
  113. ast_log(LOG_ERROR, "ARI BuildInfo field kernel failed validation\n");
  114. res = 0;
  115. }
  116. } else
  117. if (strcmp("machine", ast_json_object_iter_key(iter)) == 0) {
  118. int prop_is_valid;
  119. has_machine = 1;
  120. prop_is_valid = ast_ari_validate_string(
  121. ast_json_object_iter_value(iter));
  122. if (!prop_is_valid) {
  123. ast_log(LOG_ERROR, "ARI BuildInfo field machine failed validation\n");
  124. res = 0;
  125. }
  126. } else
  127. if (strcmp("options", ast_json_object_iter_key(iter)) == 0) {
  128. int prop_is_valid;
  129. has_options = 1;
  130. prop_is_valid = ast_ari_validate_string(
  131. ast_json_object_iter_value(iter));
  132. if (!prop_is_valid) {
  133. ast_log(LOG_ERROR, "ARI BuildInfo field options failed validation\n");
  134. res = 0;
  135. }
  136. } else
  137. if (strcmp("os", ast_json_object_iter_key(iter)) == 0) {
  138. int prop_is_valid;
  139. has_os = 1;
  140. prop_is_valid = ast_ari_validate_string(
  141. ast_json_object_iter_value(iter));
  142. if (!prop_is_valid) {
  143. ast_log(LOG_ERROR, "ARI BuildInfo field os failed validation\n");
  144. res = 0;
  145. }
  146. } else
  147. if (strcmp("user", ast_json_object_iter_key(iter)) == 0) {
  148. int prop_is_valid;
  149. has_user = 1;
  150. prop_is_valid = ast_ari_validate_string(
  151. ast_json_object_iter_value(iter));
  152. if (!prop_is_valid) {
  153. ast_log(LOG_ERROR, "ARI BuildInfo field user failed validation\n");
  154. res = 0;
  155. }
  156. } else
  157. {
  158. ast_log(LOG_ERROR,
  159. "ARI BuildInfo has undocumented field %s\n",
  160. ast_json_object_iter_key(iter));
  161. res = 0;
  162. }
  163. }
  164. if (!has_date) {
  165. ast_log(LOG_ERROR, "ARI BuildInfo missing required field date\n");
  166. res = 0;
  167. }
  168. if (!has_kernel) {
  169. ast_log(LOG_ERROR, "ARI BuildInfo missing required field kernel\n");
  170. res = 0;
  171. }
  172. if (!has_machine) {
  173. ast_log(LOG_ERROR, "ARI BuildInfo missing required field machine\n");
  174. res = 0;
  175. }
  176. if (!has_options) {
  177. ast_log(LOG_ERROR, "ARI BuildInfo missing required field options\n");
  178. res = 0;
  179. }
  180. if (!has_os) {
  181. ast_log(LOG_ERROR, "ARI BuildInfo missing required field os\n");
  182. res = 0;
  183. }
  184. if (!has_user) {
  185. ast_log(LOG_ERROR, "ARI BuildInfo missing required field user\n");
  186. res = 0;
  187. }
  188. return res;
  189. }
  190. ari_validator ast_ari_validate_build_info_fn(void)
  191. {
  192. return ast_ari_validate_build_info;
  193. }
  194. int ast_ari_validate_config_info(struct ast_json *json)
  195. {
  196. int res = 1;
  197. struct ast_json_iter *iter;
  198. int has_default_language = 0;
  199. int has_name = 0;
  200. int has_setid = 0;
  201. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  202. if (strcmp("default_language", ast_json_object_iter_key(iter)) == 0) {
  203. int prop_is_valid;
  204. has_default_language = 1;
  205. prop_is_valid = ast_ari_validate_string(
  206. ast_json_object_iter_value(iter));
  207. if (!prop_is_valid) {
  208. ast_log(LOG_ERROR, "ARI ConfigInfo field default_language failed validation\n");
  209. res = 0;
  210. }
  211. } else
  212. if (strcmp("max_channels", ast_json_object_iter_key(iter)) == 0) {
  213. int prop_is_valid;
  214. prop_is_valid = ast_ari_validate_int(
  215. ast_json_object_iter_value(iter));
  216. if (!prop_is_valid) {
  217. ast_log(LOG_ERROR, "ARI ConfigInfo field max_channels failed validation\n");
  218. res = 0;
  219. }
  220. } else
  221. if (strcmp("max_load", ast_json_object_iter_key(iter)) == 0) {
  222. int prop_is_valid;
  223. prop_is_valid = ast_ari_validate_double(
  224. ast_json_object_iter_value(iter));
  225. if (!prop_is_valid) {
  226. ast_log(LOG_ERROR, "ARI ConfigInfo field max_load failed validation\n");
  227. res = 0;
  228. }
  229. } else
  230. if (strcmp("max_open_files", ast_json_object_iter_key(iter)) == 0) {
  231. int prop_is_valid;
  232. prop_is_valid = ast_ari_validate_int(
  233. ast_json_object_iter_value(iter));
  234. if (!prop_is_valid) {
  235. ast_log(LOG_ERROR, "ARI ConfigInfo field max_open_files failed validation\n");
  236. res = 0;
  237. }
  238. } else
  239. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  240. int prop_is_valid;
  241. has_name = 1;
  242. prop_is_valid = ast_ari_validate_string(
  243. ast_json_object_iter_value(iter));
  244. if (!prop_is_valid) {
  245. ast_log(LOG_ERROR, "ARI ConfigInfo field name failed validation\n");
  246. res = 0;
  247. }
  248. } else
  249. if (strcmp("setid", ast_json_object_iter_key(iter)) == 0) {
  250. int prop_is_valid;
  251. has_setid = 1;
  252. prop_is_valid = ast_ari_validate_set_id(
  253. ast_json_object_iter_value(iter));
  254. if (!prop_is_valid) {
  255. ast_log(LOG_ERROR, "ARI ConfigInfo field setid failed validation\n");
  256. res = 0;
  257. }
  258. } else
  259. {
  260. ast_log(LOG_ERROR,
  261. "ARI ConfigInfo has undocumented field %s\n",
  262. ast_json_object_iter_key(iter));
  263. res = 0;
  264. }
  265. }
  266. if (!has_default_language) {
  267. ast_log(LOG_ERROR, "ARI ConfigInfo missing required field default_language\n");
  268. res = 0;
  269. }
  270. if (!has_name) {
  271. ast_log(LOG_ERROR, "ARI ConfigInfo missing required field name\n");
  272. res = 0;
  273. }
  274. if (!has_setid) {
  275. ast_log(LOG_ERROR, "ARI ConfigInfo missing required field setid\n");
  276. res = 0;
  277. }
  278. return res;
  279. }
  280. ari_validator ast_ari_validate_config_info_fn(void)
  281. {
  282. return ast_ari_validate_config_info;
  283. }
  284. int ast_ari_validate_set_id(struct ast_json *json)
  285. {
  286. int res = 1;
  287. struct ast_json_iter *iter;
  288. int has_group = 0;
  289. int has_user = 0;
  290. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  291. if (strcmp("group", ast_json_object_iter_key(iter)) == 0) {
  292. int prop_is_valid;
  293. has_group = 1;
  294. prop_is_valid = ast_ari_validate_string(
  295. ast_json_object_iter_value(iter));
  296. if (!prop_is_valid) {
  297. ast_log(LOG_ERROR, "ARI SetId field group failed validation\n");
  298. res = 0;
  299. }
  300. } else
  301. if (strcmp("user", ast_json_object_iter_key(iter)) == 0) {
  302. int prop_is_valid;
  303. has_user = 1;
  304. prop_is_valid = ast_ari_validate_string(
  305. ast_json_object_iter_value(iter));
  306. if (!prop_is_valid) {
  307. ast_log(LOG_ERROR, "ARI SetId field user failed validation\n");
  308. res = 0;
  309. }
  310. } else
  311. {
  312. ast_log(LOG_ERROR,
  313. "ARI SetId has undocumented field %s\n",
  314. ast_json_object_iter_key(iter));
  315. res = 0;
  316. }
  317. }
  318. if (!has_group) {
  319. ast_log(LOG_ERROR, "ARI SetId missing required field group\n");
  320. res = 0;
  321. }
  322. if (!has_user) {
  323. ast_log(LOG_ERROR, "ARI SetId missing required field user\n");
  324. res = 0;
  325. }
  326. return res;
  327. }
  328. ari_validator ast_ari_validate_set_id_fn(void)
  329. {
  330. return ast_ari_validate_set_id;
  331. }
  332. int ast_ari_validate_status_info(struct ast_json *json)
  333. {
  334. int res = 1;
  335. struct ast_json_iter *iter;
  336. int has_last_reload_time = 0;
  337. int has_startup_time = 0;
  338. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  339. if (strcmp("last_reload_time", ast_json_object_iter_key(iter)) == 0) {
  340. int prop_is_valid;
  341. has_last_reload_time = 1;
  342. prop_is_valid = ast_ari_validate_date(
  343. ast_json_object_iter_value(iter));
  344. if (!prop_is_valid) {
  345. ast_log(LOG_ERROR, "ARI StatusInfo field last_reload_time failed validation\n");
  346. res = 0;
  347. }
  348. } else
  349. if (strcmp("startup_time", ast_json_object_iter_key(iter)) == 0) {
  350. int prop_is_valid;
  351. has_startup_time = 1;
  352. prop_is_valid = ast_ari_validate_date(
  353. ast_json_object_iter_value(iter));
  354. if (!prop_is_valid) {
  355. ast_log(LOG_ERROR, "ARI StatusInfo field startup_time failed validation\n");
  356. res = 0;
  357. }
  358. } else
  359. {
  360. ast_log(LOG_ERROR,
  361. "ARI StatusInfo has undocumented field %s\n",
  362. ast_json_object_iter_key(iter));
  363. res = 0;
  364. }
  365. }
  366. if (!has_last_reload_time) {
  367. ast_log(LOG_ERROR, "ARI StatusInfo missing required field last_reload_time\n");
  368. res = 0;
  369. }
  370. if (!has_startup_time) {
  371. ast_log(LOG_ERROR, "ARI StatusInfo missing required field startup_time\n");
  372. res = 0;
  373. }
  374. return res;
  375. }
  376. ari_validator ast_ari_validate_status_info_fn(void)
  377. {
  378. return ast_ari_validate_status_info;
  379. }
  380. int ast_ari_validate_system_info(struct ast_json *json)
  381. {
  382. int res = 1;
  383. struct ast_json_iter *iter;
  384. int has_entity_id = 0;
  385. int has_version = 0;
  386. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  387. if (strcmp("entity_id", ast_json_object_iter_key(iter)) == 0) {
  388. int prop_is_valid;
  389. has_entity_id = 1;
  390. prop_is_valid = ast_ari_validate_string(
  391. ast_json_object_iter_value(iter));
  392. if (!prop_is_valid) {
  393. ast_log(LOG_ERROR, "ARI SystemInfo field entity_id failed validation\n");
  394. res = 0;
  395. }
  396. } else
  397. if (strcmp("version", ast_json_object_iter_key(iter)) == 0) {
  398. int prop_is_valid;
  399. has_version = 1;
  400. prop_is_valid = ast_ari_validate_string(
  401. ast_json_object_iter_value(iter));
  402. if (!prop_is_valid) {
  403. ast_log(LOG_ERROR, "ARI SystemInfo field version failed validation\n");
  404. res = 0;
  405. }
  406. } else
  407. {
  408. ast_log(LOG_ERROR,
  409. "ARI SystemInfo has undocumented field %s\n",
  410. ast_json_object_iter_key(iter));
  411. res = 0;
  412. }
  413. }
  414. if (!has_entity_id) {
  415. ast_log(LOG_ERROR, "ARI SystemInfo missing required field entity_id\n");
  416. res = 0;
  417. }
  418. if (!has_version) {
  419. ast_log(LOG_ERROR, "ARI SystemInfo missing required field version\n");
  420. res = 0;
  421. }
  422. return res;
  423. }
  424. ari_validator ast_ari_validate_system_info_fn(void)
  425. {
  426. return ast_ari_validate_system_info;
  427. }
  428. int ast_ari_validate_variable(struct ast_json *json)
  429. {
  430. int res = 1;
  431. struct ast_json_iter *iter;
  432. int has_value = 0;
  433. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  434. if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
  435. int prop_is_valid;
  436. has_value = 1;
  437. prop_is_valid = ast_ari_validate_string(
  438. ast_json_object_iter_value(iter));
  439. if (!prop_is_valid) {
  440. ast_log(LOG_ERROR, "ARI Variable field value failed validation\n");
  441. res = 0;
  442. }
  443. } else
  444. {
  445. ast_log(LOG_ERROR,
  446. "ARI Variable has undocumented field %s\n",
  447. ast_json_object_iter_key(iter));
  448. res = 0;
  449. }
  450. }
  451. if (!has_value) {
  452. ast_log(LOG_ERROR, "ARI Variable missing required field value\n");
  453. res = 0;
  454. }
  455. return res;
  456. }
  457. ari_validator ast_ari_validate_variable_fn(void)
  458. {
  459. return ast_ari_validate_variable;
  460. }
  461. int ast_ari_validate_endpoint(struct ast_json *json)
  462. {
  463. int res = 1;
  464. struct ast_json_iter *iter;
  465. int has_channel_ids = 0;
  466. int has_resource = 0;
  467. int has_technology = 0;
  468. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  469. if (strcmp("channel_ids", ast_json_object_iter_key(iter)) == 0) {
  470. int prop_is_valid;
  471. has_channel_ids = 1;
  472. prop_is_valid = ast_ari_validate_list(
  473. ast_json_object_iter_value(iter),
  474. ast_ari_validate_string);
  475. if (!prop_is_valid) {
  476. ast_log(LOG_ERROR, "ARI Endpoint field channel_ids failed validation\n");
  477. res = 0;
  478. }
  479. } else
  480. if (strcmp("resource", ast_json_object_iter_key(iter)) == 0) {
  481. int prop_is_valid;
  482. has_resource = 1;
  483. prop_is_valid = ast_ari_validate_string(
  484. ast_json_object_iter_value(iter));
  485. if (!prop_is_valid) {
  486. ast_log(LOG_ERROR, "ARI Endpoint field resource failed validation\n");
  487. res = 0;
  488. }
  489. } else
  490. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  491. int prop_is_valid;
  492. prop_is_valid = ast_ari_validate_string(
  493. ast_json_object_iter_value(iter));
  494. if (!prop_is_valid) {
  495. ast_log(LOG_ERROR, "ARI Endpoint field state failed validation\n");
  496. res = 0;
  497. }
  498. } else
  499. if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
  500. int prop_is_valid;
  501. has_technology = 1;
  502. prop_is_valid = ast_ari_validate_string(
  503. ast_json_object_iter_value(iter));
  504. if (!prop_is_valid) {
  505. ast_log(LOG_ERROR, "ARI Endpoint field technology failed validation\n");
  506. res = 0;
  507. }
  508. } else
  509. {
  510. ast_log(LOG_ERROR,
  511. "ARI Endpoint has undocumented field %s\n",
  512. ast_json_object_iter_key(iter));
  513. res = 0;
  514. }
  515. }
  516. if (!has_channel_ids) {
  517. ast_log(LOG_ERROR, "ARI Endpoint missing required field channel_ids\n");
  518. res = 0;
  519. }
  520. if (!has_resource) {
  521. ast_log(LOG_ERROR, "ARI Endpoint missing required field resource\n");
  522. res = 0;
  523. }
  524. if (!has_technology) {
  525. ast_log(LOG_ERROR, "ARI Endpoint missing required field technology\n");
  526. res = 0;
  527. }
  528. return res;
  529. }
  530. ari_validator ast_ari_validate_endpoint_fn(void)
  531. {
  532. return ast_ari_validate_endpoint;
  533. }
  534. int ast_ari_validate_text_message(struct ast_json *json)
  535. {
  536. int res = 1;
  537. struct ast_json_iter *iter;
  538. int has_body = 0;
  539. int has_from = 0;
  540. int has_to = 0;
  541. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  542. if (strcmp("body", ast_json_object_iter_key(iter)) == 0) {
  543. int prop_is_valid;
  544. has_body = 1;
  545. prop_is_valid = ast_ari_validate_string(
  546. ast_json_object_iter_value(iter));
  547. if (!prop_is_valid) {
  548. ast_log(LOG_ERROR, "ARI TextMessage field body failed validation\n");
  549. res = 0;
  550. }
  551. } else
  552. if (strcmp("from", ast_json_object_iter_key(iter)) == 0) {
  553. int prop_is_valid;
  554. has_from = 1;
  555. prop_is_valid = ast_ari_validate_string(
  556. ast_json_object_iter_value(iter));
  557. if (!prop_is_valid) {
  558. ast_log(LOG_ERROR, "ARI TextMessage field from failed validation\n");
  559. res = 0;
  560. }
  561. } else
  562. if (strcmp("to", ast_json_object_iter_key(iter)) == 0) {
  563. int prop_is_valid;
  564. has_to = 1;
  565. prop_is_valid = ast_ari_validate_string(
  566. ast_json_object_iter_value(iter));
  567. if (!prop_is_valid) {
  568. ast_log(LOG_ERROR, "ARI TextMessage field to failed validation\n");
  569. res = 0;
  570. }
  571. } else
  572. if (strcmp("variables", ast_json_object_iter_key(iter)) == 0) {
  573. int prop_is_valid;
  574. prop_is_valid = ast_ari_validate_list(
  575. ast_json_object_iter_value(iter),
  576. ast_ari_validate_text_message_variable);
  577. if (!prop_is_valid) {
  578. ast_log(LOG_ERROR, "ARI TextMessage field variables failed validation\n");
  579. res = 0;
  580. }
  581. } else
  582. {
  583. ast_log(LOG_ERROR,
  584. "ARI TextMessage has undocumented field %s\n",
  585. ast_json_object_iter_key(iter));
  586. res = 0;
  587. }
  588. }
  589. if (!has_body) {
  590. ast_log(LOG_ERROR, "ARI TextMessage missing required field body\n");
  591. res = 0;
  592. }
  593. if (!has_from) {
  594. ast_log(LOG_ERROR, "ARI TextMessage missing required field from\n");
  595. res = 0;
  596. }
  597. if (!has_to) {
  598. ast_log(LOG_ERROR, "ARI TextMessage missing required field to\n");
  599. res = 0;
  600. }
  601. return res;
  602. }
  603. ari_validator ast_ari_validate_text_message_fn(void)
  604. {
  605. return ast_ari_validate_text_message;
  606. }
  607. int ast_ari_validate_text_message_variable(struct ast_json *json)
  608. {
  609. int res = 1;
  610. struct ast_json_iter *iter;
  611. int has_key = 0;
  612. int has_value = 0;
  613. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  614. if (strcmp("key", ast_json_object_iter_key(iter)) == 0) {
  615. int prop_is_valid;
  616. has_key = 1;
  617. prop_is_valid = ast_ari_validate_string(
  618. ast_json_object_iter_value(iter));
  619. if (!prop_is_valid) {
  620. ast_log(LOG_ERROR, "ARI TextMessageVariable field key failed validation\n");
  621. res = 0;
  622. }
  623. } else
  624. if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
  625. int prop_is_valid;
  626. has_value = 1;
  627. prop_is_valid = ast_ari_validate_string(
  628. ast_json_object_iter_value(iter));
  629. if (!prop_is_valid) {
  630. ast_log(LOG_ERROR, "ARI TextMessageVariable field value failed validation\n");
  631. res = 0;
  632. }
  633. } else
  634. {
  635. ast_log(LOG_ERROR,
  636. "ARI TextMessageVariable has undocumented field %s\n",
  637. ast_json_object_iter_key(iter));
  638. res = 0;
  639. }
  640. }
  641. if (!has_key) {
  642. ast_log(LOG_ERROR, "ARI TextMessageVariable missing required field key\n");
  643. res = 0;
  644. }
  645. if (!has_value) {
  646. ast_log(LOG_ERROR, "ARI TextMessageVariable missing required field value\n");
  647. res = 0;
  648. }
  649. return res;
  650. }
  651. ari_validator ast_ari_validate_text_message_variable_fn(void)
  652. {
  653. return ast_ari_validate_text_message_variable;
  654. }
  655. int ast_ari_validate_caller_id(struct ast_json *json)
  656. {
  657. int res = 1;
  658. struct ast_json_iter *iter;
  659. int has_name = 0;
  660. int has_number = 0;
  661. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  662. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  663. int prop_is_valid;
  664. has_name = 1;
  665. prop_is_valid = ast_ari_validate_string(
  666. ast_json_object_iter_value(iter));
  667. if (!prop_is_valid) {
  668. ast_log(LOG_ERROR, "ARI CallerID field name failed validation\n");
  669. res = 0;
  670. }
  671. } else
  672. if (strcmp("number", ast_json_object_iter_key(iter)) == 0) {
  673. int prop_is_valid;
  674. has_number = 1;
  675. prop_is_valid = ast_ari_validate_string(
  676. ast_json_object_iter_value(iter));
  677. if (!prop_is_valid) {
  678. ast_log(LOG_ERROR, "ARI CallerID field number failed validation\n");
  679. res = 0;
  680. }
  681. } else
  682. {
  683. ast_log(LOG_ERROR,
  684. "ARI CallerID has undocumented field %s\n",
  685. ast_json_object_iter_key(iter));
  686. res = 0;
  687. }
  688. }
  689. if (!has_name) {
  690. ast_log(LOG_ERROR, "ARI CallerID missing required field name\n");
  691. res = 0;
  692. }
  693. if (!has_number) {
  694. ast_log(LOG_ERROR, "ARI CallerID missing required field number\n");
  695. res = 0;
  696. }
  697. return res;
  698. }
  699. ari_validator ast_ari_validate_caller_id_fn(void)
  700. {
  701. return ast_ari_validate_caller_id;
  702. }
  703. int ast_ari_validate_channel(struct ast_json *json)
  704. {
  705. int res = 1;
  706. struct ast_json_iter *iter;
  707. int has_accountcode = 0;
  708. int has_caller = 0;
  709. int has_connected = 0;
  710. int has_creationtime = 0;
  711. int has_dialplan = 0;
  712. int has_id = 0;
  713. int has_name = 0;
  714. int has_state = 0;
  715. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  716. if (strcmp("accountcode", ast_json_object_iter_key(iter)) == 0) {
  717. int prop_is_valid;
  718. has_accountcode = 1;
  719. prop_is_valid = ast_ari_validate_string(
  720. ast_json_object_iter_value(iter));
  721. if (!prop_is_valid) {
  722. ast_log(LOG_ERROR, "ARI Channel field accountcode failed validation\n");
  723. res = 0;
  724. }
  725. } else
  726. if (strcmp("caller", ast_json_object_iter_key(iter)) == 0) {
  727. int prop_is_valid;
  728. has_caller = 1;
  729. prop_is_valid = ast_ari_validate_caller_id(
  730. ast_json_object_iter_value(iter));
  731. if (!prop_is_valid) {
  732. ast_log(LOG_ERROR, "ARI Channel field caller failed validation\n");
  733. res = 0;
  734. }
  735. } else
  736. if (strcmp("connected", ast_json_object_iter_key(iter)) == 0) {
  737. int prop_is_valid;
  738. has_connected = 1;
  739. prop_is_valid = ast_ari_validate_caller_id(
  740. ast_json_object_iter_value(iter));
  741. if (!prop_is_valid) {
  742. ast_log(LOG_ERROR, "ARI Channel field connected failed validation\n");
  743. res = 0;
  744. }
  745. } else
  746. if (strcmp("creationtime", ast_json_object_iter_key(iter)) == 0) {
  747. int prop_is_valid;
  748. has_creationtime = 1;
  749. prop_is_valid = ast_ari_validate_date(
  750. ast_json_object_iter_value(iter));
  751. if (!prop_is_valid) {
  752. ast_log(LOG_ERROR, "ARI Channel field creationtime failed validation\n");
  753. res = 0;
  754. }
  755. } else
  756. if (strcmp("dialplan", ast_json_object_iter_key(iter)) == 0) {
  757. int prop_is_valid;
  758. has_dialplan = 1;
  759. prop_is_valid = ast_ari_validate_dialplan_cep(
  760. ast_json_object_iter_value(iter));
  761. if (!prop_is_valid) {
  762. ast_log(LOG_ERROR, "ARI Channel field dialplan failed validation\n");
  763. res = 0;
  764. }
  765. } else
  766. if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
  767. int prop_is_valid;
  768. has_id = 1;
  769. prop_is_valid = ast_ari_validate_string(
  770. ast_json_object_iter_value(iter));
  771. if (!prop_is_valid) {
  772. ast_log(LOG_ERROR, "ARI Channel field id failed validation\n");
  773. res = 0;
  774. }
  775. } else
  776. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  777. int prop_is_valid;
  778. has_name = 1;
  779. prop_is_valid = ast_ari_validate_string(
  780. ast_json_object_iter_value(iter));
  781. if (!prop_is_valid) {
  782. ast_log(LOG_ERROR, "ARI Channel field name failed validation\n");
  783. res = 0;
  784. }
  785. } else
  786. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  787. int prop_is_valid;
  788. has_state = 1;
  789. prop_is_valid = ast_ari_validate_string(
  790. ast_json_object_iter_value(iter));
  791. if (!prop_is_valid) {
  792. ast_log(LOG_ERROR, "ARI Channel field state failed validation\n");
  793. res = 0;
  794. }
  795. } else
  796. {
  797. ast_log(LOG_ERROR,
  798. "ARI Channel has undocumented field %s\n",
  799. ast_json_object_iter_key(iter));
  800. res = 0;
  801. }
  802. }
  803. if (!has_accountcode) {
  804. ast_log(LOG_ERROR, "ARI Channel missing required field accountcode\n");
  805. res = 0;
  806. }
  807. if (!has_caller) {
  808. ast_log(LOG_ERROR, "ARI Channel missing required field caller\n");
  809. res = 0;
  810. }
  811. if (!has_connected) {
  812. ast_log(LOG_ERROR, "ARI Channel missing required field connected\n");
  813. res = 0;
  814. }
  815. if (!has_creationtime) {
  816. ast_log(LOG_ERROR, "ARI Channel missing required field creationtime\n");
  817. res = 0;
  818. }
  819. if (!has_dialplan) {
  820. ast_log(LOG_ERROR, "ARI Channel missing required field dialplan\n");
  821. res = 0;
  822. }
  823. if (!has_id) {
  824. ast_log(LOG_ERROR, "ARI Channel missing required field id\n");
  825. res = 0;
  826. }
  827. if (!has_name) {
  828. ast_log(LOG_ERROR, "ARI Channel missing required field name\n");
  829. res = 0;
  830. }
  831. if (!has_state) {
  832. ast_log(LOG_ERROR, "ARI Channel missing required field state\n");
  833. res = 0;
  834. }
  835. return res;
  836. }
  837. ari_validator ast_ari_validate_channel_fn(void)
  838. {
  839. return ast_ari_validate_channel;
  840. }
  841. int ast_ari_validate_dialed(struct ast_json *json)
  842. {
  843. int res = 1;
  844. struct ast_json_iter *iter;
  845. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  846. {
  847. ast_log(LOG_ERROR,
  848. "ARI Dialed has undocumented field %s\n",
  849. ast_json_object_iter_key(iter));
  850. res = 0;
  851. }
  852. }
  853. return res;
  854. }
  855. ari_validator ast_ari_validate_dialed_fn(void)
  856. {
  857. return ast_ari_validate_dialed;
  858. }
  859. int ast_ari_validate_dialplan_cep(struct ast_json *json)
  860. {
  861. int res = 1;
  862. struct ast_json_iter *iter;
  863. int has_context = 0;
  864. int has_exten = 0;
  865. int has_priority = 0;
  866. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  867. if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
  868. int prop_is_valid;
  869. has_context = 1;
  870. prop_is_valid = ast_ari_validate_string(
  871. ast_json_object_iter_value(iter));
  872. if (!prop_is_valid) {
  873. ast_log(LOG_ERROR, "ARI DialplanCEP field context failed validation\n");
  874. res = 0;
  875. }
  876. } else
  877. if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
  878. int prop_is_valid;
  879. has_exten = 1;
  880. prop_is_valid = ast_ari_validate_string(
  881. ast_json_object_iter_value(iter));
  882. if (!prop_is_valid) {
  883. ast_log(LOG_ERROR, "ARI DialplanCEP field exten failed validation\n");
  884. res = 0;
  885. }
  886. } else
  887. if (strcmp("priority", ast_json_object_iter_key(iter)) == 0) {
  888. int prop_is_valid;
  889. has_priority = 1;
  890. prop_is_valid = ast_ari_validate_long(
  891. ast_json_object_iter_value(iter));
  892. if (!prop_is_valid) {
  893. ast_log(LOG_ERROR, "ARI DialplanCEP field priority failed validation\n");
  894. res = 0;
  895. }
  896. } else
  897. {
  898. ast_log(LOG_ERROR,
  899. "ARI DialplanCEP has undocumented field %s\n",
  900. ast_json_object_iter_key(iter));
  901. res = 0;
  902. }
  903. }
  904. if (!has_context) {
  905. ast_log(LOG_ERROR, "ARI DialplanCEP missing required field context\n");
  906. res = 0;
  907. }
  908. if (!has_exten) {
  909. ast_log(LOG_ERROR, "ARI DialplanCEP missing required field exten\n");
  910. res = 0;
  911. }
  912. if (!has_priority) {
  913. ast_log(LOG_ERROR, "ARI DialplanCEP missing required field priority\n");
  914. res = 0;
  915. }
  916. return res;
  917. }
  918. ari_validator ast_ari_validate_dialplan_cep_fn(void)
  919. {
  920. return ast_ari_validate_dialplan_cep;
  921. }
  922. int ast_ari_validate_bridge(struct ast_json *json)
  923. {
  924. int res = 1;
  925. struct ast_json_iter *iter;
  926. int has_bridge_class = 0;
  927. int has_bridge_type = 0;
  928. int has_channels = 0;
  929. int has_creator = 0;
  930. int has_id = 0;
  931. int has_name = 0;
  932. int has_technology = 0;
  933. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  934. if (strcmp("bridge_class", ast_json_object_iter_key(iter)) == 0) {
  935. int prop_is_valid;
  936. has_bridge_class = 1;
  937. prop_is_valid = ast_ari_validate_string(
  938. ast_json_object_iter_value(iter));
  939. if (!prop_is_valid) {
  940. ast_log(LOG_ERROR, "ARI Bridge field bridge_class failed validation\n");
  941. res = 0;
  942. }
  943. } else
  944. if (strcmp("bridge_type", ast_json_object_iter_key(iter)) == 0) {
  945. int prop_is_valid;
  946. has_bridge_type = 1;
  947. prop_is_valid = ast_ari_validate_string(
  948. ast_json_object_iter_value(iter));
  949. if (!prop_is_valid) {
  950. ast_log(LOG_ERROR, "ARI Bridge field bridge_type failed validation\n");
  951. res = 0;
  952. }
  953. } else
  954. if (strcmp("channels", ast_json_object_iter_key(iter)) == 0) {
  955. int prop_is_valid;
  956. has_channels = 1;
  957. prop_is_valid = ast_ari_validate_list(
  958. ast_json_object_iter_value(iter),
  959. ast_ari_validate_string);
  960. if (!prop_is_valid) {
  961. ast_log(LOG_ERROR, "ARI Bridge field channels failed validation\n");
  962. res = 0;
  963. }
  964. } else
  965. if (strcmp("creator", ast_json_object_iter_key(iter)) == 0) {
  966. int prop_is_valid;
  967. has_creator = 1;
  968. prop_is_valid = ast_ari_validate_string(
  969. ast_json_object_iter_value(iter));
  970. if (!prop_is_valid) {
  971. ast_log(LOG_ERROR, "ARI Bridge field creator failed validation\n");
  972. res = 0;
  973. }
  974. } else
  975. if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
  976. int prop_is_valid;
  977. has_id = 1;
  978. prop_is_valid = ast_ari_validate_string(
  979. ast_json_object_iter_value(iter));
  980. if (!prop_is_valid) {
  981. ast_log(LOG_ERROR, "ARI Bridge field id failed validation\n");
  982. res = 0;
  983. }
  984. } else
  985. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  986. int prop_is_valid;
  987. has_name = 1;
  988. prop_is_valid = ast_ari_validate_string(
  989. ast_json_object_iter_value(iter));
  990. if (!prop_is_valid) {
  991. ast_log(LOG_ERROR, "ARI Bridge field name failed validation\n");
  992. res = 0;
  993. }
  994. } else
  995. if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
  996. int prop_is_valid;
  997. has_technology = 1;
  998. prop_is_valid = ast_ari_validate_string(
  999. ast_json_object_iter_value(iter));
  1000. if (!prop_is_valid) {
  1001. ast_log(LOG_ERROR, "ARI Bridge field technology failed validation\n");
  1002. res = 0;
  1003. }
  1004. } else
  1005. {
  1006. ast_log(LOG_ERROR,
  1007. "ARI Bridge has undocumented field %s\n",
  1008. ast_json_object_iter_key(iter));
  1009. res = 0;
  1010. }
  1011. }
  1012. if (!has_bridge_class) {
  1013. ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_class\n");
  1014. res = 0;
  1015. }
  1016. if (!has_bridge_type) {
  1017. ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_type\n");
  1018. res = 0;
  1019. }
  1020. if (!has_channels) {
  1021. ast_log(LOG_ERROR, "ARI Bridge missing required field channels\n");
  1022. res = 0;
  1023. }
  1024. if (!has_creator) {
  1025. ast_log(LOG_ERROR, "ARI Bridge missing required field creator\n");
  1026. res = 0;
  1027. }
  1028. if (!has_id) {
  1029. ast_log(LOG_ERROR, "ARI Bridge missing required field id\n");
  1030. res = 0;
  1031. }
  1032. if (!has_name) {
  1033. ast_log(LOG_ERROR, "ARI Bridge missing required field name\n");
  1034. res = 0;
  1035. }
  1036. if (!has_technology) {
  1037. ast_log(LOG_ERROR, "ARI Bridge missing required field technology\n");
  1038. res = 0;
  1039. }
  1040. return res;
  1041. }
  1042. ari_validator ast_ari_validate_bridge_fn(void)
  1043. {
  1044. return ast_ari_validate_bridge;
  1045. }
  1046. int ast_ari_validate_live_recording(struct ast_json *json)
  1047. {
  1048. int res = 1;
  1049. struct ast_json_iter *iter;
  1050. int has_format = 0;
  1051. int has_name = 0;
  1052. int has_state = 0;
  1053. int has_target_uri = 0;
  1054. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1055. if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
  1056. int prop_is_valid;
  1057. prop_is_valid = ast_ari_validate_string(
  1058. ast_json_object_iter_value(iter));
  1059. if (!prop_is_valid) {
  1060. ast_log(LOG_ERROR, "ARI LiveRecording field cause failed validation\n");
  1061. res = 0;
  1062. }
  1063. } else
  1064. if (strcmp("duration", ast_json_object_iter_key(iter)) == 0) {
  1065. int prop_is_valid;
  1066. prop_is_valid = ast_ari_validate_int(
  1067. ast_json_object_iter_value(iter));
  1068. if (!prop_is_valid) {
  1069. ast_log(LOG_ERROR, "ARI LiveRecording field duration failed validation\n");
  1070. res = 0;
  1071. }
  1072. } else
  1073. if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
  1074. int prop_is_valid;
  1075. has_format = 1;
  1076. prop_is_valid = ast_ari_validate_string(
  1077. ast_json_object_iter_value(iter));
  1078. if (!prop_is_valid) {
  1079. ast_log(LOG_ERROR, "ARI LiveRecording field format failed validation\n");
  1080. res = 0;
  1081. }
  1082. } else
  1083. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1084. int prop_is_valid;
  1085. has_name = 1;
  1086. prop_is_valid = ast_ari_validate_string(
  1087. ast_json_object_iter_value(iter));
  1088. if (!prop_is_valid) {
  1089. ast_log(LOG_ERROR, "ARI LiveRecording field name failed validation\n");
  1090. res = 0;
  1091. }
  1092. } else
  1093. if (strcmp("silence_duration", ast_json_object_iter_key(iter)) == 0) {
  1094. int prop_is_valid;
  1095. prop_is_valid = ast_ari_validate_int(
  1096. ast_json_object_iter_value(iter));
  1097. if (!prop_is_valid) {
  1098. ast_log(LOG_ERROR, "ARI LiveRecording field silence_duration failed validation\n");
  1099. res = 0;
  1100. }
  1101. } else
  1102. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  1103. int prop_is_valid;
  1104. has_state = 1;
  1105. prop_is_valid = ast_ari_validate_string(
  1106. ast_json_object_iter_value(iter));
  1107. if (!prop_is_valid) {
  1108. ast_log(LOG_ERROR, "ARI LiveRecording field state failed validation\n");
  1109. res = 0;
  1110. }
  1111. } else
  1112. if (strcmp("talking_duration", ast_json_object_iter_key(iter)) == 0) {
  1113. int prop_is_valid;
  1114. prop_is_valid = ast_ari_validate_int(
  1115. ast_json_object_iter_value(iter));
  1116. if (!prop_is_valid) {
  1117. ast_log(LOG_ERROR, "ARI LiveRecording field talking_duration failed validation\n");
  1118. res = 0;
  1119. }
  1120. } else
  1121. if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
  1122. int prop_is_valid;
  1123. has_target_uri = 1;
  1124. prop_is_valid = ast_ari_validate_string(
  1125. ast_json_object_iter_value(iter));
  1126. if (!prop_is_valid) {
  1127. ast_log(LOG_ERROR, "ARI LiveRecording field target_uri failed validation\n");
  1128. res = 0;
  1129. }
  1130. } else
  1131. {
  1132. ast_log(LOG_ERROR,
  1133. "ARI LiveRecording has undocumented field %s\n",
  1134. ast_json_object_iter_key(iter));
  1135. res = 0;
  1136. }
  1137. }
  1138. if (!has_format) {
  1139. ast_log(LOG_ERROR, "ARI LiveRecording missing required field format\n");
  1140. res = 0;
  1141. }
  1142. if (!has_name) {
  1143. ast_log(LOG_ERROR, "ARI LiveRecording missing required field name\n");
  1144. res = 0;
  1145. }
  1146. if (!has_state) {
  1147. ast_log(LOG_ERROR, "ARI LiveRecording missing required field state\n");
  1148. res = 0;
  1149. }
  1150. if (!has_target_uri) {
  1151. ast_log(LOG_ERROR, "ARI LiveRecording missing required field target_uri\n");
  1152. res = 0;
  1153. }
  1154. return res;
  1155. }
  1156. ari_validator ast_ari_validate_live_recording_fn(void)
  1157. {
  1158. return ast_ari_validate_live_recording;
  1159. }
  1160. int ast_ari_validate_stored_recording(struct ast_json *json)
  1161. {
  1162. int res = 1;
  1163. struct ast_json_iter *iter;
  1164. int has_format = 0;
  1165. int has_name = 0;
  1166. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1167. if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
  1168. int prop_is_valid;
  1169. has_format = 1;
  1170. prop_is_valid = ast_ari_validate_string(
  1171. ast_json_object_iter_value(iter));
  1172. if (!prop_is_valid) {
  1173. ast_log(LOG_ERROR, "ARI StoredRecording field format failed validation\n");
  1174. res = 0;
  1175. }
  1176. } else
  1177. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1178. int prop_is_valid;
  1179. has_name = 1;
  1180. prop_is_valid = ast_ari_validate_string(
  1181. ast_json_object_iter_value(iter));
  1182. if (!prop_is_valid) {
  1183. ast_log(LOG_ERROR, "ARI StoredRecording field name failed validation\n");
  1184. res = 0;
  1185. }
  1186. } else
  1187. {
  1188. ast_log(LOG_ERROR,
  1189. "ARI StoredRecording has undocumented field %s\n",
  1190. ast_json_object_iter_key(iter));
  1191. res = 0;
  1192. }
  1193. }
  1194. if (!has_format) {
  1195. ast_log(LOG_ERROR, "ARI StoredRecording missing required field format\n");
  1196. res = 0;
  1197. }
  1198. if (!has_name) {
  1199. ast_log(LOG_ERROR, "ARI StoredRecording missing required field name\n");
  1200. res = 0;
  1201. }
  1202. return res;
  1203. }
  1204. ari_validator ast_ari_validate_stored_recording_fn(void)
  1205. {
  1206. return ast_ari_validate_stored_recording;
  1207. }
  1208. int ast_ari_validate_format_lang_pair(struct ast_json *json)
  1209. {
  1210. int res = 1;
  1211. struct ast_json_iter *iter;
  1212. int has_format = 0;
  1213. int has_language = 0;
  1214. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1215. if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
  1216. int prop_is_valid;
  1217. has_format = 1;
  1218. prop_is_valid = ast_ari_validate_string(
  1219. ast_json_object_iter_value(iter));
  1220. if (!prop_is_valid) {
  1221. ast_log(LOG_ERROR, "ARI FormatLangPair field format failed validation\n");
  1222. res = 0;
  1223. }
  1224. } else
  1225. if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
  1226. int prop_is_valid;
  1227. has_language = 1;
  1228. prop_is_valid = ast_ari_validate_string(
  1229. ast_json_object_iter_value(iter));
  1230. if (!prop_is_valid) {
  1231. ast_log(LOG_ERROR, "ARI FormatLangPair field language failed validation\n");
  1232. res = 0;
  1233. }
  1234. } else
  1235. {
  1236. ast_log(LOG_ERROR,
  1237. "ARI FormatLangPair has undocumented field %s\n",
  1238. ast_json_object_iter_key(iter));
  1239. res = 0;
  1240. }
  1241. }
  1242. if (!has_format) {
  1243. ast_log(LOG_ERROR, "ARI FormatLangPair missing required field format\n");
  1244. res = 0;
  1245. }
  1246. if (!has_language) {
  1247. ast_log(LOG_ERROR, "ARI FormatLangPair missing required field language\n");
  1248. res = 0;
  1249. }
  1250. return res;
  1251. }
  1252. ari_validator ast_ari_validate_format_lang_pair_fn(void)
  1253. {
  1254. return ast_ari_validate_format_lang_pair;
  1255. }
  1256. int ast_ari_validate_sound(struct ast_json *json)
  1257. {
  1258. int res = 1;
  1259. struct ast_json_iter *iter;
  1260. int has_formats = 0;
  1261. int has_id = 0;
  1262. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1263. if (strcmp("formats", ast_json_object_iter_key(iter)) == 0) {
  1264. int prop_is_valid;
  1265. has_formats = 1;
  1266. prop_is_valid = ast_ari_validate_list(
  1267. ast_json_object_iter_value(iter),
  1268. ast_ari_validate_format_lang_pair);
  1269. if (!prop_is_valid) {
  1270. ast_log(LOG_ERROR, "ARI Sound field formats failed validation\n");
  1271. res = 0;
  1272. }
  1273. } else
  1274. if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
  1275. int prop_is_valid;
  1276. has_id = 1;
  1277. prop_is_valid = ast_ari_validate_string(
  1278. ast_json_object_iter_value(iter));
  1279. if (!prop_is_valid) {
  1280. ast_log(LOG_ERROR, "ARI Sound field id failed validation\n");
  1281. res = 0;
  1282. }
  1283. } else
  1284. if (strcmp("text", ast_json_object_iter_key(iter)) == 0) {
  1285. int prop_is_valid;
  1286. prop_is_valid = ast_ari_validate_string(
  1287. ast_json_object_iter_value(iter));
  1288. if (!prop_is_valid) {
  1289. ast_log(LOG_ERROR, "ARI Sound field text failed validation\n");
  1290. res = 0;
  1291. }
  1292. } else
  1293. {
  1294. ast_log(LOG_ERROR,
  1295. "ARI Sound has undocumented field %s\n",
  1296. ast_json_object_iter_key(iter));
  1297. res = 0;
  1298. }
  1299. }
  1300. if (!has_formats) {
  1301. ast_log(LOG_ERROR, "ARI Sound missing required field formats\n");
  1302. res = 0;
  1303. }
  1304. if (!has_id) {
  1305. ast_log(LOG_ERROR, "ARI Sound missing required field id\n");
  1306. res = 0;
  1307. }
  1308. return res;
  1309. }
  1310. ari_validator ast_ari_validate_sound_fn(void)
  1311. {
  1312. return ast_ari_validate_sound;
  1313. }
  1314. int ast_ari_validate_playback(struct ast_json *json)
  1315. {
  1316. int res = 1;
  1317. struct ast_json_iter *iter;
  1318. int has_id = 0;
  1319. int has_media_uri = 0;
  1320. int has_state = 0;
  1321. int has_target_uri = 0;
  1322. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1323. if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
  1324. int prop_is_valid;
  1325. has_id = 1;
  1326. prop_is_valid = ast_ari_validate_string(
  1327. ast_json_object_iter_value(iter));
  1328. if (!prop_is_valid) {
  1329. ast_log(LOG_ERROR, "ARI Playback field id failed validation\n");
  1330. res = 0;
  1331. }
  1332. } else
  1333. if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
  1334. int prop_is_valid;
  1335. prop_is_valid = ast_ari_validate_string(
  1336. ast_json_object_iter_value(iter));
  1337. if (!prop_is_valid) {
  1338. ast_log(LOG_ERROR, "ARI Playback field language failed validation\n");
  1339. res = 0;
  1340. }
  1341. } else
  1342. if (strcmp("media_uri", ast_json_object_iter_key(iter)) == 0) {
  1343. int prop_is_valid;
  1344. has_media_uri = 1;
  1345. prop_is_valid = ast_ari_validate_string(
  1346. ast_json_object_iter_value(iter));
  1347. if (!prop_is_valid) {
  1348. ast_log(LOG_ERROR, "ARI Playback field media_uri failed validation\n");
  1349. res = 0;
  1350. }
  1351. } else
  1352. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  1353. int prop_is_valid;
  1354. has_state = 1;
  1355. prop_is_valid = ast_ari_validate_string(
  1356. ast_json_object_iter_value(iter));
  1357. if (!prop_is_valid) {
  1358. ast_log(LOG_ERROR, "ARI Playback field state failed validation\n");
  1359. res = 0;
  1360. }
  1361. } else
  1362. if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
  1363. int prop_is_valid;
  1364. has_target_uri = 1;
  1365. prop_is_valid = ast_ari_validate_string(
  1366. ast_json_object_iter_value(iter));
  1367. if (!prop_is_valid) {
  1368. ast_log(LOG_ERROR, "ARI Playback field target_uri failed validation\n");
  1369. res = 0;
  1370. }
  1371. } else
  1372. {
  1373. ast_log(LOG_ERROR,
  1374. "ARI Playback has undocumented field %s\n",
  1375. ast_json_object_iter_key(iter));
  1376. res = 0;
  1377. }
  1378. }
  1379. if (!has_id) {
  1380. ast_log(LOG_ERROR, "ARI Playback missing required field id\n");
  1381. res = 0;
  1382. }
  1383. if (!has_media_uri) {
  1384. ast_log(LOG_ERROR, "ARI Playback missing required field media_uri\n");
  1385. res = 0;
  1386. }
  1387. if (!has_state) {
  1388. ast_log(LOG_ERROR, "ARI Playback missing required field state\n");
  1389. res = 0;
  1390. }
  1391. if (!has_target_uri) {
  1392. ast_log(LOG_ERROR, "ARI Playback missing required field target_uri\n");
  1393. res = 0;
  1394. }
  1395. return res;
  1396. }
  1397. ari_validator ast_ari_validate_playback_fn(void)
  1398. {
  1399. return ast_ari_validate_playback;
  1400. }
  1401. int ast_ari_validate_device_state(struct ast_json *json)
  1402. {
  1403. int res = 1;
  1404. struct ast_json_iter *iter;
  1405. int has_name = 0;
  1406. int has_state = 0;
  1407. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1408. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1409. int prop_is_valid;
  1410. has_name = 1;
  1411. prop_is_valid = ast_ari_validate_string(
  1412. ast_json_object_iter_value(iter));
  1413. if (!prop_is_valid) {
  1414. ast_log(LOG_ERROR, "ARI DeviceState field name failed validation\n");
  1415. res = 0;
  1416. }
  1417. } else
  1418. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  1419. int prop_is_valid;
  1420. has_state = 1;
  1421. prop_is_valid = ast_ari_validate_string(
  1422. ast_json_object_iter_value(iter));
  1423. if (!prop_is_valid) {
  1424. ast_log(LOG_ERROR, "ARI DeviceState field state failed validation\n");
  1425. res = 0;
  1426. }
  1427. } else
  1428. {
  1429. ast_log(LOG_ERROR,
  1430. "ARI DeviceState has undocumented field %s\n",
  1431. ast_json_object_iter_key(iter));
  1432. res = 0;
  1433. }
  1434. }
  1435. if (!has_name) {
  1436. ast_log(LOG_ERROR, "ARI DeviceState missing required field name\n");
  1437. res = 0;
  1438. }
  1439. if (!has_state) {
  1440. ast_log(LOG_ERROR, "ARI DeviceState missing required field state\n");
  1441. res = 0;
  1442. }
  1443. return res;
  1444. }
  1445. ari_validator ast_ari_validate_device_state_fn(void)
  1446. {
  1447. return ast_ari_validate_device_state;
  1448. }
  1449. int ast_ari_validate_mailbox(struct ast_json *json)
  1450. {
  1451. int res = 1;
  1452. struct ast_json_iter *iter;
  1453. int has_name = 0;
  1454. int has_new_messages = 0;
  1455. int has_old_messages = 0;
  1456. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1457. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1458. int prop_is_valid;
  1459. has_name = 1;
  1460. prop_is_valid = ast_ari_validate_string(
  1461. ast_json_object_iter_value(iter));
  1462. if (!prop_is_valid) {
  1463. ast_log(LOG_ERROR, "ARI Mailbox field name failed validation\n");
  1464. res = 0;
  1465. }
  1466. } else
  1467. if (strcmp("new_messages", ast_json_object_iter_key(iter)) == 0) {
  1468. int prop_is_valid;
  1469. has_new_messages = 1;
  1470. prop_is_valid = ast_ari_validate_int(
  1471. ast_json_object_iter_value(iter));
  1472. if (!prop_is_valid) {
  1473. ast_log(LOG_ERROR, "ARI Mailbox field new_messages failed validation\n");
  1474. res = 0;
  1475. }
  1476. } else
  1477. if (strcmp("old_messages", ast_json_object_iter_key(iter)) == 0) {
  1478. int prop_is_valid;
  1479. has_old_messages = 1;
  1480. prop_is_valid = ast_ari_validate_int(
  1481. ast_json_object_iter_value(iter));
  1482. if (!prop_is_valid) {
  1483. ast_log(LOG_ERROR, "ARI Mailbox field old_messages failed validation\n");
  1484. res = 0;
  1485. }
  1486. } else
  1487. {
  1488. ast_log(LOG_ERROR,
  1489. "ARI Mailbox has undocumented field %s\n",
  1490. ast_json_object_iter_key(iter));
  1491. res = 0;
  1492. }
  1493. }
  1494. if (!has_name) {
  1495. ast_log(LOG_ERROR, "ARI Mailbox missing required field name\n");
  1496. res = 0;
  1497. }
  1498. if (!has_new_messages) {
  1499. ast_log(LOG_ERROR, "ARI Mailbox missing required field new_messages\n");
  1500. res = 0;
  1501. }
  1502. if (!has_old_messages) {
  1503. ast_log(LOG_ERROR, "ARI Mailbox missing required field old_messages\n");
  1504. res = 0;
  1505. }
  1506. return res;
  1507. }
  1508. ari_validator ast_ari_validate_mailbox_fn(void)
  1509. {
  1510. return ast_ari_validate_mailbox;
  1511. }
  1512. int ast_ari_validate_application_replaced(struct ast_json *json)
  1513. {
  1514. int res = 1;
  1515. struct ast_json_iter *iter;
  1516. int has_type = 0;
  1517. int has_application = 0;
  1518. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1519. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  1520. int prop_is_valid;
  1521. has_type = 1;
  1522. prop_is_valid = ast_ari_validate_string(
  1523. ast_json_object_iter_value(iter));
  1524. if (!prop_is_valid) {
  1525. ast_log(LOG_ERROR, "ARI ApplicationReplaced field type failed validation\n");
  1526. res = 0;
  1527. }
  1528. } else
  1529. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  1530. int prop_is_valid;
  1531. has_application = 1;
  1532. prop_is_valid = ast_ari_validate_string(
  1533. ast_json_object_iter_value(iter));
  1534. if (!prop_is_valid) {
  1535. ast_log(LOG_ERROR, "ARI ApplicationReplaced field application failed validation\n");
  1536. res = 0;
  1537. }
  1538. } else
  1539. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  1540. int prop_is_valid;
  1541. prop_is_valid = ast_ari_validate_date(
  1542. ast_json_object_iter_value(iter));
  1543. if (!prop_is_valid) {
  1544. ast_log(LOG_ERROR, "ARI ApplicationReplaced field timestamp failed validation\n");
  1545. res = 0;
  1546. }
  1547. } else
  1548. {
  1549. ast_log(LOG_ERROR,
  1550. "ARI ApplicationReplaced has undocumented field %s\n",
  1551. ast_json_object_iter_key(iter));
  1552. res = 0;
  1553. }
  1554. }
  1555. if (!has_type) {
  1556. ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field type\n");
  1557. res = 0;
  1558. }
  1559. if (!has_application) {
  1560. ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field application\n");
  1561. res = 0;
  1562. }
  1563. return res;
  1564. }
  1565. ari_validator ast_ari_validate_application_replaced_fn(void)
  1566. {
  1567. return ast_ari_validate_application_replaced;
  1568. }
  1569. int ast_ari_validate_bridge_attended_transfer(struct ast_json *json)
  1570. {
  1571. int res = 1;
  1572. struct ast_json_iter *iter;
  1573. int has_type = 0;
  1574. int has_application = 0;
  1575. int has_destination_type = 0;
  1576. int has_is_external = 0;
  1577. int has_result = 0;
  1578. int has_transferer_first_leg = 0;
  1579. int has_transferer_second_leg = 0;
  1580. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1581. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  1582. int prop_is_valid;
  1583. has_type = 1;
  1584. prop_is_valid = ast_ari_validate_string(
  1585. ast_json_object_iter_value(iter));
  1586. if (!prop_is_valid) {
  1587. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field type failed validation\n");
  1588. res = 0;
  1589. }
  1590. } else
  1591. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  1592. int prop_is_valid;
  1593. has_application = 1;
  1594. prop_is_valid = ast_ari_validate_string(
  1595. ast_json_object_iter_value(iter));
  1596. if (!prop_is_valid) {
  1597. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field application failed validation\n");
  1598. res = 0;
  1599. }
  1600. } else
  1601. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  1602. int prop_is_valid;
  1603. prop_is_valid = ast_ari_validate_date(
  1604. ast_json_object_iter_value(iter));
  1605. if (!prop_is_valid) {
  1606. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field timestamp failed validation\n");
  1607. res = 0;
  1608. }
  1609. } else
  1610. if (strcmp("destination_application", ast_json_object_iter_key(iter)) == 0) {
  1611. int prop_is_valid;
  1612. prop_is_valid = ast_ari_validate_string(
  1613. ast_json_object_iter_value(iter));
  1614. if (!prop_is_valid) {
  1615. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_application failed validation\n");
  1616. res = 0;
  1617. }
  1618. } else
  1619. if (strcmp("destination_bridge", ast_json_object_iter_key(iter)) == 0) {
  1620. int prop_is_valid;
  1621. prop_is_valid = ast_ari_validate_string(
  1622. ast_json_object_iter_value(iter));
  1623. if (!prop_is_valid) {
  1624. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_bridge failed validation\n");
  1625. res = 0;
  1626. }
  1627. } else
  1628. if (strcmp("destination_link_first_leg", ast_json_object_iter_key(iter)) == 0) {
  1629. int prop_is_valid;
  1630. prop_is_valid = ast_ari_validate_channel(
  1631. ast_json_object_iter_value(iter));
  1632. if (!prop_is_valid) {
  1633. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_first_leg failed validation\n");
  1634. res = 0;
  1635. }
  1636. } else
  1637. if (strcmp("destination_link_second_leg", ast_json_object_iter_key(iter)) == 0) {
  1638. int prop_is_valid;
  1639. prop_is_valid = ast_ari_validate_channel(
  1640. ast_json_object_iter_value(iter));
  1641. if (!prop_is_valid) {
  1642. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_second_leg failed validation\n");
  1643. res = 0;
  1644. }
  1645. } else
  1646. if (strcmp("destination_threeway_bridge", ast_json_object_iter_key(iter)) == 0) {
  1647. int prop_is_valid;
  1648. prop_is_valid = ast_ari_validate_bridge(
  1649. ast_json_object_iter_value(iter));
  1650. if (!prop_is_valid) {
  1651. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_bridge failed validation\n");
  1652. res = 0;
  1653. }
  1654. } else
  1655. if (strcmp("destination_threeway_channel", ast_json_object_iter_key(iter)) == 0) {
  1656. int prop_is_valid;
  1657. prop_is_valid = ast_ari_validate_channel(
  1658. ast_json_object_iter_value(iter));
  1659. if (!prop_is_valid) {
  1660. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_channel failed validation\n");
  1661. res = 0;
  1662. }
  1663. } else
  1664. if (strcmp("destination_type", ast_json_object_iter_key(iter)) == 0) {
  1665. int prop_is_valid;
  1666. has_destination_type = 1;
  1667. prop_is_valid = ast_ari_validate_string(
  1668. ast_json_object_iter_value(iter));
  1669. if (!prop_is_valid) {
  1670. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_type failed validation\n");
  1671. res = 0;
  1672. }
  1673. } else
  1674. if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
  1675. int prop_is_valid;
  1676. has_is_external = 1;
  1677. prop_is_valid = ast_ari_validate_boolean(
  1678. ast_json_object_iter_value(iter));
  1679. if (!prop_is_valid) {
  1680. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field is_external failed validation\n");
  1681. res = 0;
  1682. }
  1683. } else
  1684. if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
  1685. int prop_is_valid;
  1686. prop_is_valid = ast_ari_validate_channel(
  1687. ast_json_object_iter_value(iter));
  1688. if (!prop_is_valid) {
  1689. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field replace_channel failed validation\n");
  1690. res = 0;
  1691. }
  1692. } else
  1693. if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
  1694. int prop_is_valid;
  1695. has_result = 1;
  1696. prop_is_valid = ast_ari_validate_string(
  1697. ast_json_object_iter_value(iter));
  1698. if (!prop_is_valid) {
  1699. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field result failed validation\n");
  1700. res = 0;
  1701. }
  1702. } else
  1703. if (strcmp("transfer_target", ast_json_object_iter_key(iter)) == 0) {
  1704. int prop_is_valid;
  1705. prop_is_valid = ast_ari_validate_channel(
  1706. ast_json_object_iter_value(iter));
  1707. if (!prop_is_valid) {
  1708. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transfer_target failed validation\n");
  1709. res = 0;
  1710. }
  1711. } else
  1712. if (strcmp("transferee", ast_json_object_iter_key(iter)) == 0) {
  1713. int prop_is_valid;
  1714. prop_is_valid = ast_ari_validate_channel(
  1715. ast_json_object_iter_value(iter));
  1716. if (!prop_is_valid) {
  1717. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferee failed validation\n");
  1718. res = 0;
  1719. }
  1720. } else
  1721. if (strcmp("transferer_first_leg", ast_json_object_iter_key(iter)) == 0) {
  1722. int prop_is_valid;
  1723. has_transferer_first_leg = 1;
  1724. prop_is_valid = ast_ari_validate_channel(
  1725. ast_json_object_iter_value(iter));
  1726. if (!prop_is_valid) {
  1727. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_first_leg failed validation\n");
  1728. res = 0;
  1729. }
  1730. } else
  1731. if (strcmp("transferer_first_leg_bridge", ast_json_object_iter_key(iter)) == 0) {
  1732. int prop_is_valid;
  1733. prop_is_valid = ast_ari_validate_bridge(
  1734. ast_json_object_iter_value(iter));
  1735. if (!prop_is_valid) {
  1736. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_first_leg_bridge failed validation\n");
  1737. res = 0;
  1738. }
  1739. } else
  1740. if (strcmp("transferer_second_leg", ast_json_object_iter_key(iter)) == 0) {
  1741. int prop_is_valid;
  1742. has_transferer_second_leg = 1;
  1743. prop_is_valid = ast_ari_validate_channel(
  1744. ast_json_object_iter_value(iter));
  1745. if (!prop_is_valid) {
  1746. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_second_leg failed validation\n");
  1747. res = 0;
  1748. }
  1749. } else
  1750. if (strcmp("transferer_second_leg_bridge", ast_json_object_iter_key(iter)) == 0) {
  1751. int prop_is_valid;
  1752. prop_is_valid = ast_ari_validate_bridge(
  1753. ast_json_object_iter_value(iter));
  1754. if (!prop_is_valid) {
  1755. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_second_leg_bridge failed validation\n");
  1756. res = 0;
  1757. }
  1758. } else
  1759. {
  1760. ast_log(LOG_ERROR,
  1761. "ARI BridgeAttendedTransfer has undocumented field %s\n",
  1762. ast_json_object_iter_key(iter));
  1763. res = 0;
  1764. }
  1765. }
  1766. if (!has_type) {
  1767. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field type\n");
  1768. res = 0;
  1769. }
  1770. if (!has_application) {
  1771. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field application\n");
  1772. res = 0;
  1773. }
  1774. if (!has_destination_type) {
  1775. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field destination_type\n");
  1776. res = 0;
  1777. }
  1778. if (!has_is_external) {
  1779. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field is_external\n");
  1780. res = 0;
  1781. }
  1782. if (!has_result) {
  1783. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field result\n");
  1784. res = 0;
  1785. }
  1786. if (!has_transferer_first_leg) {
  1787. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field transferer_first_leg\n");
  1788. res = 0;
  1789. }
  1790. if (!has_transferer_second_leg) {
  1791. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field transferer_second_leg\n");
  1792. res = 0;
  1793. }
  1794. return res;
  1795. }
  1796. ari_validator ast_ari_validate_bridge_attended_transfer_fn(void)
  1797. {
  1798. return ast_ari_validate_bridge_attended_transfer;
  1799. }
  1800. int ast_ari_validate_bridge_blind_transfer(struct ast_json *json)
  1801. {
  1802. int res = 1;
  1803. struct ast_json_iter *iter;
  1804. int has_type = 0;
  1805. int has_application = 0;
  1806. int has_channel = 0;
  1807. int has_context = 0;
  1808. int has_exten = 0;
  1809. int has_is_external = 0;
  1810. int has_result = 0;
  1811. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1812. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  1813. int prop_is_valid;
  1814. has_type = 1;
  1815. prop_is_valid = ast_ari_validate_string(
  1816. ast_json_object_iter_value(iter));
  1817. if (!prop_is_valid) {
  1818. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field type failed validation\n");
  1819. res = 0;
  1820. }
  1821. } else
  1822. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  1823. int prop_is_valid;
  1824. has_application = 1;
  1825. prop_is_valid = ast_ari_validate_string(
  1826. ast_json_object_iter_value(iter));
  1827. if (!prop_is_valid) {
  1828. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field application failed validation\n");
  1829. res = 0;
  1830. }
  1831. } else
  1832. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  1833. int prop_is_valid;
  1834. prop_is_valid = ast_ari_validate_date(
  1835. ast_json_object_iter_value(iter));
  1836. if (!prop_is_valid) {
  1837. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field timestamp failed validation\n");
  1838. res = 0;
  1839. }
  1840. } else
  1841. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  1842. int prop_is_valid;
  1843. prop_is_valid = ast_ari_validate_bridge(
  1844. ast_json_object_iter_value(iter));
  1845. if (!prop_is_valid) {
  1846. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field bridge failed validation\n");
  1847. res = 0;
  1848. }
  1849. } else
  1850. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  1851. int prop_is_valid;
  1852. has_channel = 1;
  1853. prop_is_valid = ast_ari_validate_channel(
  1854. ast_json_object_iter_value(iter));
  1855. if (!prop_is_valid) {
  1856. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field channel failed validation\n");
  1857. res = 0;
  1858. }
  1859. } else
  1860. if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
  1861. int prop_is_valid;
  1862. has_context = 1;
  1863. prop_is_valid = ast_ari_validate_string(
  1864. ast_json_object_iter_value(iter));
  1865. if (!prop_is_valid) {
  1866. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field context failed validation\n");
  1867. res = 0;
  1868. }
  1869. } else
  1870. if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
  1871. int prop_is_valid;
  1872. has_exten = 1;
  1873. prop_is_valid = ast_ari_validate_string(
  1874. ast_json_object_iter_value(iter));
  1875. if (!prop_is_valid) {
  1876. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field exten failed validation\n");
  1877. res = 0;
  1878. }
  1879. } else
  1880. if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
  1881. int prop_is_valid;
  1882. has_is_external = 1;
  1883. prop_is_valid = ast_ari_validate_boolean(
  1884. ast_json_object_iter_value(iter));
  1885. if (!prop_is_valid) {
  1886. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field is_external failed validation\n");
  1887. res = 0;
  1888. }
  1889. } else
  1890. if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
  1891. int prop_is_valid;
  1892. prop_is_valid = ast_ari_validate_channel(
  1893. ast_json_object_iter_value(iter));
  1894. if (!prop_is_valid) {
  1895. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field replace_channel failed validation\n");
  1896. res = 0;
  1897. }
  1898. } else
  1899. if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
  1900. int prop_is_valid;
  1901. has_result = 1;
  1902. prop_is_valid = ast_ari_validate_string(
  1903. ast_json_object_iter_value(iter));
  1904. if (!prop_is_valid) {
  1905. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field result failed validation\n");
  1906. res = 0;
  1907. }
  1908. } else
  1909. if (strcmp("transferee", ast_json_object_iter_key(iter)) == 0) {
  1910. int prop_is_valid;
  1911. prop_is_valid = ast_ari_validate_channel(
  1912. ast_json_object_iter_value(iter));
  1913. if (!prop_is_valid) {
  1914. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field transferee failed validation\n");
  1915. res = 0;
  1916. }
  1917. } else
  1918. {
  1919. ast_log(LOG_ERROR,
  1920. "ARI BridgeBlindTransfer has undocumented field %s\n",
  1921. ast_json_object_iter_key(iter));
  1922. res = 0;
  1923. }
  1924. }
  1925. if (!has_type) {
  1926. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field type\n");
  1927. res = 0;
  1928. }
  1929. if (!has_application) {
  1930. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field application\n");
  1931. res = 0;
  1932. }
  1933. if (!has_channel) {
  1934. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field channel\n");
  1935. res = 0;
  1936. }
  1937. if (!has_context) {
  1938. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field context\n");
  1939. res = 0;
  1940. }
  1941. if (!has_exten) {
  1942. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field exten\n");
  1943. res = 0;
  1944. }
  1945. if (!has_is_external) {
  1946. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field is_external\n");
  1947. res = 0;
  1948. }
  1949. if (!has_result) {
  1950. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field result\n");
  1951. res = 0;
  1952. }
  1953. return res;
  1954. }
  1955. ari_validator ast_ari_validate_bridge_blind_transfer_fn(void)
  1956. {
  1957. return ast_ari_validate_bridge_blind_transfer;
  1958. }
  1959. int ast_ari_validate_bridge_created(struct ast_json *json)
  1960. {
  1961. int res = 1;
  1962. struct ast_json_iter *iter;
  1963. int has_type = 0;
  1964. int has_application = 0;
  1965. int has_bridge = 0;
  1966. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1967. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  1968. int prop_is_valid;
  1969. has_type = 1;
  1970. prop_is_valid = ast_ari_validate_string(
  1971. ast_json_object_iter_value(iter));
  1972. if (!prop_is_valid) {
  1973. ast_log(LOG_ERROR, "ARI BridgeCreated field type failed validation\n");
  1974. res = 0;
  1975. }
  1976. } else
  1977. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  1978. int prop_is_valid;
  1979. has_application = 1;
  1980. prop_is_valid = ast_ari_validate_string(
  1981. ast_json_object_iter_value(iter));
  1982. if (!prop_is_valid) {
  1983. ast_log(LOG_ERROR, "ARI BridgeCreated field application failed validation\n");
  1984. res = 0;
  1985. }
  1986. } else
  1987. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  1988. int prop_is_valid;
  1989. prop_is_valid = ast_ari_validate_date(
  1990. ast_json_object_iter_value(iter));
  1991. if (!prop_is_valid) {
  1992. ast_log(LOG_ERROR, "ARI BridgeCreated field timestamp failed validation\n");
  1993. res = 0;
  1994. }
  1995. } else
  1996. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  1997. int prop_is_valid;
  1998. has_bridge = 1;
  1999. prop_is_valid = ast_ari_validate_bridge(
  2000. ast_json_object_iter_value(iter));
  2001. if (!prop_is_valid) {
  2002. ast_log(LOG_ERROR, "ARI BridgeCreated field bridge failed validation\n");
  2003. res = 0;
  2004. }
  2005. } else
  2006. {
  2007. ast_log(LOG_ERROR,
  2008. "ARI BridgeCreated has undocumented field %s\n",
  2009. ast_json_object_iter_key(iter));
  2010. res = 0;
  2011. }
  2012. }
  2013. if (!has_type) {
  2014. ast_log(LOG_ERROR, "ARI BridgeCreated missing required field type\n");
  2015. res = 0;
  2016. }
  2017. if (!has_application) {
  2018. ast_log(LOG_ERROR, "ARI BridgeCreated missing required field application\n");
  2019. res = 0;
  2020. }
  2021. if (!has_bridge) {
  2022. ast_log(LOG_ERROR, "ARI BridgeCreated missing required field bridge\n");
  2023. res = 0;
  2024. }
  2025. return res;
  2026. }
  2027. ari_validator ast_ari_validate_bridge_created_fn(void)
  2028. {
  2029. return ast_ari_validate_bridge_created;
  2030. }
  2031. int ast_ari_validate_bridge_destroyed(struct ast_json *json)
  2032. {
  2033. int res = 1;
  2034. struct ast_json_iter *iter;
  2035. int has_type = 0;
  2036. int has_application = 0;
  2037. int has_bridge = 0;
  2038. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2039. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2040. int prop_is_valid;
  2041. has_type = 1;
  2042. prop_is_valid = ast_ari_validate_string(
  2043. ast_json_object_iter_value(iter));
  2044. if (!prop_is_valid) {
  2045. ast_log(LOG_ERROR, "ARI BridgeDestroyed field type failed validation\n");
  2046. res = 0;
  2047. }
  2048. } else
  2049. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2050. int prop_is_valid;
  2051. has_application = 1;
  2052. prop_is_valid = ast_ari_validate_string(
  2053. ast_json_object_iter_value(iter));
  2054. if (!prop_is_valid) {
  2055. ast_log(LOG_ERROR, "ARI BridgeDestroyed field application failed validation\n");
  2056. res = 0;
  2057. }
  2058. } else
  2059. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2060. int prop_is_valid;
  2061. prop_is_valid = ast_ari_validate_date(
  2062. ast_json_object_iter_value(iter));
  2063. if (!prop_is_valid) {
  2064. ast_log(LOG_ERROR, "ARI BridgeDestroyed field timestamp failed validation\n");
  2065. res = 0;
  2066. }
  2067. } else
  2068. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2069. int prop_is_valid;
  2070. has_bridge = 1;
  2071. prop_is_valid = ast_ari_validate_bridge(
  2072. ast_json_object_iter_value(iter));
  2073. if (!prop_is_valid) {
  2074. ast_log(LOG_ERROR, "ARI BridgeDestroyed field bridge failed validation\n");
  2075. res = 0;
  2076. }
  2077. } else
  2078. {
  2079. ast_log(LOG_ERROR,
  2080. "ARI BridgeDestroyed has undocumented field %s\n",
  2081. ast_json_object_iter_key(iter));
  2082. res = 0;
  2083. }
  2084. }
  2085. if (!has_type) {
  2086. ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field type\n");
  2087. res = 0;
  2088. }
  2089. if (!has_application) {
  2090. ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field application\n");
  2091. res = 0;
  2092. }
  2093. if (!has_bridge) {
  2094. ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field bridge\n");
  2095. res = 0;
  2096. }
  2097. return res;
  2098. }
  2099. ari_validator ast_ari_validate_bridge_destroyed_fn(void)
  2100. {
  2101. return ast_ari_validate_bridge_destroyed;
  2102. }
  2103. int ast_ari_validate_bridge_merged(struct ast_json *json)
  2104. {
  2105. int res = 1;
  2106. struct ast_json_iter *iter;
  2107. int has_type = 0;
  2108. int has_application = 0;
  2109. int has_bridge = 0;
  2110. int has_bridge_from = 0;
  2111. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2112. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2113. int prop_is_valid;
  2114. has_type = 1;
  2115. prop_is_valid = ast_ari_validate_string(
  2116. ast_json_object_iter_value(iter));
  2117. if (!prop_is_valid) {
  2118. ast_log(LOG_ERROR, "ARI BridgeMerged field type failed validation\n");
  2119. res = 0;
  2120. }
  2121. } else
  2122. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2123. int prop_is_valid;
  2124. has_application = 1;
  2125. prop_is_valid = ast_ari_validate_string(
  2126. ast_json_object_iter_value(iter));
  2127. if (!prop_is_valid) {
  2128. ast_log(LOG_ERROR, "ARI BridgeMerged field application failed validation\n");
  2129. res = 0;
  2130. }
  2131. } else
  2132. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2133. int prop_is_valid;
  2134. prop_is_valid = ast_ari_validate_date(
  2135. ast_json_object_iter_value(iter));
  2136. if (!prop_is_valid) {
  2137. ast_log(LOG_ERROR, "ARI BridgeMerged field timestamp failed validation\n");
  2138. res = 0;
  2139. }
  2140. } else
  2141. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2142. int prop_is_valid;
  2143. has_bridge = 1;
  2144. prop_is_valid = ast_ari_validate_bridge(
  2145. ast_json_object_iter_value(iter));
  2146. if (!prop_is_valid) {
  2147. ast_log(LOG_ERROR, "ARI BridgeMerged field bridge failed validation\n");
  2148. res = 0;
  2149. }
  2150. } else
  2151. if (strcmp("bridge_from", ast_json_object_iter_key(iter)) == 0) {
  2152. int prop_is_valid;
  2153. has_bridge_from = 1;
  2154. prop_is_valid = ast_ari_validate_bridge(
  2155. ast_json_object_iter_value(iter));
  2156. if (!prop_is_valid) {
  2157. ast_log(LOG_ERROR, "ARI BridgeMerged field bridge_from failed validation\n");
  2158. res = 0;
  2159. }
  2160. } else
  2161. {
  2162. ast_log(LOG_ERROR,
  2163. "ARI BridgeMerged has undocumented field %s\n",
  2164. ast_json_object_iter_key(iter));
  2165. res = 0;
  2166. }
  2167. }
  2168. if (!has_type) {
  2169. ast_log(LOG_ERROR, "ARI BridgeMerged missing required field type\n");
  2170. res = 0;
  2171. }
  2172. if (!has_application) {
  2173. ast_log(LOG_ERROR, "ARI BridgeMerged missing required field application\n");
  2174. res = 0;
  2175. }
  2176. if (!has_bridge) {
  2177. ast_log(LOG_ERROR, "ARI BridgeMerged missing required field bridge\n");
  2178. res = 0;
  2179. }
  2180. if (!has_bridge_from) {
  2181. ast_log(LOG_ERROR, "ARI BridgeMerged missing required field bridge_from\n");
  2182. res = 0;
  2183. }
  2184. return res;
  2185. }
  2186. ari_validator ast_ari_validate_bridge_merged_fn(void)
  2187. {
  2188. return ast_ari_validate_bridge_merged;
  2189. }
  2190. int ast_ari_validate_channel_caller_id(struct ast_json *json)
  2191. {
  2192. int res = 1;
  2193. struct ast_json_iter *iter;
  2194. int has_type = 0;
  2195. int has_application = 0;
  2196. int has_caller_presentation = 0;
  2197. int has_caller_presentation_txt = 0;
  2198. int has_channel = 0;
  2199. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2200. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2201. int prop_is_valid;
  2202. has_type = 1;
  2203. prop_is_valid = ast_ari_validate_string(
  2204. ast_json_object_iter_value(iter));
  2205. if (!prop_is_valid) {
  2206. ast_log(LOG_ERROR, "ARI ChannelCallerId field type failed validation\n");
  2207. res = 0;
  2208. }
  2209. } else
  2210. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2211. int prop_is_valid;
  2212. has_application = 1;
  2213. prop_is_valid = ast_ari_validate_string(
  2214. ast_json_object_iter_value(iter));
  2215. if (!prop_is_valid) {
  2216. ast_log(LOG_ERROR, "ARI ChannelCallerId field application failed validation\n");
  2217. res = 0;
  2218. }
  2219. } else
  2220. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2221. int prop_is_valid;
  2222. prop_is_valid = ast_ari_validate_date(
  2223. ast_json_object_iter_value(iter));
  2224. if (!prop_is_valid) {
  2225. ast_log(LOG_ERROR, "ARI ChannelCallerId field timestamp failed validation\n");
  2226. res = 0;
  2227. }
  2228. } else
  2229. if (strcmp("caller_presentation", ast_json_object_iter_key(iter)) == 0) {
  2230. int prop_is_valid;
  2231. has_caller_presentation = 1;
  2232. prop_is_valid = ast_ari_validate_int(
  2233. ast_json_object_iter_value(iter));
  2234. if (!prop_is_valid) {
  2235. ast_log(LOG_ERROR, "ARI ChannelCallerId field caller_presentation failed validation\n");
  2236. res = 0;
  2237. }
  2238. } else
  2239. if (strcmp("caller_presentation_txt", ast_json_object_iter_key(iter)) == 0) {
  2240. int prop_is_valid;
  2241. has_caller_presentation_txt = 1;
  2242. prop_is_valid = ast_ari_validate_string(
  2243. ast_json_object_iter_value(iter));
  2244. if (!prop_is_valid) {
  2245. ast_log(LOG_ERROR, "ARI ChannelCallerId field caller_presentation_txt failed validation\n");
  2246. res = 0;
  2247. }
  2248. } else
  2249. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2250. int prop_is_valid;
  2251. has_channel = 1;
  2252. prop_is_valid = ast_ari_validate_channel(
  2253. ast_json_object_iter_value(iter));
  2254. if (!prop_is_valid) {
  2255. ast_log(LOG_ERROR, "ARI ChannelCallerId field channel failed validation\n");
  2256. res = 0;
  2257. }
  2258. } else
  2259. {
  2260. ast_log(LOG_ERROR,
  2261. "ARI ChannelCallerId has undocumented field %s\n",
  2262. ast_json_object_iter_key(iter));
  2263. res = 0;
  2264. }
  2265. }
  2266. if (!has_type) {
  2267. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field type\n");
  2268. res = 0;
  2269. }
  2270. if (!has_application) {
  2271. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field application\n");
  2272. res = 0;
  2273. }
  2274. if (!has_caller_presentation) {
  2275. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field caller_presentation\n");
  2276. res = 0;
  2277. }
  2278. if (!has_caller_presentation_txt) {
  2279. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field caller_presentation_txt\n");
  2280. res = 0;
  2281. }
  2282. if (!has_channel) {
  2283. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field channel\n");
  2284. res = 0;
  2285. }
  2286. return res;
  2287. }
  2288. ari_validator ast_ari_validate_channel_caller_id_fn(void)
  2289. {
  2290. return ast_ari_validate_channel_caller_id;
  2291. }
  2292. int ast_ari_validate_channel_created(struct ast_json *json)
  2293. {
  2294. int res = 1;
  2295. struct ast_json_iter *iter;
  2296. int has_type = 0;
  2297. int has_application = 0;
  2298. int has_channel = 0;
  2299. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2300. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2301. int prop_is_valid;
  2302. has_type = 1;
  2303. prop_is_valid = ast_ari_validate_string(
  2304. ast_json_object_iter_value(iter));
  2305. if (!prop_is_valid) {
  2306. ast_log(LOG_ERROR, "ARI ChannelCreated field type failed validation\n");
  2307. res = 0;
  2308. }
  2309. } else
  2310. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2311. int prop_is_valid;
  2312. has_application = 1;
  2313. prop_is_valid = ast_ari_validate_string(
  2314. ast_json_object_iter_value(iter));
  2315. if (!prop_is_valid) {
  2316. ast_log(LOG_ERROR, "ARI ChannelCreated field application failed validation\n");
  2317. res = 0;
  2318. }
  2319. } else
  2320. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2321. int prop_is_valid;
  2322. prop_is_valid = ast_ari_validate_date(
  2323. ast_json_object_iter_value(iter));
  2324. if (!prop_is_valid) {
  2325. ast_log(LOG_ERROR, "ARI ChannelCreated field timestamp failed validation\n");
  2326. res = 0;
  2327. }
  2328. } else
  2329. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2330. int prop_is_valid;
  2331. has_channel = 1;
  2332. prop_is_valid = ast_ari_validate_channel(
  2333. ast_json_object_iter_value(iter));
  2334. if (!prop_is_valid) {
  2335. ast_log(LOG_ERROR, "ARI ChannelCreated field channel failed validation\n");
  2336. res = 0;
  2337. }
  2338. } else
  2339. {
  2340. ast_log(LOG_ERROR,
  2341. "ARI ChannelCreated has undocumented field %s\n",
  2342. ast_json_object_iter_key(iter));
  2343. res = 0;
  2344. }
  2345. }
  2346. if (!has_type) {
  2347. ast_log(LOG_ERROR, "ARI ChannelCreated missing required field type\n");
  2348. res = 0;
  2349. }
  2350. if (!has_application) {
  2351. ast_log(LOG_ERROR, "ARI ChannelCreated missing required field application\n");
  2352. res = 0;
  2353. }
  2354. if (!has_channel) {
  2355. ast_log(LOG_ERROR, "ARI ChannelCreated missing required field channel\n");
  2356. res = 0;
  2357. }
  2358. return res;
  2359. }
  2360. ari_validator ast_ari_validate_channel_created_fn(void)
  2361. {
  2362. return ast_ari_validate_channel_created;
  2363. }
  2364. int ast_ari_validate_channel_destroyed(struct ast_json *json)
  2365. {
  2366. int res = 1;
  2367. struct ast_json_iter *iter;
  2368. int has_type = 0;
  2369. int has_application = 0;
  2370. int has_cause = 0;
  2371. int has_cause_txt = 0;
  2372. int has_channel = 0;
  2373. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2374. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2375. int prop_is_valid;
  2376. has_type = 1;
  2377. prop_is_valid = ast_ari_validate_string(
  2378. ast_json_object_iter_value(iter));
  2379. if (!prop_is_valid) {
  2380. ast_log(LOG_ERROR, "ARI ChannelDestroyed field type failed validation\n");
  2381. res = 0;
  2382. }
  2383. } else
  2384. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2385. int prop_is_valid;
  2386. has_application = 1;
  2387. prop_is_valid = ast_ari_validate_string(
  2388. ast_json_object_iter_value(iter));
  2389. if (!prop_is_valid) {
  2390. ast_log(LOG_ERROR, "ARI ChannelDestroyed field application failed validation\n");
  2391. res = 0;
  2392. }
  2393. } else
  2394. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2395. int prop_is_valid;
  2396. prop_is_valid = ast_ari_validate_date(
  2397. ast_json_object_iter_value(iter));
  2398. if (!prop_is_valid) {
  2399. ast_log(LOG_ERROR, "ARI ChannelDestroyed field timestamp failed validation\n");
  2400. res = 0;
  2401. }
  2402. } else
  2403. if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
  2404. int prop_is_valid;
  2405. has_cause = 1;
  2406. prop_is_valid = ast_ari_validate_int(
  2407. ast_json_object_iter_value(iter));
  2408. if (!prop_is_valid) {
  2409. ast_log(LOG_ERROR, "ARI ChannelDestroyed field cause failed validation\n");
  2410. res = 0;
  2411. }
  2412. } else
  2413. if (strcmp("cause_txt", ast_json_object_iter_key(iter)) == 0) {
  2414. int prop_is_valid;
  2415. has_cause_txt = 1;
  2416. prop_is_valid = ast_ari_validate_string(
  2417. ast_json_object_iter_value(iter));
  2418. if (!prop_is_valid) {
  2419. ast_log(LOG_ERROR, "ARI ChannelDestroyed field cause_txt failed validation\n");
  2420. res = 0;
  2421. }
  2422. } else
  2423. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2424. int prop_is_valid;
  2425. has_channel = 1;
  2426. prop_is_valid = ast_ari_validate_channel(
  2427. ast_json_object_iter_value(iter));
  2428. if (!prop_is_valid) {
  2429. ast_log(LOG_ERROR, "ARI ChannelDestroyed field channel failed validation\n");
  2430. res = 0;
  2431. }
  2432. } else
  2433. {
  2434. ast_log(LOG_ERROR,
  2435. "ARI ChannelDestroyed has undocumented field %s\n",
  2436. ast_json_object_iter_key(iter));
  2437. res = 0;
  2438. }
  2439. }
  2440. if (!has_type) {
  2441. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field type\n");
  2442. res = 0;
  2443. }
  2444. if (!has_application) {
  2445. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field application\n");
  2446. res = 0;
  2447. }
  2448. if (!has_cause) {
  2449. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field cause\n");
  2450. res = 0;
  2451. }
  2452. if (!has_cause_txt) {
  2453. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field cause_txt\n");
  2454. res = 0;
  2455. }
  2456. if (!has_channel) {
  2457. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field channel\n");
  2458. res = 0;
  2459. }
  2460. return res;
  2461. }
  2462. ari_validator ast_ari_validate_channel_destroyed_fn(void)
  2463. {
  2464. return ast_ari_validate_channel_destroyed;
  2465. }
  2466. int ast_ari_validate_channel_dialplan(struct ast_json *json)
  2467. {
  2468. int res = 1;
  2469. struct ast_json_iter *iter;
  2470. int has_type = 0;
  2471. int has_application = 0;
  2472. int has_channel = 0;
  2473. int has_dialplan_app = 0;
  2474. int has_dialplan_app_data = 0;
  2475. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2476. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2477. int prop_is_valid;
  2478. has_type = 1;
  2479. prop_is_valid = ast_ari_validate_string(
  2480. ast_json_object_iter_value(iter));
  2481. if (!prop_is_valid) {
  2482. ast_log(LOG_ERROR, "ARI ChannelDialplan field type failed validation\n");
  2483. res = 0;
  2484. }
  2485. } else
  2486. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2487. int prop_is_valid;
  2488. has_application = 1;
  2489. prop_is_valid = ast_ari_validate_string(
  2490. ast_json_object_iter_value(iter));
  2491. if (!prop_is_valid) {
  2492. ast_log(LOG_ERROR, "ARI ChannelDialplan field application failed validation\n");
  2493. res = 0;
  2494. }
  2495. } else
  2496. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2497. int prop_is_valid;
  2498. prop_is_valid = ast_ari_validate_date(
  2499. ast_json_object_iter_value(iter));
  2500. if (!prop_is_valid) {
  2501. ast_log(LOG_ERROR, "ARI ChannelDialplan field timestamp failed validation\n");
  2502. res = 0;
  2503. }
  2504. } else
  2505. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2506. int prop_is_valid;
  2507. has_channel = 1;
  2508. prop_is_valid = ast_ari_validate_channel(
  2509. ast_json_object_iter_value(iter));
  2510. if (!prop_is_valid) {
  2511. ast_log(LOG_ERROR, "ARI ChannelDialplan field channel failed validation\n");
  2512. res = 0;
  2513. }
  2514. } else
  2515. if (strcmp("dialplan_app", ast_json_object_iter_key(iter)) == 0) {
  2516. int prop_is_valid;
  2517. has_dialplan_app = 1;
  2518. prop_is_valid = ast_ari_validate_string(
  2519. ast_json_object_iter_value(iter));
  2520. if (!prop_is_valid) {
  2521. ast_log(LOG_ERROR, "ARI ChannelDialplan field dialplan_app failed validation\n");
  2522. res = 0;
  2523. }
  2524. } else
  2525. if (strcmp("dialplan_app_data", ast_json_object_iter_key(iter)) == 0) {
  2526. int prop_is_valid;
  2527. has_dialplan_app_data = 1;
  2528. prop_is_valid = ast_ari_validate_string(
  2529. ast_json_object_iter_value(iter));
  2530. if (!prop_is_valid) {
  2531. ast_log(LOG_ERROR, "ARI ChannelDialplan field dialplan_app_data failed validation\n");
  2532. res = 0;
  2533. }
  2534. } else
  2535. {
  2536. ast_log(LOG_ERROR,
  2537. "ARI ChannelDialplan has undocumented field %s\n",
  2538. ast_json_object_iter_key(iter));
  2539. res = 0;
  2540. }
  2541. }
  2542. if (!has_type) {
  2543. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field type\n");
  2544. res = 0;
  2545. }
  2546. if (!has_application) {
  2547. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field application\n");
  2548. res = 0;
  2549. }
  2550. if (!has_channel) {
  2551. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field channel\n");
  2552. res = 0;
  2553. }
  2554. if (!has_dialplan_app) {
  2555. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field dialplan_app\n");
  2556. res = 0;
  2557. }
  2558. if (!has_dialplan_app_data) {
  2559. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field dialplan_app_data\n");
  2560. res = 0;
  2561. }
  2562. return res;
  2563. }
  2564. ari_validator ast_ari_validate_channel_dialplan_fn(void)
  2565. {
  2566. return ast_ari_validate_channel_dialplan;
  2567. }
  2568. int ast_ari_validate_channel_dtmf_received(struct ast_json *json)
  2569. {
  2570. int res = 1;
  2571. struct ast_json_iter *iter;
  2572. int has_type = 0;
  2573. int has_application = 0;
  2574. int has_channel = 0;
  2575. int has_digit = 0;
  2576. int has_duration_ms = 0;
  2577. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2578. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2579. int prop_is_valid;
  2580. has_type = 1;
  2581. prop_is_valid = ast_ari_validate_string(
  2582. ast_json_object_iter_value(iter));
  2583. if (!prop_is_valid) {
  2584. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field type failed validation\n");
  2585. res = 0;
  2586. }
  2587. } else
  2588. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2589. int prop_is_valid;
  2590. has_application = 1;
  2591. prop_is_valid = ast_ari_validate_string(
  2592. ast_json_object_iter_value(iter));
  2593. if (!prop_is_valid) {
  2594. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field application failed validation\n");
  2595. res = 0;
  2596. }
  2597. } else
  2598. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2599. int prop_is_valid;
  2600. prop_is_valid = ast_ari_validate_date(
  2601. ast_json_object_iter_value(iter));
  2602. if (!prop_is_valid) {
  2603. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field timestamp failed validation\n");
  2604. res = 0;
  2605. }
  2606. } else
  2607. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2608. int prop_is_valid;
  2609. has_channel = 1;
  2610. prop_is_valid = ast_ari_validate_channel(
  2611. ast_json_object_iter_value(iter));
  2612. if (!prop_is_valid) {
  2613. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field channel failed validation\n");
  2614. res = 0;
  2615. }
  2616. } else
  2617. if (strcmp("digit", ast_json_object_iter_key(iter)) == 0) {
  2618. int prop_is_valid;
  2619. has_digit = 1;
  2620. prop_is_valid = ast_ari_validate_string(
  2621. ast_json_object_iter_value(iter));
  2622. if (!prop_is_valid) {
  2623. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field digit failed validation\n");
  2624. res = 0;
  2625. }
  2626. } else
  2627. if (strcmp("duration_ms", ast_json_object_iter_key(iter)) == 0) {
  2628. int prop_is_valid;
  2629. has_duration_ms = 1;
  2630. prop_is_valid = ast_ari_validate_int(
  2631. ast_json_object_iter_value(iter));
  2632. if (!prop_is_valid) {
  2633. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field duration_ms failed validation\n");
  2634. res = 0;
  2635. }
  2636. } else
  2637. {
  2638. ast_log(LOG_ERROR,
  2639. "ARI ChannelDtmfReceived has undocumented field %s\n",
  2640. ast_json_object_iter_key(iter));
  2641. res = 0;
  2642. }
  2643. }
  2644. if (!has_type) {
  2645. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field type\n");
  2646. res = 0;
  2647. }
  2648. if (!has_application) {
  2649. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field application\n");
  2650. res = 0;
  2651. }
  2652. if (!has_channel) {
  2653. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field channel\n");
  2654. res = 0;
  2655. }
  2656. if (!has_digit) {
  2657. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field digit\n");
  2658. res = 0;
  2659. }
  2660. if (!has_duration_ms) {
  2661. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field duration_ms\n");
  2662. res = 0;
  2663. }
  2664. return res;
  2665. }
  2666. ari_validator ast_ari_validate_channel_dtmf_received_fn(void)
  2667. {
  2668. return ast_ari_validate_channel_dtmf_received;
  2669. }
  2670. int ast_ari_validate_channel_entered_bridge(struct ast_json *json)
  2671. {
  2672. int res = 1;
  2673. struct ast_json_iter *iter;
  2674. int has_type = 0;
  2675. int has_application = 0;
  2676. int has_bridge = 0;
  2677. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2678. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2679. int prop_is_valid;
  2680. has_type = 1;
  2681. prop_is_valid = ast_ari_validate_string(
  2682. ast_json_object_iter_value(iter));
  2683. if (!prop_is_valid) {
  2684. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field type failed validation\n");
  2685. res = 0;
  2686. }
  2687. } else
  2688. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2689. int prop_is_valid;
  2690. has_application = 1;
  2691. prop_is_valid = ast_ari_validate_string(
  2692. ast_json_object_iter_value(iter));
  2693. if (!prop_is_valid) {
  2694. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field application failed validation\n");
  2695. res = 0;
  2696. }
  2697. } else
  2698. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2699. int prop_is_valid;
  2700. prop_is_valid = ast_ari_validate_date(
  2701. ast_json_object_iter_value(iter));
  2702. if (!prop_is_valid) {
  2703. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field timestamp failed validation\n");
  2704. res = 0;
  2705. }
  2706. } else
  2707. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2708. int prop_is_valid;
  2709. has_bridge = 1;
  2710. prop_is_valid = ast_ari_validate_bridge(
  2711. ast_json_object_iter_value(iter));
  2712. if (!prop_is_valid) {
  2713. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field bridge failed validation\n");
  2714. res = 0;
  2715. }
  2716. } else
  2717. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2718. int prop_is_valid;
  2719. prop_is_valid = ast_ari_validate_channel(
  2720. ast_json_object_iter_value(iter));
  2721. if (!prop_is_valid) {
  2722. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field channel failed validation\n");
  2723. res = 0;
  2724. }
  2725. } else
  2726. {
  2727. ast_log(LOG_ERROR,
  2728. "ARI ChannelEnteredBridge has undocumented field %s\n",
  2729. ast_json_object_iter_key(iter));
  2730. res = 0;
  2731. }
  2732. }
  2733. if (!has_type) {
  2734. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field type\n");
  2735. res = 0;
  2736. }
  2737. if (!has_application) {
  2738. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field application\n");
  2739. res = 0;
  2740. }
  2741. if (!has_bridge) {
  2742. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field bridge\n");
  2743. res = 0;
  2744. }
  2745. return res;
  2746. }
  2747. ari_validator ast_ari_validate_channel_entered_bridge_fn(void)
  2748. {
  2749. return ast_ari_validate_channel_entered_bridge;
  2750. }
  2751. int ast_ari_validate_channel_hangup_request(struct ast_json *json)
  2752. {
  2753. int res = 1;
  2754. struct ast_json_iter *iter;
  2755. int has_type = 0;
  2756. int has_application = 0;
  2757. int has_channel = 0;
  2758. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2759. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2760. int prop_is_valid;
  2761. has_type = 1;
  2762. prop_is_valid = ast_ari_validate_string(
  2763. ast_json_object_iter_value(iter));
  2764. if (!prop_is_valid) {
  2765. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field type failed validation\n");
  2766. res = 0;
  2767. }
  2768. } else
  2769. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2770. int prop_is_valid;
  2771. has_application = 1;
  2772. prop_is_valid = ast_ari_validate_string(
  2773. ast_json_object_iter_value(iter));
  2774. if (!prop_is_valid) {
  2775. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field application failed validation\n");
  2776. res = 0;
  2777. }
  2778. } else
  2779. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2780. int prop_is_valid;
  2781. prop_is_valid = ast_ari_validate_date(
  2782. ast_json_object_iter_value(iter));
  2783. if (!prop_is_valid) {
  2784. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field timestamp failed validation\n");
  2785. res = 0;
  2786. }
  2787. } else
  2788. if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
  2789. int prop_is_valid;
  2790. prop_is_valid = ast_ari_validate_int(
  2791. ast_json_object_iter_value(iter));
  2792. if (!prop_is_valid) {
  2793. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field cause failed validation\n");
  2794. res = 0;
  2795. }
  2796. } else
  2797. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2798. int prop_is_valid;
  2799. has_channel = 1;
  2800. prop_is_valid = ast_ari_validate_channel(
  2801. ast_json_object_iter_value(iter));
  2802. if (!prop_is_valid) {
  2803. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field channel failed validation\n");
  2804. res = 0;
  2805. }
  2806. } else
  2807. if (strcmp("soft", ast_json_object_iter_key(iter)) == 0) {
  2808. int prop_is_valid;
  2809. prop_is_valid = ast_ari_validate_boolean(
  2810. ast_json_object_iter_value(iter));
  2811. if (!prop_is_valid) {
  2812. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field soft failed validation\n");
  2813. res = 0;
  2814. }
  2815. } else
  2816. {
  2817. ast_log(LOG_ERROR,
  2818. "ARI ChannelHangupRequest has undocumented field %s\n",
  2819. ast_json_object_iter_key(iter));
  2820. res = 0;
  2821. }
  2822. }
  2823. if (!has_type) {
  2824. ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field type\n");
  2825. res = 0;
  2826. }
  2827. if (!has_application) {
  2828. ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field application\n");
  2829. res = 0;
  2830. }
  2831. if (!has_channel) {
  2832. ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field channel\n");
  2833. res = 0;
  2834. }
  2835. return res;
  2836. }
  2837. ari_validator ast_ari_validate_channel_hangup_request_fn(void)
  2838. {
  2839. return ast_ari_validate_channel_hangup_request;
  2840. }
  2841. int ast_ari_validate_channel_left_bridge(struct ast_json *json)
  2842. {
  2843. int res = 1;
  2844. struct ast_json_iter *iter;
  2845. int has_type = 0;
  2846. int has_application = 0;
  2847. int has_bridge = 0;
  2848. int has_channel = 0;
  2849. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2850. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2851. int prop_is_valid;
  2852. has_type = 1;
  2853. prop_is_valid = ast_ari_validate_string(
  2854. ast_json_object_iter_value(iter));
  2855. if (!prop_is_valid) {
  2856. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field type failed validation\n");
  2857. res = 0;
  2858. }
  2859. } else
  2860. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2861. int prop_is_valid;
  2862. has_application = 1;
  2863. prop_is_valid = ast_ari_validate_string(
  2864. ast_json_object_iter_value(iter));
  2865. if (!prop_is_valid) {
  2866. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field application failed validation\n");
  2867. res = 0;
  2868. }
  2869. } else
  2870. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2871. int prop_is_valid;
  2872. prop_is_valid = ast_ari_validate_date(
  2873. ast_json_object_iter_value(iter));
  2874. if (!prop_is_valid) {
  2875. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field timestamp failed validation\n");
  2876. res = 0;
  2877. }
  2878. } else
  2879. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2880. int prop_is_valid;
  2881. has_bridge = 1;
  2882. prop_is_valid = ast_ari_validate_bridge(
  2883. ast_json_object_iter_value(iter));
  2884. if (!prop_is_valid) {
  2885. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field bridge failed validation\n");
  2886. res = 0;
  2887. }
  2888. } else
  2889. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2890. int prop_is_valid;
  2891. has_channel = 1;
  2892. prop_is_valid = ast_ari_validate_channel(
  2893. ast_json_object_iter_value(iter));
  2894. if (!prop_is_valid) {
  2895. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field channel failed validation\n");
  2896. res = 0;
  2897. }
  2898. } else
  2899. {
  2900. ast_log(LOG_ERROR,
  2901. "ARI ChannelLeftBridge has undocumented field %s\n",
  2902. ast_json_object_iter_key(iter));
  2903. res = 0;
  2904. }
  2905. }
  2906. if (!has_type) {
  2907. ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field type\n");
  2908. res = 0;
  2909. }
  2910. if (!has_application) {
  2911. ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field application\n");
  2912. res = 0;
  2913. }
  2914. if (!has_bridge) {
  2915. ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field bridge\n");
  2916. res = 0;
  2917. }
  2918. if (!has_channel) {
  2919. ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field channel\n");
  2920. res = 0;
  2921. }
  2922. return res;
  2923. }
  2924. ari_validator ast_ari_validate_channel_left_bridge_fn(void)
  2925. {
  2926. return ast_ari_validate_channel_left_bridge;
  2927. }
  2928. int ast_ari_validate_channel_state_change(struct ast_json *json)
  2929. {
  2930. int res = 1;
  2931. struct ast_json_iter *iter;
  2932. int has_type = 0;
  2933. int has_application = 0;
  2934. int has_channel = 0;
  2935. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2936. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2937. int prop_is_valid;
  2938. has_type = 1;
  2939. prop_is_valid = ast_ari_validate_string(
  2940. ast_json_object_iter_value(iter));
  2941. if (!prop_is_valid) {
  2942. ast_log(LOG_ERROR, "ARI ChannelStateChange field type failed validation\n");
  2943. res = 0;
  2944. }
  2945. } else
  2946. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2947. int prop_is_valid;
  2948. has_application = 1;
  2949. prop_is_valid = ast_ari_validate_string(
  2950. ast_json_object_iter_value(iter));
  2951. if (!prop_is_valid) {
  2952. ast_log(LOG_ERROR, "ARI ChannelStateChange field application failed validation\n");
  2953. res = 0;
  2954. }
  2955. } else
  2956. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2957. int prop_is_valid;
  2958. prop_is_valid = ast_ari_validate_date(
  2959. ast_json_object_iter_value(iter));
  2960. if (!prop_is_valid) {
  2961. ast_log(LOG_ERROR, "ARI ChannelStateChange field timestamp failed validation\n");
  2962. res = 0;
  2963. }
  2964. } else
  2965. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2966. int prop_is_valid;
  2967. has_channel = 1;
  2968. prop_is_valid = ast_ari_validate_channel(
  2969. ast_json_object_iter_value(iter));
  2970. if (!prop_is_valid) {
  2971. ast_log(LOG_ERROR, "ARI ChannelStateChange field channel failed validation\n");
  2972. res = 0;
  2973. }
  2974. } else
  2975. {
  2976. ast_log(LOG_ERROR,
  2977. "ARI ChannelStateChange has undocumented field %s\n",
  2978. ast_json_object_iter_key(iter));
  2979. res = 0;
  2980. }
  2981. }
  2982. if (!has_type) {
  2983. ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field type\n");
  2984. res = 0;
  2985. }
  2986. if (!has_application) {
  2987. ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field application\n");
  2988. res = 0;
  2989. }
  2990. if (!has_channel) {
  2991. ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field channel\n");
  2992. res = 0;
  2993. }
  2994. return res;
  2995. }
  2996. ari_validator ast_ari_validate_channel_state_change_fn(void)
  2997. {
  2998. return ast_ari_validate_channel_state_change;
  2999. }
  3000. int ast_ari_validate_channel_talking_finished(struct ast_json *json)
  3001. {
  3002. int res = 1;
  3003. struct ast_json_iter *iter;
  3004. int has_type = 0;
  3005. int has_application = 0;
  3006. int has_channel = 0;
  3007. int has_duration = 0;
  3008. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3009. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3010. int prop_is_valid;
  3011. has_type = 1;
  3012. prop_is_valid = ast_ari_validate_string(
  3013. ast_json_object_iter_value(iter));
  3014. if (!prop_is_valid) {
  3015. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field type failed validation\n");
  3016. res = 0;
  3017. }
  3018. } else
  3019. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3020. int prop_is_valid;
  3021. has_application = 1;
  3022. prop_is_valid = ast_ari_validate_string(
  3023. ast_json_object_iter_value(iter));
  3024. if (!prop_is_valid) {
  3025. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field application failed validation\n");
  3026. res = 0;
  3027. }
  3028. } else
  3029. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3030. int prop_is_valid;
  3031. prop_is_valid = ast_ari_validate_date(
  3032. ast_json_object_iter_value(iter));
  3033. if (!prop_is_valid) {
  3034. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field timestamp failed validation\n");
  3035. res = 0;
  3036. }
  3037. } else
  3038. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3039. int prop_is_valid;
  3040. has_channel = 1;
  3041. prop_is_valid = ast_ari_validate_channel(
  3042. ast_json_object_iter_value(iter));
  3043. if (!prop_is_valid) {
  3044. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field channel failed validation\n");
  3045. res = 0;
  3046. }
  3047. } else
  3048. if (strcmp("duration", ast_json_object_iter_key(iter)) == 0) {
  3049. int prop_is_valid;
  3050. has_duration = 1;
  3051. prop_is_valid = ast_ari_validate_int(
  3052. ast_json_object_iter_value(iter));
  3053. if (!prop_is_valid) {
  3054. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field duration failed validation\n");
  3055. res = 0;
  3056. }
  3057. } else
  3058. {
  3059. ast_log(LOG_ERROR,
  3060. "ARI ChannelTalkingFinished has undocumented field %s\n",
  3061. ast_json_object_iter_key(iter));
  3062. res = 0;
  3063. }
  3064. }
  3065. if (!has_type) {
  3066. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished missing required field type\n");
  3067. res = 0;
  3068. }
  3069. if (!has_application) {
  3070. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished missing required field application\n");
  3071. res = 0;
  3072. }
  3073. if (!has_channel) {
  3074. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished missing required field channel\n");
  3075. res = 0;
  3076. }
  3077. if (!has_duration) {
  3078. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished missing required field duration\n");
  3079. res = 0;
  3080. }
  3081. return res;
  3082. }
  3083. ari_validator ast_ari_validate_channel_talking_finished_fn(void)
  3084. {
  3085. return ast_ari_validate_channel_talking_finished;
  3086. }
  3087. int ast_ari_validate_channel_talking_started(struct ast_json *json)
  3088. {
  3089. int res = 1;
  3090. struct ast_json_iter *iter;
  3091. int has_type = 0;
  3092. int has_application = 0;
  3093. int has_channel = 0;
  3094. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3095. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3096. int prop_is_valid;
  3097. has_type = 1;
  3098. prop_is_valid = ast_ari_validate_string(
  3099. ast_json_object_iter_value(iter));
  3100. if (!prop_is_valid) {
  3101. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field type failed validation\n");
  3102. res = 0;
  3103. }
  3104. } else
  3105. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3106. int prop_is_valid;
  3107. has_application = 1;
  3108. prop_is_valid = ast_ari_validate_string(
  3109. ast_json_object_iter_value(iter));
  3110. if (!prop_is_valid) {
  3111. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field application failed validation\n");
  3112. res = 0;
  3113. }
  3114. } else
  3115. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3116. int prop_is_valid;
  3117. prop_is_valid = ast_ari_validate_date(
  3118. ast_json_object_iter_value(iter));
  3119. if (!prop_is_valid) {
  3120. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field timestamp failed validation\n");
  3121. res = 0;
  3122. }
  3123. } else
  3124. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3125. int prop_is_valid;
  3126. has_channel = 1;
  3127. prop_is_valid = ast_ari_validate_channel(
  3128. ast_json_object_iter_value(iter));
  3129. if (!prop_is_valid) {
  3130. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field channel failed validation\n");
  3131. res = 0;
  3132. }
  3133. } else
  3134. {
  3135. ast_log(LOG_ERROR,
  3136. "ARI ChannelTalkingStarted has undocumented field %s\n",
  3137. ast_json_object_iter_key(iter));
  3138. res = 0;
  3139. }
  3140. }
  3141. if (!has_type) {
  3142. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted missing required field type\n");
  3143. res = 0;
  3144. }
  3145. if (!has_application) {
  3146. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted missing required field application\n");
  3147. res = 0;
  3148. }
  3149. if (!has_channel) {
  3150. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted missing required field channel\n");
  3151. res = 0;
  3152. }
  3153. return res;
  3154. }
  3155. ari_validator ast_ari_validate_channel_talking_started_fn(void)
  3156. {
  3157. return ast_ari_validate_channel_talking_started;
  3158. }
  3159. int ast_ari_validate_channel_userevent(struct ast_json *json)
  3160. {
  3161. int res = 1;
  3162. struct ast_json_iter *iter;
  3163. int has_type = 0;
  3164. int has_application = 0;
  3165. int has_eventname = 0;
  3166. int has_userevent = 0;
  3167. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3168. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3169. int prop_is_valid;
  3170. has_type = 1;
  3171. prop_is_valid = ast_ari_validate_string(
  3172. ast_json_object_iter_value(iter));
  3173. if (!prop_is_valid) {
  3174. ast_log(LOG_ERROR, "ARI ChannelUserevent field type failed validation\n");
  3175. res = 0;
  3176. }
  3177. } else
  3178. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3179. int prop_is_valid;
  3180. has_application = 1;
  3181. prop_is_valid = ast_ari_validate_string(
  3182. ast_json_object_iter_value(iter));
  3183. if (!prop_is_valid) {
  3184. ast_log(LOG_ERROR, "ARI ChannelUserevent field application failed validation\n");
  3185. res = 0;
  3186. }
  3187. } else
  3188. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3189. int prop_is_valid;
  3190. prop_is_valid = ast_ari_validate_date(
  3191. ast_json_object_iter_value(iter));
  3192. if (!prop_is_valid) {
  3193. ast_log(LOG_ERROR, "ARI ChannelUserevent field timestamp failed validation\n");
  3194. res = 0;
  3195. }
  3196. } else
  3197. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  3198. int prop_is_valid;
  3199. prop_is_valid = ast_ari_validate_bridge(
  3200. ast_json_object_iter_value(iter));
  3201. if (!prop_is_valid) {
  3202. ast_log(LOG_ERROR, "ARI ChannelUserevent field bridge failed validation\n");
  3203. res = 0;
  3204. }
  3205. } else
  3206. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3207. int prop_is_valid;
  3208. prop_is_valid = ast_ari_validate_channel(
  3209. ast_json_object_iter_value(iter));
  3210. if (!prop_is_valid) {
  3211. ast_log(LOG_ERROR, "ARI ChannelUserevent field channel failed validation\n");
  3212. res = 0;
  3213. }
  3214. } else
  3215. if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
  3216. int prop_is_valid;
  3217. prop_is_valid = ast_ari_validate_endpoint(
  3218. ast_json_object_iter_value(iter));
  3219. if (!prop_is_valid) {
  3220. ast_log(LOG_ERROR, "ARI ChannelUserevent field endpoint failed validation\n");
  3221. res = 0;
  3222. }
  3223. } else
  3224. if (strcmp("eventname", ast_json_object_iter_key(iter)) == 0) {
  3225. int prop_is_valid;
  3226. has_eventname = 1;
  3227. prop_is_valid = ast_ari_validate_string(
  3228. ast_json_object_iter_value(iter));
  3229. if (!prop_is_valid) {
  3230. ast_log(LOG_ERROR, "ARI ChannelUserevent field eventname failed validation\n");
  3231. res = 0;
  3232. }
  3233. } else
  3234. if (strcmp("userevent", ast_json_object_iter_key(iter)) == 0) {
  3235. int prop_is_valid;
  3236. has_userevent = 1;
  3237. prop_is_valid = ast_ari_validate_object(
  3238. ast_json_object_iter_value(iter));
  3239. if (!prop_is_valid) {
  3240. ast_log(LOG_ERROR, "ARI ChannelUserevent field userevent failed validation\n");
  3241. res = 0;
  3242. }
  3243. } else
  3244. {
  3245. ast_log(LOG_ERROR,
  3246. "ARI ChannelUserevent has undocumented field %s\n",
  3247. ast_json_object_iter_key(iter));
  3248. res = 0;
  3249. }
  3250. }
  3251. if (!has_type) {
  3252. ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field type\n");
  3253. res = 0;
  3254. }
  3255. if (!has_application) {
  3256. ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field application\n");
  3257. res = 0;
  3258. }
  3259. if (!has_eventname) {
  3260. ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field eventname\n");
  3261. res = 0;
  3262. }
  3263. if (!has_userevent) {
  3264. ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field userevent\n");
  3265. res = 0;
  3266. }
  3267. return res;
  3268. }
  3269. ari_validator ast_ari_validate_channel_userevent_fn(void)
  3270. {
  3271. return ast_ari_validate_channel_userevent;
  3272. }
  3273. int ast_ari_validate_channel_varset(struct ast_json *json)
  3274. {
  3275. int res = 1;
  3276. struct ast_json_iter *iter;
  3277. int has_type = 0;
  3278. int has_application = 0;
  3279. int has_value = 0;
  3280. int has_variable = 0;
  3281. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3282. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3283. int prop_is_valid;
  3284. has_type = 1;
  3285. prop_is_valid = ast_ari_validate_string(
  3286. ast_json_object_iter_value(iter));
  3287. if (!prop_is_valid) {
  3288. ast_log(LOG_ERROR, "ARI ChannelVarset field type failed validation\n");
  3289. res = 0;
  3290. }
  3291. } else
  3292. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3293. int prop_is_valid;
  3294. has_application = 1;
  3295. prop_is_valid = ast_ari_validate_string(
  3296. ast_json_object_iter_value(iter));
  3297. if (!prop_is_valid) {
  3298. ast_log(LOG_ERROR, "ARI ChannelVarset field application failed validation\n");
  3299. res = 0;
  3300. }
  3301. } else
  3302. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3303. int prop_is_valid;
  3304. prop_is_valid = ast_ari_validate_date(
  3305. ast_json_object_iter_value(iter));
  3306. if (!prop_is_valid) {
  3307. ast_log(LOG_ERROR, "ARI ChannelVarset field timestamp failed validation\n");
  3308. res = 0;
  3309. }
  3310. } else
  3311. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3312. int prop_is_valid;
  3313. prop_is_valid = ast_ari_validate_channel(
  3314. ast_json_object_iter_value(iter));
  3315. if (!prop_is_valid) {
  3316. ast_log(LOG_ERROR, "ARI ChannelVarset field channel failed validation\n");
  3317. res = 0;
  3318. }
  3319. } else
  3320. if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
  3321. int prop_is_valid;
  3322. has_value = 1;
  3323. prop_is_valid = ast_ari_validate_string(
  3324. ast_json_object_iter_value(iter));
  3325. if (!prop_is_valid) {
  3326. ast_log(LOG_ERROR, "ARI ChannelVarset field value failed validation\n");
  3327. res = 0;
  3328. }
  3329. } else
  3330. if (strcmp("variable", ast_json_object_iter_key(iter)) == 0) {
  3331. int prop_is_valid;
  3332. has_variable = 1;
  3333. prop_is_valid = ast_ari_validate_string(
  3334. ast_json_object_iter_value(iter));
  3335. if (!prop_is_valid) {
  3336. ast_log(LOG_ERROR, "ARI ChannelVarset field variable failed validation\n");
  3337. res = 0;
  3338. }
  3339. } else
  3340. {
  3341. ast_log(LOG_ERROR,
  3342. "ARI ChannelVarset has undocumented field %s\n",
  3343. ast_json_object_iter_key(iter));
  3344. res = 0;
  3345. }
  3346. }
  3347. if (!has_type) {
  3348. ast_log(LOG_ERROR, "ARI ChannelVarset missing required field type\n");
  3349. res = 0;
  3350. }
  3351. if (!has_application) {
  3352. ast_log(LOG_ERROR, "ARI ChannelVarset missing required field application\n");
  3353. res = 0;
  3354. }
  3355. if (!has_value) {
  3356. ast_log(LOG_ERROR, "ARI ChannelVarset missing required field value\n");
  3357. res = 0;
  3358. }
  3359. if (!has_variable) {
  3360. ast_log(LOG_ERROR, "ARI ChannelVarset missing required field variable\n");
  3361. res = 0;
  3362. }
  3363. return res;
  3364. }
  3365. ari_validator ast_ari_validate_channel_varset_fn(void)
  3366. {
  3367. return ast_ari_validate_channel_varset;
  3368. }
  3369. int ast_ari_validate_device_state_changed(struct ast_json *json)
  3370. {
  3371. int res = 1;
  3372. struct ast_json_iter *iter;
  3373. int has_type = 0;
  3374. int has_application = 0;
  3375. int has_device_state = 0;
  3376. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3377. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3378. int prop_is_valid;
  3379. has_type = 1;
  3380. prop_is_valid = ast_ari_validate_string(
  3381. ast_json_object_iter_value(iter));
  3382. if (!prop_is_valid) {
  3383. ast_log(LOG_ERROR, "ARI DeviceStateChanged field type failed validation\n");
  3384. res = 0;
  3385. }
  3386. } else
  3387. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3388. int prop_is_valid;
  3389. has_application = 1;
  3390. prop_is_valid = ast_ari_validate_string(
  3391. ast_json_object_iter_value(iter));
  3392. if (!prop_is_valid) {
  3393. ast_log(LOG_ERROR, "ARI DeviceStateChanged field application failed validation\n");
  3394. res = 0;
  3395. }
  3396. } else
  3397. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3398. int prop_is_valid;
  3399. prop_is_valid = ast_ari_validate_date(
  3400. ast_json_object_iter_value(iter));
  3401. if (!prop_is_valid) {
  3402. ast_log(LOG_ERROR, "ARI DeviceStateChanged field timestamp failed validation\n");
  3403. res = 0;
  3404. }
  3405. } else
  3406. if (strcmp("device_state", ast_json_object_iter_key(iter)) == 0) {
  3407. int prop_is_valid;
  3408. has_device_state = 1;
  3409. prop_is_valid = ast_ari_validate_device_state(
  3410. ast_json_object_iter_value(iter));
  3411. if (!prop_is_valid) {
  3412. ast_log(LOG_ERROR, "ARI DeviceStateChanged field device_state failed validation\n");
  3413. res = 0;
  3414. }
  3415. } else
  3416. {
  3417. ast_log(LOG_ERROR,
  3418. "ARI DeviceStateChanged has undocumented field %s\n",
  3419. ast_json_object_iter_key(iter));
  3420. res = 0;
  3421. }
  3422. }
  3423. if (!has_type) {
  3424. ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field type\n");
  3425. res = 0;
  3426. }
  3427. if (!has_application) {
  3428. ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field application\n");
  3429. res = 0;
  3430. }
  3431. if (!has_device_state) {
  3432. ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field device_state\n");
  3433. res = 0;
  3434. }
  3435. return res;
  3436. }
  3437. ari_validator ast_ari_validate_device_state_changed_fn(void)
  3438. {
  3439. return ast_ari_validate_device_state_changed;
  3440. }
  3441. int ast_ari_validate_dial(struct ast_json *json)
  3442. {
  3443. int res = 1;
  3444. struct ast_json_iter *iter;
  3445. int has_type = 0;
  3446. int has_application = 0;
  3447. int has_dialstatus = 0;
  3448. int has_peer = 0;
  3449. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3450. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3451. int prop_is_valid;
  3452. has_type = 1;
  3453. prop_is_valid = ast_ari_validate_string(
  3454. ast_json_object_iter_value(iter));
  3455. if (!prop_is_valid) {
  3456. ast_log(LOG_ERROR, "ARI Dial field type failed validation\n");
  3457. res = 0;
  3458. }
  3459. } else
  3460. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3461. int prop_is_valid;
  3462. has_application = 1;
  3463. prop_is_valid = ast_ari_validate_string(
  3464. ast_json_object_iter_value(iter));
  3465. if (!prop_is_valid) {
  3466. ast_log(LOG_ERROR, "ARI Dial field application failed validation\n");
  3467. res = 0;
  3468. }
  3469. } else
  3470. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3471. int prop_is_valid;
  3472. prop_is_valid = ast_ari_validate_date(
  3473. ast_json_object_iter_value(iter));
  3474. if (!prop_is_valid) {
  3475. ast_log(LOG_ERROR, "ARI Dial field timestamp failed validation\n");
  3476. res = 0;
  3477. }
  3478. } else
  3479. if (strcmp("caller", ast_json_object_iter_key(iter)) == 0) {
  3480. int prop_is_valid;
  3481. prop_is_valid = ast_ari_validate_channel(
  3482. ast_json_object_iter_value(iter));
  3483. if (!prop_is_valid) {
  3484. ast_log(LOG_ERROR, "ARI Dial field caller failed validation\n");
  3485. res = 0;
  3486. }
  3487. } else
  3488. if (strcmp("dialstatus", ast_json_object_iter_key(iter)) == 0) {
  3489. int prop_is_valid;
  3490. has_dialstatus = 1;
  3491. prop_is_valid = ast_ari_validate_string(
  3492. ast_json_object_iter_value(iter));
  3493. if (!prop_is_valid) {
  3494. ast_log(LOG_ERROR, "ARI Dial field dialstatus failed validation\n");
  3495. res = 0;
  3496. }
  3497. } else
  3498. if (strcmp("dialstring", ast_json_object_iter_key(iter)) == 0) {
  3499. int prop_is_valid;
  3500. prop_is_valid = ast_ari_validate_string(
  3501. ast_json_object_iter_value(iter));
  3502. if (!prop_is_valid) {
  3503. ast_log(LOG_ERROR, "ARI Dial field dialstring failed validation\n");
  3504. res = 0;
  3505. }
  3506. } else
  3507. if (strcmp("forward", ast_json_object_iter_key(iter)) == 0) {
  3508. int prop_is_valid;
  3509. prop_is_valid = ast_ari_validate_string(
  3510. ast_json_object_iter_value(iter));
  3511. if (!prop_is_valid) {
  3512. ast_log(LOG_ERROR, "ARI Dial field forward failed validation\n");
  3513. res = 0;
  3514. }
  3515. } else
  3516. if (strcmp("forwarded", ast_json_object_iter_key(iter)) == 0) {
  3517. int prop_is_valid;
  3518. prop_is_valid = ast_ari_validate_channel(
  3519. ast_json_object_iter_value(iter));
  3520. if (!prop_is_valid) {
  3521. ast_log(LOG_ERROR, "ARI Dial field forwarded failed validation\n");
  3522. res = 0;
  3523. }
  3524. } else
  3525. if (strcmp("peer", ast_json_object_iter_key(iter)) == 0) {
  3526. int prop_is_valid;
  3527. has_peer = 1;
  3528. prop_is_valid = ast_ari_validate_channel(
  3529. ast_json_object_iter_value(iter));
  3530. if (!prop_is_valid) {
  3531. ast_log(LOG_ERROR, "ARI Dial field peer failed validation\n");
  3532. res = 0;
  3533. }
  3534. } else
  3535. {
  3536. ast_log(LOG_ERROR,
  3537. "ARI Dial has undocumented field %s\n",
  3538. ast_json_object_iter_key(iter));
  3539. res = 0;
  3540. }
  3541. }
  3542. if (!has_type) {
  3543. ast_log(LOG_ERROR, "ARI Dial missing required field type\n");
  3544. res = 0;
  3545. }
  3546. if (!has_application) {
  3547. ast_log(LOG_ERROR, "ARI Dial missing required field application\n");
  3548. res = 0;
  3549. }
  3550. if (!has_dialstatus) {
  3551. ast_log(LOG_ERROR, "ARI Dial missing required field dialstatus\n");
  3552. res = 0;
  3553. }
  3554. if (!has_peer) {
  3555. ast_log(LOG_ERROR, "ARI Dial missing required field peer\n");
  3556. res = 0;
  3557. }
  3558. return res;
  3559. }
  3560. ari_validator ast_ari_validate_dial_fn(void)
  3561. {
  3562. return ast_ari_validate_dial;
  3563. }
  3564. int ast_ari_validate_endpoint_state_change(struct ast_json *json)
  3565. {
  3566. int res = 1;
  3567. struct ast_json_iter *iter;
  3568. int has_type = 0;
  3569. int has_application = 0;
  3570. int has_endpoint = 0;
  3571. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3572. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3573. int prop_is_valid;
  3574. has_type = 1;
  3575. prop_is_valid = ast_ari_validate_string(
  3576. ast_json_object_iter_value(iter));
  3577. if (!prop_is_valid) {
  3578. ast_log(LOG_ERROR, "ARI EndpointStateChange field type failed validation\n");
  3579. res = 0;
  3580. }
  3581. } else
  3582. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3583. int prop_is_valid;
  3584. has_application = 1;
  3585. prop_is_valid = ast_ari_validate_string(
  3586. ast_json_object_iter_value(iter));
  3587. if (!prop_is_valid) {
  3588. ast_log(LOG_ERROR, "ARI EndpointStateChange field application failed validation\n");
  3589. res = 0;
  3590. }
  3591. } else
  3592. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3593. int prop_is_valid;
  3594. prop_is_valid = ast_ari_validate_date(
  3595. ast_json_object_iter_value(iter));
  3596. if (!prop_is_valid) {
  3597. ast_log(LOG_ERROR, "ARI EndpointStateChange field timestamp failed validation\n");
  3598. res = 0;
  3599. }
  3600. } else
  3601. if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
  3602. int prop_is_valid;
  3603. has_endpoint = 1;
  3604. prop_is_valid = ast_ari_validate_endpoint(
  3605. ast_json_object_iter_value(iter));
  3606. if (!prop_is_valid) {
  3607. ast_log(LOG_ERROR, "ARI EndpointStateChange field endpoint failed validation\n");
  3608. res = 0;
  3609. }
  3610. } else
  3611. {
  3612. ast_log(LOG_ERROR,
  3613. "ARI EndpointStateChange has undocumented field %s\n",
  3614. ast_json_object_iter_key(iter));
  3615. res = 0;
  3616. }
  3617. }
  3618. if (!has_type) {
  3619. ast_log(LOG_ERROR, "ARI EndpointStateChange missing required field type\n");
  3620. res = 0;
  3621. }
  3622. if (!has_application) {
  3623. ast_log(LOG_ERROR, "ARI EndpointStateChange missing required field application\n");
  3624. res = 0;
  3625. }
  3626. if (!has_endpoint) {
  3627. ast_log(LOG_ERROR, "ARI EndpointStateChange missing required field endpoint\n");
  3628. res = 0;
  3629. }
  3630. return res;
  3631. }
  3632. ari_validator ast_ari_validate_endpoint_state_change_fn(void)
  3633. {
  3634. return ast_ari_validate_endpoint_state_change;
  3635. }
  3636. int ast_ari_validate_event(struct ast_json *json)
  3637. {
  3638. int res = 1;
  3639. struct ast_json_iter *iter;
  3640. int has_type = 0;
  3641. int has_application = 0;
  3642. const char *discriminator;
  3643. discriminator = ast_json_string_get(ast_json_object_get(json, "type"));
  3644. if (!discriminator) {
  3645. ast_log(LOG_ERROR, "ARI Event missing required field type");
  3646. return 0;
  3647. }
  3648. if (strcmp("Event", discriminator) == 0) {
  3649. /* Self type; fall through */
  3650. } else
  3651. if (strcmp("ApplicationReplaced", discriminator) == 0) {
  3652. return ast_ari_validate_application_replaced(json);
  3653. } else
  3654. if (strcmp("BridgeAttendedTransfer", discriminator) == 0) {
  3655. return ast_ari_validate_bridge_attended_transfer(json);
  3656. } else
  3657. if (strcmp("BridgeBlindTransfer", discriminator) == 0) {
  3658. return ast_ari_validate_bridge_blind_transfer(json);
  3659. } else
  3660. if (strcmp("BridgeCreated", discriminator) == 0) {
  3661. return ast_ari_validate_bridge_created(json);
  3662. } else
  3663. if (strcmp("BridgeDestroyed", discriminator) == 0) {
  3664. return ast_ari_validate_bridge_destroyed(json);
  3665. } else
  3666. if (strcmp("BridgeMerged", discriminator) == 0) {
  3667. return ast_ari_validate_bridge_merged(json);
  3668. } else
  3669. if (strcmp("ChannelCallerId", discriminator) == 0) {
  3670. return ast_ari_validate_channel_caller_id(json);
  3671. } else
  3672. if (strcmp("ChannelCreated", discriminator) == 0) {
  3673. return ast_ari_validate_channel_created(json);
  3674. } else
  3675. if (strcmp("ChannelDestroyed", discriminator) == 0) {
  3676. return ast_ari_validate_channel_destroyed(json);
  3677. } else
  3678. if (strcmp("ChannelDialplan", discriminator) == 0) {
  3679. return ast_ari_validate_channel_dialplan(json);
  3680. } else
  3681. if (strcmp("ChannelDtmfReceived", discriminator) == 0) {
  3682. return ast_ari_validate_channel_dtmf_received(json);
  3683. } else
  3684. if (strcmp("ChannelEnteredBridge", discriminator) == 0) {
  3685. return ast_ari_validate_channel_entered_bridge(json);
  3686. } else
  3687. if (strcmp("ChannelHangupRequest", discriminator) == 0) {
  3688. return ast_ari_validate_channel_hangup_request(json);
  3689. } else
  3690. if (strcmp("ChannelLeftBridge", discriminator) == 0) {
  3691. return ast_ari_validate_channel_left_bridge(json);
  3692. } else
  3693. if (strcmp("ChannelStateChange", discriminator) == 0) {
  3694. return ast_ari_validate_channel_state_change(json);
  3695. } else
  3696. if (strcmp("ChannelTalkingFinished", discriminator) == 0) {
  3697. return ast_ari_validate_channel_talking_finished(json);
  3698. } else
  3699. if (strcmp("ChannelTalkingStarted", discriminator) == 0) {
  3700. return ast_ari_validate_channel_talking_started(json);
  3701. } else
  3702. if (strcmp("ChannelUserevent", discriminator) == 0) {
  3703. return ast_ari_validate_channel_userevent(json);
  3704. } else
  3705. if (strcmp("ChannelVarset", discriminator) == 0) {
  3706. return ast_ari_validate_channel_varset(json);
  3707. } else
  3708. if (strcmp("DeviceStateChanged", discriminator) == 0) {
  3709. return ast_ari_validate_device_state_changed(json);
  3710. } else
  3711. if (strcmp("Dial", discriminator) == 0) {
  3712. return ast_ari_validate_dial(json);
  3713. } else
  3714. if (strcmp("EndpointStateChange", discriminator) == 0) {
  3715. return ast_ari_validate_endpoint_state_change(json);
  3716. } else
  3717. if (strcmp("PlaybackFinished", discriminator) == 0) {
  3718. return ast_ari_validate_playback_finished(json);
  3719. } else
  3720. if (strcmp("PlaybackStarted", discriminator) == 0) {
  3721. return ast_ari_validate_playback_started(json);
  3722. } else
  3723. if (strcmp("RecordingFailed", discriminator) == 0) {
  3724. return ast_ari_validate_recording_failed(json);
  3725. } else
  3726. if (strcmp("RecordingFinished", discriminator) == 0) {
  3727. return ast_ari_validate_recording_finished(json);
  3728. } else
  3729. if (strcmp("RecordingStarted", discriminator) == 0) {
  3730. return ast_ari_validate_recording_started(json);
  3731. } else
  3732. if (strcmp("StasisEnd", discriminator) == 0) {
  3733. return ast_ari_validate_stasis_end(json);
  3734. } else
  3735. if (strcmp("StasisStart", discriminator) == 0) {
  3736. return ast_ari_validate_stasis_start(json);
  3737. } else
  3738. if (strcmp("TextMessageReceived", discriminator) == 0) {
  3739. return ast_ari_validate_text_message_received(json);
  3740. } else
  3741. {
  3742. ast_log(LOG_ERROR, "ARI Event has undocumented subtype %s\n",
  3743. discriminator);
  3744. res = 0;
  3745. }
  3746. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3747. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3748. int prop_is_valid;
  3749. has_type = 1;
  3750. prop_is_valid = ast_ari_validate_string(
  3751. ast_json_object_iter_value(iter));
  3752. if (!prop_is_valid) {
  3753. ast_log(LOG_ERROR, "ARI Event field type failed validation\n");
  3754. res = 0;
  3755. }
  3756. } else
  3757. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3758. int prop_is_valid;
  3759. has_application = 1;
  3760. prop_is_valid = ast_ari_validate_string(
  3761. ast_json_object_iter_value(iter));
  3762. if (!prop_is_valid) {
  3763. ast_log(LOG_ERROR, "ARI Event field application failed validation\n");
  3764. res = 0;
  3765. }
  3766. } else
  3767. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3768. int prop_is_valid;
  3769. prop_is_valid = ast_ari_validate_date(
  3770. ast_json_object_iter_value(iter));
  3771. if (!prop_is_valid) {
  3772. ast_log(LOG_ERROR, "ARI Event field timestamp failed validation\n");
  3773. res = 0;
  3774. }
  3775. } else
  3776. {
  3777. ast_log(LOG_ERROR,
  3778. "ARI Event has undocumented field %s\n",
  3779. ast_json_object_iter_key(iter));
  3780. res = 0;
  3781. }
  3782. }
  3783. if (!has_type) {
  3784. ast_log(LOG_ERROR, "ARI Event missing required field type\n");
  3785. res = 0;
  3786. }
  3787. if (!has_application) {
  3788. ast_log(LOG_ERROR, "ARI Event missing required field application\n");
  3789. res = 0;
  3790. }
  3791. return res;
  3792. }
  3793. ari_validator ast_ari_validate_event_fn(void)
  3794. {
  3795. return ast_ari_validate_event;
  3796. }
  3797. int ast_ari_validate_message(struct ast_json *json)
  3798. {
  3799. int res = 1;
  3800. struct ast_json_iter *iter;
  3801. int has_type = 0;
  3802. const char *discriminator;
  3803. discriminator = ast_json_string_get(ast_json_object_get(json, "type"));
  3804. if (!discriminator) {
  3805. ast_log(LOG_ERROR, "ARI Message missing required field type");
  3806. return 0;
  3807. }
  3808. if (strcmp("Message", discriminator) == 0) {
  3809. /* Self type; fall through */
  3810. } else
  3811. if (strcmp("ApplicationReplaced", discriminator) == 0) {
  3812. return ast_ari_validate_application_replaced(json);
  3813. } else
  3814. if (strcmp("BridgeAttendedTransfer", discriminator) == 0) {
  3815. return ast_ari_validate_bridge_attended_transfer(json);
  3816. } else
  3817. if (strcmp("BridgeBlindTransfer", discriminator) == 0) {
  3818. return ast_ari_validate_bridge_blind_transfer(json);
  3819. } else
  3820. if (strcmp("BridgeCreated", discriminator) == 0) {
  3821. return ast_ari_validate_bridge_created(json);
  3822. } else
  3823. if (strcmp("BridgeDestroyed", discriminator) == 0) {
  3824. return ast_ari_validate_bridge_destroyed(json);
  3825. } else
  3826. if (strcmp("BridgeMerged", discriminator) == 0) {
  3827. return ast_ari_validate_bridge_merged(json);
  3828. } else
  3829. if (strcmp("ChannelCallerId", discriminator) == 0) {
  3830. return ast_ari_validate_channel_caller_id(json);
  3831. } else
  3832. if (strcmp("ChannelCreated", discriminator) == 0) {
  3833. return ast_ari_validate_channel_created(json);
  3834. } else
  3835. if (strcmp("ChannelDestroyed", discriminator) == 0) {
  3836. return ast_ari_validate_channel_destroyed(json);
  3837. } else
  3838. if (strcmp("ChannelDialplan", discriminator) == 0) {
  3839. return ast_ari_validate_channel_dialplan(json);
  3840. } else
  3841. if (strcmp("ChannelDtmfReceived", discriminator) == 0) {
  3842. return ast_ari_validate_channel_dtmf_received(json);
  3843. } else
  3844. if (strcmp("ChannelEnteredBridge", discriminator) == 0) {
  3845. return ast_ari_validate_channel_entered_bridge(json);
  3846. } else
  3847. if (strcmp("ChannelHangupRequest", discriminator) == 0) {
  3848. return ast_ari_validate_channel_hangup_request(json);
  3849. } else
  3850. if (strcmp("ChannelLeftBridge", discriminator) == 0) {
  3851. return ast_ari_validate_channel_left_bridge(json);
  3852. } else
  3853. if (strcmp("ChannelStateChange", discriminator) == 0) {
  3854. return ast_ari_validate_channel_state_change(json);
  3855. } else
  3856. if (strcmp("ChannelTalkingFinished", discriminator) == 0) {
  3857. return ast_ari_validate_channel_talking_finished(json);
  3858. } else
  3859. if (strcmp("ChannelTalkingStarted", discriminator) == 0) {
  3860. return ast_ari_validate_channel_talking_started(json);
  3861. } else
  3862. if (strcmp("ChannelUserevent", discriminator) == 0) {
  3863. return ast_ari_validate_channel_userevent(json);
  3864. } else
  3865. if (strcmp("ChannelVarset", discriminator) == 0) {
  3866. return ast_ari_validate_channel_varset(json);
  3867. } else
  3868. if (strcmp("DeviceStateChanged", discriminator) == 0) {
  3869. return ast_ari_validate_device_state_changed(json);
  3870. } else
  3871. if (strcmp("Dial", discriminator) == 0) {
  3872. return ast_ari_validate_dial(json);
  3873. } else
  3874. if (strcmp("EndpointStateChange", discriminator) == 0) {
  3875. return ast_ari_validate_endpoint_state_change(json);
  3876. } else
  3877. if (strcmp("Event", discriminator) == 0) {
  3878. return ast_ari_validate_event(json);
  3879. } else
  3880. if (strcmp("MissingParams", discriminator) == 0) {
  3881. return ast_ari_validate_missing_params(json);
  3882. } else
  3883. if (strcmp("PlaybackFinished", discriminator) == 0) {
  3884. return ast_ari_validate_playback_finished(json);
  3885. } else
  3886. if (strcmp("PlaybackStarted", discriminator) == 0) {
  3887. return ast_ari_validate_playback_started(json);
  3888. } else
  3889. if (strcmp("RecordingFailed", discriminator) == 0) {
  3890. return ast_ari_validate_recording_failed(json);
  3891. } else
  3892. if (strcmp("RecordingFinished", discriminator) == 0) {
  3893. return ast_ari_validate_recording_finished(json);
  3894. } else
  3895. if (strcmp("RecordingStarted", discriminator) == 0) {
  3896. return ast_ari_validate_recording_started(json);
  3897. } else
  3898. if (strcmp("StasisEnd", discriminator) == 0) {
  3899. return ast_ari_validate_stasis_end(json);
  3900. } else
  3901. if (strcmp("StasisStart", discriminator) == 0) {
  3902. return ast_ari_validate_stasis_start(json);
  3903. } else
  3904. if (strcmp("TextMessageReceived", discriminator) == 0) {
  3905. return ast_ari_validate_text_message_received(json);
  3906. } else
  3907. {
  3908. ast_log(LOG_ERROR, "ARI Message has undocumented subtype %s\n",
  3909. discriminator);
  3910. res = 0;
  3911. }
  3912. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3913. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3914. int prop_is_valid;
  3915. has_type = 1;
  3916. prop_is_valid = ast_ari_validate_string(
  3917. ast_json_object_iter_value(iter));
  3918. if (!prop_is_valid) {
  3919. ast_log(LOG_ERROR, "ARI Message field type failed validation\n");
  3920. res = 0;
  3921. }
  3922. } else
  3923. {
  3924. ast_log(LOG_ERROR,
  3925. "ARI Message has undocumented field %s\n",
  3926. ast_json_object_iter_key(iter));
  3927. res = 0;
  3928. }
  3929. }
  3930. if (!has_type) {
  3931. ast_log(LOG_ERROR, "ARI Message missing required field type\n");
  3932. res = 0;
  3933. }
  3934. return res;
  3935. }
  3936. ari_validator ast_ari_validate_message_fn(void)
  3937. {
  3938. return ast_ari_validate_message;
  3939. }
  3940. int ast_ari_validate_missing_params(struct ast_json *json)
  3941. {
  3942. int res = 1;
  3943. struct ast_json_iter *iter;
  3944. int has_type = 0;
  3945. int has_params = 0;
  3946. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3947. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3948. int prop_is_valid;
  3949. has_type = 1;
  3950. prop_is_valid = ast_ari_validate_string(
  3951. ast_json_object_iter_value(iter));
  3952. if (!prop_is_valid) {
  3953. ast_log(LOG_ERROR, "ARI MissingParams field type failed validation\n");
  3954. res = 0;
  3955. }
  3956. } else
  3957. if (strcmp("params", ast_json_object_iter_key(iter)) == 0) {
  3958. int prop_is_valid;
  3959. has_params = 1;
  3960. prop_is_valid = ast_ari_validate_list(
  3961. ast_json_object_iter_value(iter),
  3962. ast_ari_validate_string);
  3963. if (!prop_is_valid) {
  3964. ast_log(LOG_ERROR, "ARI MissingParams field params failed validation\n");
  3965. res = 0;
  3966. }
  3967. } else
  3968. {
  3969. ast_log(LOG_ERROR,
  3970. "ARI MissingParams has undocumented field %s\n",
  3971. ast_json_object_iter_key(iter));
  3972. res = 0;
  3973. }
  3974. }
  3975. if (!has_type) {
  3976. ast_log(LOG_ERROR, "ARI MissingParams missing required field type\n");
  3977. res = 0;
  3978. }
  3979. if (!has_params) {
  3980. ast_log(LOG_ERROR, "ARI MissingParams missing required field params\n");
  3981. res = 0;
  3982. }
  3983. return res;
  3984. }
  3985. ari_validator ast_ari_validate_missing_params_fn(void)
  3986. {
  3987. return ast_ari_validate_missing_params;
  3988. }
  3989. int ast_ari_validate_playback_finished(struct ast_json *json)
  3990. {
  3991. int res = 1;
  3992. struct ast_json_iter *iter;
  3993. int has_type = 0;
  3994. int has_application = 0;
  3995. int has_playback = 0;
  3996. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3997. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3998. int prop_is_valid;
  3999. has_type = 1;
  4000. prop_is_valid = ast_ari_validate_string(
  4001. ast_json_object_iter_value(iter));
  4002. if (!prop_is_valid) {
  4003. ast_log(LOG_ERROR, "ARI PlaybackFinished field type failed validation\n");
  4004. res = 0;
  4005. }
  4006. } else
  4007. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4008. int prop_is_valid;
  4009. has_application = 1;
  4010. prop_is_valid = ast_ari_validate_string(
  4011. ast_json_object_iter_value(iter));
  4012. if (!prop_is_valid) {
  4013. ast_log(LOG_ERROR, "ARI PlaybackFinished field application failed validation\n");
  4014. res = 0;
  4015. }
  4016. } else
  4017. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4018. int prop_is_valid;
  4019. prop_is_valid = ast_ari_validate_date(
  4020. ast_json_object_iter_value(iter));
  4021. if (!prop_is_valid) {
  4022. ast_log(LOG_ERROR, "ARI PlaybackFinished field timestamp failed validation\n");
  4023. res = 0;
  4024. }
  4025. } else
  4026. if (strcmp("playback", ast_json_object_iter_key(iter)) == 0) {
  4027. int prop_is_valid;
  4028. has_playback = 1;
  4029. prop_is_valid = ast_ari_validate_playback(
  4030. ast_json_object_iter_value(iter));
  4031. if (!prop_is_valid) {
  4032. ast_log(LOG_ERROR, "ARI PlaybackFinished field playback failed validation\n");
  4033. res = 0;
  4034. }
  4035. } else
  4036. {
  4037. ast_log(LOG_ERROR,
  4038. "ARI PlaybackFinished has undocumented field %s\n",
  4039. ast_json_object_iter_key(iter));
  4040. res = 0;
  4041. }
  4042. }
  4043. if (!has_type) {
  4044. ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field type\n");
  4045. res = 0;
  4046. }
  4047. if (!has_application) {
  4048. ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field application\n");
  4049. res = 0;
  4050. }
  4051. if (!has_playback) {
  4052. ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field playback\n");
  4053. res = 0;
  4054. }
  4055. return res;
  4056. }
  4057. ari_validator ast_ari_validate_playback_finished_fn(void)
  4058. {
  4059. return ast_ari_validate_playback_finished;
  4060. }
  4061. int ast_ari_validate_playback_started(struct ast_json *json)
  4062. {
  4063. int res = 1;
  4064. struct ast_json_iter *iter;
  4065. int has_type = 0;
  4066. int has_application = 0;
  4067. int has_playback = 0;
  4068. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4069. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4070. int prop_is_valid;
  4071. has_type = 1;
  4072. prop_is_valid = ast_ari_validate_string(
  4073. ast_json_object_iter_value(iter));
  4074. if (!prop_is_valid) {
  4075. ast_log(LOG_ERROR, "ARI PlaybackStarted field type failed validation\n");
  4076. res = 0;
  4077. }
  4078. } else
  4079. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4080. int prop_is_valid;
  4081. has_application = 1;
  4082. prop_is_valid = ast_ari_validate_string(
  4083. ast_json_object_iter_value(iter));
  4084. if (!prop_is_valid) {
  4085. ast_log(LOG_ERROR, "ARI PlaybackStarted field application failed validation\n");
  4086. res = 0;
  4087. }
  4088. } else
  4089. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4090. int prop_is_valid;
  4091. prop_is_valid = ast_ari_validate_date(
  4092. ast_json_object_iter_value(iter));
  4093. if (!prop_is_valid) {
  4094. ast_log(LOG_ERROR, "ARI PlaybackStarted field timestamp failed validation\n");
  4095. res = 0;
  4096. }
  4097. } else
  4098. if (strcmp("playback", ast_json_object_iter_key(iter)) == 0) {
  4099. int prop_is_valid;
  4100. has_playback = 1;
  4101. prop_is_valid = ast_ari_validate_playback(
  4102. ast_json_object_iter_value(iter));
  4103. if (!prop_is_valid) {
  4104. ast_log(LOG_ERROR, "ARI PlaybackStarted field playback failed validation\n");
  4105. res = 0;
  4106. }
  4107. } else
  4108. {
  4109. ast_log(LOG_ERROR,
  4110. "ARI PlaybackStarted has undocumented field %s\n",
  4111. ast_json_object_iter_key(iter));
  4112. res = 0;
  4113. }
  4114. }
  4115. if (!has_type) {
  4116. ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field type\n");
  4117. res = 0;
  4118. }
  4119. if (!has_application) {
  4120. ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field application\n");
  4121. res = 0;
  4122. }
  4123. if (!has_playback) {
  4124. ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field playback\n");
  4125. res = 0;
  4126. }
  4127. return res;
  4128. }
  4129. ari_validator ast_ari_validate_playback_started_fn(void)
  4130. {
  4131. return ast_ari_validate_playback_started;
  4132. }
  4133. int ast_ari_validate_recording_failed(struct ast_json *json)
  4134. {
  4135. int res = 1;
  4136. struct ast_json_iter *iter;
  4137. int has_type = 0;
  4138. int has_application = 0;
  4139. int has_recording = 0;
  4140. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4141. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4142. int prop_is_valid;
  4143. has_type = 1;
  4144. prop_is_valid = ast_ari_validate_string(
  4145. ast_json_object_iter_value(iter));
  4146. if (!prop_is_valid) {
  4147. ast_log(LOG_ERROR, "ARI RecordingFailed field type failed validation\n");
  4148. res = 0;
  4149. }
  4150. } else
  4151. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4152. int prop_is_valid;
  4153. has_application = 1;
  4154. prop_is_valid = ast_ari_validate_string(
  4155. ast_json_object_iter_value(iter));
  4156. if (!prop_is_valid) {
  4157. ast_log(LOG_ERROR, "ARI RecordingFailed field application failed validation\n");
  4158. res = 0;
  4159. }
  4160. } else
  4161. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4162. int prop_is_valid;
  4163. prop_is_valid = ast_ari_validate_date(
  4164. ast_json_object_iter_value(iter));
  4165. if (!prop_is_valid) {
  4166. ast_log(LOG_ERROR, "ARI RecordingFailed field timestamp failed validation\n");
  4167. res = 0;
  4168. }
  4169. } else
  4170. if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
  4171. int prop_is_valid;
  4172. has_recording = 1;
  4173. prop_is_valid = ast_ari_validate_live_recording(
  4174. ast_json_object_iter_value(iter));
  4175. if (!prop_is_valid) {
  4176. ast_log(LOG_ERROR, "ARI RecordingFailed field recording failed validation\n");
  4177. res = 0;
  4178. }
  4179. } else
  4180. {
  4181. ast_log(LOG_ERROR,
  4182. "ARI RecordingFailed has undocumented field %s\n",
  4183. ast_json_object_iter_key(iter));
  4184. res = 0;
  4185. }
  4186. }
  4187. if (!has_type) {
  4188. ast_log(LOG_ERROR, "ARI RecordingFailed missing required field type\n");
  4189. res = 0;
  4190. }
  4191. if (!has_application) {
  4192. ast_log(LOG_ERROR, "ARI RecordingFailed missing required field application\n");
  4193. res = 0;
  4194. }
  4195. if (!has_recording) {
  4196. ast_log(LOG_ERROR, "ARI RecordingFailed missing required field recording\n");
  4197. res = 0;
  4198. }
  4199. return res;
  4200. }
  4201. ari_validator ast_ari_validate_recording_failed_fn(void)
  4202. {
  4203. return ast_ari_validate_recording_failed;
  4204. }
  4205. int ast_ari_validate_recording_finished(struct ast_json *json)
  4206. {
  4207. int res = 1;
  4208. struct ast_json_iter *iter;
  4209. int has_type = 0;
  4210. int has_application = 0;
  4211. int has_recording = 0;
  4212. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4213. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4214. int prop_is_valid;
  4215. has_type = 1;
  4216. prop_is_valid = ast_ari_validate_string(
  4217. ast_json_object_iter_value(iter));
  4218. if (!prop_is_valid) {
  4219. ast_log(LOG_ERROR, "ARI RecordingFinished field type failed validation\n");
  4220. res = 0;
  4221. }
  4222. } else
  4223. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4224. int prop_is_valid;
  4225. has_application = 1;
  4226. prop_is_valid = ast_ari_validate_string(
  4227. ast_json_object_iter_value(iter));
  4228. if (!prop_is_valid) {
  4229. ast_log(LOG_ERROR, "ARI RecordingFinished field application failed validation\n");
  4230. res = 0;
  4231. }
  4232. } else
  4233. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4234. int prop_is_valid;
  4235. prop_is_valid = ast_ari_validate_date(
  4236. ast_json_object_iter_value(iter));
  4237. if (!prop_is_valid) {
  4238. ast_log(LOG_ERROR, "ARI RecordingFinished field timestamp failed validation\n");
  4239. res = 0;
  4240. }
  4241. } else
  4242. if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
  4243. int prop_is_valid;
  4244. has_recording = 1;
  4245. prop_is_valid = ast_ari_validate_live_recording(
  4246. ast_json_object_iter_value(iter));
  4247. if (!prop_is_valid) {
  4248. ast_log(LOG_ERROR, "ARI RecordingFinished field recording failed validation\n");
  4249. res = 0;
  4250. }
  4251. } else
  4252. {
  4253. ast_log(LOG_ERROR,
  4254. "ARI RecordingFinished has undocumented field %s\n",
  4255. ast_json_object_iter_key(iter));
  4256. res = 0;
  4257. }
  4258. }
  4259. if (!has_type) {
  4260. ast_log(LOG_ERROR, "ARI RecordingFinished missing required field type\n");
  4261. res = 0;
  4262. }
  4263. if (!has_application) {
  4264. ast_log(LOG_ERROR, "ARI RecordingFinished missing required field application\n");
  4265. res = 0;
  4266. }
  4267. if (!has_recording) {
  4268. ast_log(LOG_ERROR, "ARI RecordingFinished missing required field recording\n");
  4269. res = 0;
  4270. }
  4271. return res;
  4272. }
  4273. ari_validator ast_ari_validate_recording_finished_fn(void)
  4274. {
  4275. return ast_ari_validate_recording_finished;
  4276. }
  4277. int ast_ari_validate_recording_started(struct ast_json *json)
  4278. {
  4279. int res = 1;
  4280. struct ast_json_iter *iter;
  4281. int has_type = 0;
  4282. int has_application = 0;
  4283. int has_recording = 0;
  4284. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4285. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4286. int prop_is_valid;
  4287. has_type = 1;
  4288. prop_is_valid = ast_ari_validate_string(
  4289. ast_json_object_iter_value(iter));
  4290. if (!prop_is_valid) {
  4291. ast_log(LOG_ERROR, "ARI RecordingStarted field type failed validation\n");
  4292. res = 0;
  4293. }
  4294. } else
  4295. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4296. int prop_is_valid;
  4297. has_application = 1;
  4298. prop_is_valid = ast_ari_validate_string(
  4299. ast_json_object_iter_value(iter));
  4300. if (!prop_is_valid) {
  4301. ast_log(LOG_ERROR, "ARI RecordingStarted field application failed validation\n");
  4302. res = 0;
  4303. }
  4304. } else
  4305. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4306. int prop_is_valid;
  4307. prop_is_valid = ast_ari_validate_date(
  4308. ast_json_object_iter_value(iter));
  4309. if (!prop_is_valid) {
  4310. ast_log(LOG_ERROR, "ARI RecordingStarted field timestamp failed validation\n");
  4311. res = 0;
  4312. }
  4313. } else
  4314. if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
  4315. int prop_is_valid;
  4316. has_recording = 1;
  4317. prop_is_valid = ast_ari_validate_live_recording(
  4318. ast_json_object_iter_value(iter));
  4319. if (!prop_is_valid) {
  4320. ast_log(LOG_ERROR, "ARI RecordingStarted field recording failed validation\n");
  4321. res = 0;
  4322. }
  4323. } else
  4324. {
  4325. ast_log(LOG_ERROR,
  4326. "ARI RecordingStarted has undocumented field %s\n",
  4327. ast_json_object_iter_key(iter));
  4328. res = 0;
  4329. }
  4330. }
  4331. if (!has_type) {
  4332. ast_log(LOG_ERROR, "ARI RecordingStarted missing required field type\n");
  4333. res = 0;
  4334. }
  4335. if (!has_application) {
  4336. ast_log(LOG_ERROR, "ARI RecordingStarted missing required field application\n");
  4337. res = 0;
  4338. }
  4339. if (!has_recording) {
  4340. ast_log(LOG_ERROR, "ARI RecordingStarted missing required field recording\n");
  4341. res = 0;
  4342. }
  4343. return res;
  4344. }
  4345. ari_validator ast_ari_validate_recording_started_fn(void)
  4346. {
  4347. return ast_ari_validate_recording_started;
  4348. }
  4349. int ast_ari_validate_stasis_end(struct ast_json *json)
  4350. {
  4351. int res = 1;
  4352. struct ast_json_iter *iter;
  4353. int has_type = 0;
  4354. int has_application = 0;
  4355. int has_channel = 0;
  4356. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4357. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4358. int prop_is_valid;
  4359. has_type = 1;
  4360. prop_is_valid = ast_ari_validate_string(
  4361. ast_json_object_iter_value(iter));
  4362. if (!prop_is_valid) {
  4363. ast_log(LOG_ERROR, "ARI StasisEnd field type failed validation\n");
  4364. res = 0;
  4365. }
  4366. } else
  4367. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4368. int prop_is_valid;
  4369. has_application = 1;
  4370. prop_is_valid = ast_ari_validate_string(
  4371. ast_json_object_iter_value(iter));
  4372. if (!prop_is_valid) {
  4373. ast_log(LOG_ERROR, "ARI StasisEnd field application failed validation\n");
  4374. res = 0;
  4375. }
  4376. } else
  4377. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4378. int prop_is_valid;
  4379. prop_is_valid = ast_ari_validate_date(
  4380. ast_json_object_iter_value(iter));
  4381. if (!prop_is_valid) {
  4382. ast_log(LOG_ERROR, "ARI StasisEnd field timestamp failed validation\n");
  4383. res = 0;
  4384. }
  4385. } else
  4386. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  4387. int prop_is_valid;
  4388. has_channel = 1;
  4389. prop_is_valid = ast_ari_validate_channel(
  4390. ast_json_object_iter_value(iter));
  4391. if (!prop_is_valid) {
  4392. ast_log(LOG_ERROR, "ARI StasisEnd field channel failed validation\n");
  4393. res = 0;
  4394. }
  4395. } else
  4396. {
  4397. ast_log(LOG_ERROR,
  4398. "ARI StasisEnd has undocumented field %s\n",
  4399. ast_json_object_iter_key(iter));
  4400. res = 0;
  4401. }
  4402. }
  4403. if (!has_type) {
  4404. ast_log(LOG_ERROR, "ARI StasisEnd missing required field type\n");
  4405. res = 0;
  4406. }
  4407. if (!has_application) {
  4408. ast_log(LOG_ERROR, "ARI StasisEnd missing required field application\n");
  4409. res = 0;
  4410. }
  4411. if (!has_channel) {
  4412. ast_log(LOG_ERROR, "ARI StasisEnd missing required field channel\n");
  4413. res = 0;
  4414. }
  4415. return res;
  4416. }
  4417. ari_validator ast_ari_validate_stasis_end_fn(void)
  4418. {
  4419. return ast_ari_validate_stasis_end;
  4420. }
  4421. int ast_ari_validate_stasis_start(struct ast_json *json)
  4422. {
  4423. int res = 1;
  4424. struct ast_json_iter *iter;
  4425. int has_type = 0;
  4426. int has_application = 0;
  4427. int has_args = 0;
  4428. int has_channel = 0;
  4429. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4430. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4431. int prop_is_valid;
  4432. has_type = 1;
  4433. prop_is_valid = ast_ari_validate_string(
  4434. ast_json_object_iter_value(iter));
  4435. if (!prop_is_valid) {
  4436. ast_log(LOG_ERROR, "ARI StasisStart field type failed validation\n");
  4437. res = 0;
  4438. }
  4439. } else
  4440. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4441. int prop_is_valid;
  4442. has_application = 1;
  4443. prop_is_valid = ast_ari_validate_string(
  4444. ast_json_object_iter_value(iter));
  4445. if (!prop_is_valid) {
  4446. ast_log(LOG_ERROR, "ARI StasisStart field application failed validation\n");
  4447. res = 0;
  4448. }
  4449. } else
  4450. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4451. int prop_is_valid;
  4452. prop_is_valid = ast_ari_validate_date(
  4453. ast_json_object_iter_value(iter));
  4454. if (!prop_is_valid) {
  4455. ast_log(LOG_ERROR, "ARI StasisStart field timestamp failed validation\n");
  4456. res = 0;
  4457. }
  4458. } else
  4459. if (strcmp("args", ast_json_object_iter_key(iter)) == 0) {
  4460. int prop_is_valid;
  4461. has_args = 1;
  4462. prop_is_valid = ast_ari_validate_list(
  4463. ast_json_object_iter_value(iter),
  4464. ast_ari_validate_string);
  4465. if (!prop_is_valid) {
  4466. ast_log(LOG_ERROR, "ARI StasisStart field args failed validation\n");
  4467. res = 0;
  4468. }
  4469. } else
  4470. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  4471. int prop_is_valid;
  4472. has_channel = 1;
  4473. prop_is_valid = ast_ari_validate_channel(
  4474. ast_json_object_iter_value(iter));
  4475. if (!prop_is_valid) {
  4476. ast_log(LOG_ERROR, "ARI StasisStart field channel failed validation\n");
  4477. res = 0;
  4478. }
  4479. } else
  4480. if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
  4481. int prop_is_valid;
  4482. prop_is_valid = ast_ari_validate_channel(
  4483. ast_json_object_iter_value(iter));
  4484. if (!prop_is_valid) {
  4485. ast_log(LOG_ERROR, "ARI StasisStart field replace_channel failed validation\n");
  4486. res = 0;
  4487. }
  4488. } else
  4489. {
  4490. ast_log(LOG_ERROR,
  4491. "ARI StasisStart has undocumented field %s\n",
  4492. ast_json_object_iter_key(iter));
  4493. res = 0;
  4494. }
  4495. }
  4496. if (!has_type) {
  4497. ast_log(LOG_ERROR, "ARI StasisStart missing required field type\n");
  4498. res = 0;
  4499. }
  4500. if (!has_application) {
  4501. ast_log(LOG_ERROR, "ARI StasisStart missing required field application\n");
  4502. res = 0;
  4503. }
  4504. if (!has_args) {
  4505. ast_log(LOG_ERROR, "ARI StasisStart missing required field args\n");
  4506. res = 0;
  4507. }
  4508. if (!has_channel) {
  4509. ast_log(LOG_ERROR, "ARI StasisStart missing required field channel\n");
  4510. res = 0;
  4511. }
  4512. return res;
  4513. }
  4514. ari_validator ast_ari_validate_stasis_start_fn(void)
  4515. {
  4516. return ast_ari_validate_stasis_start;
  4517. }
  4518. int ast_ari_validate_text_message_received(struct ast_json *json)
  4519. {
  4520. int res = 1;
  4521. struct ast_json_iter *iter;
  4522. int has_type = 0;
  4523. int has_application = 0;
  4524. int has_message = 0;
  4525. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4526. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4527. int prop_is_valid;
  4528. has_type = 1;
  4529. prop_is_valid = ast_ari_validate_string(
  4530. ast_json_object_iter_value(iter));
  4531. if (!prop_is_valid) {
  4532. ast_log(LOG_ERROR, "ARI TextMessageReceived field type failed validation\n");
  4533. res = 0;
  4534. }
  4535. } else
  4536. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4537. int prop_is_valid;
  4538. has_application = 1;
  4539. prop_is_valid = ast_ari_validate_string(
  4540. ast_json_object_iter_value(iter));
  4541. if (!prop_is_valid) {
  4542. ast_log(LOG_ERROR, "ARI TextMessageReceived field application failed validation\n");
  4543. res = 0;
  4544. }
  4545. } else
  4546. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4547. int prop_is_valid;
  4548. prop_is_valid = ast_ari_validate_date(
  4549. ast_json_object_iter_value(iter));
  4550. if (!prop_is_valid) {
  4551. ast_log(LOG_ERROR, "ARI TextMessageReceived field timestamp failed validation\n");
  4552. res = 0;
  4553. }
  4554. } else
  4555. if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
  4556. int prop_is_valid;
  4557. prop_is_valid = ast_ari_validate_endpoint(
  4558. ast_json_object_iter_value(iter));
  4559. if (!prop_is_valid) {
  4560. ast_log(LOG_ERROR, "ARI TextMessageReceived field endpoint failed validation\n");
  4561. res = 0;
  4562. }
  4563. } else
  4564. if (strcmp("message", ast_json_object_iter_key(iter)) == 0) {
  4565. int prop_is_valid;
  4566. has_message = 1;
  4567. prop_is_valid = ast_ari_validate_text_message(
  4568. ast_json_object_iter_value(iter));
  4569. if (!prop_is_valid) {
  4570. ast_log(LOG_ERROR, "ARI TextMessageReceived field message failed validation\n");
  4571. res = 0;
  4572. }
  4573. } else
  4574. {
  4575. ast_log(LOG_ERROR,
  4576. "ARI TextMessageReceived has undocumented field %s\n",
  4577. ast_json_object_iter_key(iter));
  4578. res = 0;
  4579. }
  4580. }
  4581. if (!has_type) {
  4582. ast_log(LOG_ERROR, "ARI TextMessageReceived missing required field type\n");
  4583. res = 0;
  4584. }
  4585. if (!has_application) {
  4586. ast_log(LOG_ERROR, "ARI TextMessageReceived missing required field application\n");
  4587. res = 0;
  4588. }
  4589. if (!has_message) {
  4590. ast_log(LOG_ERROR, "ARI TextMessageReceived missing required field message\n");
  4591. res = 0;
  4592. }
  4593. return res;
  4594. }
  4595. ari_validator ast_ari_validate_text_message_received_fn(void)
  4596. {
  4597. return ast_ari_validate_text_message_received;
  4598. }
  4599. int ast_ari_validate_application(struct ast_json *json)
  4600. {
  4601. int res = 1;
  4602. struct ast_json_iter *iter;
  4603. int has_bridge_ids = 0;
  4604. int has_channel_ids = 0;
  4605. int has_device_names = 0;
  4606. int has_endpoint_ids = 0;
  4607. int has_name = 0;
  4608. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4609. if (strcmp("bridge_ids", ast_json_object_iter_key(iter)) == 0) {
  4610. int prop_is_valid;
  4611. has_bridge_ids = 1;
  4612. prop_is_valid = ast_ari_validate_list(
  4613. ast_json_object_iter_value(iter),
  4614. ast_ari_validate_string);
  4615. if (!prop_is_valid) {
  4616. ast_log(LOG_ERROR, "ARI Application field bridge_ids failed validation\n");
  4617. res = 0;
  4618. }
  4619. } else
  4620. if (strcmp("channel_ids", ast_json_object_iter_key(iter)) == 0) {
  4621. int prop_is_valid;
  4622. has_channel_ids = 1;
  4623. prop_is_valid = ast_ari_validate_list(
  4624. ast_json_object_iter_value(iter),
  4625. ast_ari_validate_string);
  4626. if (!prop_is_valid) {
  4627. ast_log(LOG_ERROR, "ARI Application field channel_ids failed validation\n");
  4628. res = 0;
  4629. }
  4630. } else
  4631. if (strcmp("device_names", ast_json_object_iter_key(iter)) == 0) {
  4632. int prop_is_valid;
  4633. has_device_names = 1;
  4634. prop_is_valid = ast_ari_validate_list(
  4635. ast_json_object_iter_value(iter),
  4636. ast_ari_validate_string);
  4637. if (!prop_is_valid) {
  4638. ast_log(LOG_ERROR, "ARI Application field device_names failed validation\n");
  4639. res = 0;
  4640. }
  4641. } else
  4642. if (strcmp("endpoint_ids", ast_json_object_iter_key(iter)) == 0) {
  4643. int prop_is_valid;
  4644. has_endpoint_ids = 1;
  4645. prop_is_valid = ast_ari_validate_list(
  4646. ast_json_object_iter_value(iter),
  4647. ast_ari_validate_string);
  4648. if (!prop_is_valid) {
  4649. ast_log(LOG_ERROR, "ARI Application field endpoint_ids failed validation\n");
  4650. res = 0;
  4651. }
  4652. } else
  4653. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  4654. int prop_is_valid;
  4655. has_name = 1;
  4656. prop_is_valid = ast_ari_validate_string(
  4657. ast_json_object_iter_value(iter));
  4658. if (!prop_is_valid) {
  4659. ast_log(LOG_ERROR, "ARI Application field name failed validation\n");
  4660. res = 0;
  4661. }
  4662. } else
  4663. {
  4664. ast_log(LOG_ERROR,
  4665. "ARI Application has undocumented field %s\n",
  4666. ast_json_object_iter_key(iter));
  4667. res = 0;
  4668. }
  4669. }
  4670. if (!has_bridge_ids) {
  4671. ast_log(LOG_ERROR, "ARI Application missing required field bridge_ids\n");
  4672. res = 0;
  4673. }
  4674. if (!has_channel_ids) {
  4675. ast_log(LOG_ERROR, "ARI Application missing required field channel_ids\n");
  4676. res = 0;
  4677. }
  4678. if (!has_device_names) {
  4679. ast_log(LOG_ERROR, "ARI Application missing required field device_names\n");
  4680. res = 0;
  4681. }
  4682. if (!has_endpoint_ids) {
  4683. ast_log(LOG_ERROR, "ARI Application missing required field endpoint_ids\n");
  4684. res = 0;
  4685. }
  4686. if (!has_name) {
  4687. ast_log(LOG_ERROR, "ARI Application missing required field name\n");
  4688. res = 0;
  4689. }
  4690. return res;
  4691. }
  4692. ari_validator ast_ari_validate_application_fn(void)
  4693. {
  4694. return ast_ari_validate_application;
  4695. }