ari_model_validators.c 179 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523
  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.c.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_asterisk_ping(struct ast_json *json)
  87. {
  88. int res = 1;
  89. struct ast_json_iter *iter;
  90. int has_asterisk_id = 0;
  91. int has_ping = 0;
  92. int has_timestamp = 0;
  93. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  94. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  95. int prop_is_valid;
  96. has_asterisk_id = 1;
  97. prop_is_valid = ast_ari_validate_string(
  98. ast_json_object_iter_value(iter));
  99. if (!prop_is_valid) {
  100. ast_log(LOG_ERROR, "ARI AsteriskPing field asterisk_id failed validation\n");
  101. res = 0;
  102. }
  103. } else
  104. if (strcmp("ping", ast_json_object_iter_key(iter)) == 0) {
  105. int prop_is_valid;
  106. has_ping = 1;
  107. prop_is_valid = ast_ari_validate_string(
  108. ast_json_object_iter_value(iter));
  109. if (!prop_is_valid) {
  110. ast_log(LOG_ERROR, "ARI AsteriskPing field ping failed validation\n");
  111. res = 0;
  112. }
  113. } else
  114. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  115. int prop_is_valid;
  116. has_timestamp = 1;
  117. prop_is_valid = ast_ari_validate_string(
  118. ast_json_object_iter_value(iter));
  119. if (!prop_is_valid) {
  120. ast_log(LOG_ERROR, "ARI AsteriskPing field timestamp failed validation\n");
  121. res = 0;
  122. }
  123. } else
  124. {
  125. ast_log(LOG_ERROR,
  126. "ARI AsteriskPing has undocumented field %s\n",
  127. ast_json_object_iter_key(iter));
  128. res = 0;
  129. }
  130. }
  131. if (!has_asterisk_id) {
  132. ast_log(LOG_ERROR, "ARI AsteriskPing missing required field asterisk_id\n");
  133. res = 0;
  134. }
  135. if (!has_ping) {
  136. ast_log(LOG_ERROR, "ARI AsteriskPing missing required field ping\n");
  137. res = 0;
  138. }
  139. if (!has_timestamp) {
  140. ast_log(LOG_ERROR, "ARI AsteriskPing missing required field timestamp\n");
  141. res = 0;
  142. }
  143. return res;
  144. }
  145. ari_validator ast_ari_validate_asterisk_ping_fn(void)
  146. {
  147. return ast_ari_validate_asterisk_ping;
  148. }
  149. int ast_ari_validate_build_info(struct ast_json *json)
  150. {
  151. int res = 1;
  152. struct ast_json_iter *iter;
  153. int has_date = 0;
  154. int has_kernel = 0;
  155. int has_machine = 0;
  156. int has_options = 0;
  157. int has_os = 0;
  158. int has_user = 0;
  159. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  160. if (strcmp("date", ast_json_object_iter_key(iter)) == 0) {
  161. int prop_is_valid;
  162. has_date = 1;
  163. prop_is_valid = ast_ari_validate_string(
  164. ast_json_object_iter_value(iter));
  165. if (!prop_is_valid) {
  166. ast_log(LOG_ERROR, "ARI BuildInfo field date failed validation\n");
  167. res = 0;
  168. }
  169. } else
  170. if (strcmp("kernel", ast_json_object_iter_key(iter)) == 0) {
  171. int prop_is_valid;
  172. has_kernel = 1;
  173. prop_is_valid = ast_ari_validate_string(
  174. ast_json_object_iter_value(iter));
  175. if (!prop_is_valid) {
  176. ast_log(LOG_ERROR, "ARI BuildInfo field kernel failed validation\n");
  177. res = 0;
  178. }
  179. } else
  180. if (strcmp("machine", ast_json_object_iter_key(iter)) == 0) {
  181. int prop_is_valid;
  182. has_machine = 1;
  183. prop_is_valid = ast_ari_validate_string(
  184. ast_json_object_iter_value(iter));
  185. if (!prop_is_valid) {
  186. ast_log(LOG_ERROR, "ARI BuildInfo field machine failed validation\n");
  187. res = 0;
  188. }
  189. } else
  190. if (strcmp("options", ast_json_object_iter_key(iter)) == 0) {
  191. int prop_is_valid;
  192. has_options = 1;
  193. prop_is_valid = ast_ari_validate_string(
  194. ast_json_object_iter_value(iter));
  195. if (!prop_is_valid) {
  196. ast_log(LOG_ERROR, "ARI BuildInfo field options failed validation\n");
  197. res = 0;
  198. }
  199. } else
  200. if (strcmp("os", ast_json_object_iter_key(iter)) == 0) {
  201. int prop_is_valid;
  202. has_os = 1;
  203. prop_is_valid = ast_ari_validate_string(
  204. ast_json_object_iter_value(iter));
  205. if (!prop_is_valid) {
  206. ast_log(LOG_ERROR, "ARI BuildInfo field os failed validation\n");
  207. res = 0;
  208. }
  209. } else
  210. if (strcmp("user", ast_json_object_iter_key(iter)) == 0) {
  211. int prop_is_valid;
  212. has_user = 1;
  213. prop_is_valid = ast_ari_validate_string(
  214. ast_json_object_iter_value(iter));
  215. if (!prop_is_valid) {
  216. ast_log(LOG_ERROR, "ARI BuildInfo field user failed validation\n");
  217. res = 0;
  218. }
  219. } else
  220. {
  221. ast_log(LOG_ERROR,
  222. "ARI BuildInfo has undocumented field %s\n",
  223. ast_json_object_iter_key(iter));
  224. res = 0;
  225. }
  226. }
  227. if (!has_date) {
  228. ast_log(LOG_ERROR, "ARI BuildInfo missing required field date\n");
  229. res = 0;
  230. }
  231. if (!has_kernel) {
  232. ast_log(LOG_ERROR, "ARI BuildInfo missing required field kernel\n");
  233. res = 0;
  234. }
  235. if (!has_machine) {
  236. ast_log(LOG_ERROR, "ARI BuildInfo missing required field machine\n");
  237. res = 0;
  238. }
  239. if (!has_options) {
  240. ast_log(LOG_ERROR, "ARI BuildInfo missing required field options\n");
  241. res = 0;
  242. }
  243. if (!has_os) {
  244. ast_log(LOG_ERROR, "ARI BuildInfo missing required field os\n");
  245. res = 0;
  246. }
  247. if (!has_user) {
  248. ast_log(LOG_ERROR, "ARI BuildInfo missing required field user\n");
  249. res = 0;
  250. }
  251. return res;
  252. }
  253. ari_validator ast_ari_validate_build_info_fn(void)
  254. {
  255. return ast_ari_validate_build_info;
  256. }
  257. int ast_ari_validate_config_info(struct ast_json *json)
  258. {
  259. int res = 1;
  260. struct ast_json_iter *iter;
  261. int has_default_language = 0;
  262. int has_name = 0;
  263. int has_setid = 0;
  264. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  265. if (strcmp("default_language", ast_json_object_iter_key(iter)) == 0) {
  266. int prop_is_valid;
  267. has_default_language = 1;
  268. prop_is_valid = ast_ari_validate_string(
  269. ast_json_object_iter_value(iter));
  270. if (!prop_is_valid) {
  271. ast_log(LOG_ERROR, "ARI ConfigInfo field default_language failed validation\n");
  272. res = 0;
  273. }
  274. } else
  275. if (strcmp("max_channels", ast_json_object_iter_key(iter)) == 0) {
  276. int prop_is_valid;
  277. prop_is_valid = ast_ari_validate_int(
  278. ast_json_object_iter_value(iter));
  279. if (!prop_is_valid) {
  280. ast_log(LOG_ERROR, "ARI ConfigInfo field max_channels failed validation\n");
  281. res = 0;
  282. }
  283. } else
  284. if (strcmp("max_load", ast_json_object_iter_key(iter)) == 0) {
  285. int prop_is_valid;
  286. prop_is_valid = ast_ari_validate_double(
  287. ast_json_object_iter_value(iter));
  288. if (!prop_is_valid) {
  289. ast_log(LOG_ERROR, "ARI ConfigInfo field max_load failed validation\n");
  290. res = 0;
  291. }
  292. } else
  293. if (strcmp("max_open_files", ast_json_object_iter_key(iter)) == 0) {
  294. int prop_is_valid;
  295. prop_is_valid = ast_ari_validate_int(
  296. ast_json_object_iter_value(iter));
  297. if (!prop_is_valid) {
  298. ast_log(LOG_ERROR, "ARI ConfigInfo field max_open_files failed validation\n");
  299. res = 0;
  300. }
  301. } else
  302. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  303. int prop_is_valid;
  304. has_name = 1;
  305. prop_is_valid = ast_ari_validate_string(
  306. ast_json_object_iter_value(iter));
  307. if (!prop_is_valid) {
  308. ast_log(LOG_ERROR, "ARI ConfigInfo field name failed validation\n");
  309. res = 0;
  310. }
  311. } else
  312. if (strcmp("setid", ast_json_object_iter_key(iter)) == 0) {
  313. int prop_is_valid;
  314. has_setid = 1;
  315. prop_is_valid = ast_ari_validate_set_id(
  316. ast_json_object_iter_value(iter));
  317. if (!prop_is_valid) {
  318. ast_log(LOG_ERROR, "ARI ConfigInfo field setid failed validation\n");
  319. res = 0;
  320. }
  321. } else
  322. {
  323. ast_log(LOG_ERROR,
  324. "ARI ConfigInfo has undocumented field %s\n",
  325. ast_json_object_iter_key(iter));
  326. res = 0;
  327. }
  328. }
  329. if (!has_default_language) {
  330. ast_log(LOG_ERROR, "ARI ConfigInfo missing required field default_language\n");
  331. res = 0;
  332. }
  333. if (!has_name) {
  334. ast_log(LOG_ERROR, "ARI ConfigInfo missing required field name\n");
  335. res = 0;
  336. }
  337. if (!has_setid) {
  338. ast_log(LOG_ERROR, "ARI ConfigInfo missing required field setid\n");
  339. res = 0;
  340. }
  341. return res;
  342. }
  343. ari_validator ast_ari_validate_config_info_fn(void)
  344. {
  345. return ast_ari_validate_config_info;
  346. }
  347. int ast_ari_validate_config_tuple(struct ast_json *json)
  348. {
  349. int res = 1;
  350. struct ast_json_iter *iter;
  351. int has_attribute = 0;
  352. int has_value = 0;
  353. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  354. if (strcmp("attribute", ast_json_object_iter_key(iter)) == 0) {
  355. int prop_is_valid;
  356. has_attribute = 1;
  357. prop_is_valid = ast_ari_validate_string(
  358. ast_json_object_iter_value(iter));
  359. if (!prop_is_valid) {
  360. ast_log(LOG_ERROR, "ARI ConfigTuple field attribute failed validation\n");
  361. res = 0;
  362. }
  363. } else
  364. if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
  365. int prop_is_valid;
  366. has_value = 1;
  367. prop_is_valid = ast_ari_validate_string(
  368. ast_json_object_iter_value(iter));
  369. if (!prop_is_valid) {
  370. ast_log(LOG_ERROR, "ARI ConfigTuple field value failed validation\n");
  371. res = 0;
  372. }
  373. } else
  374. {
  375. ast_log(LOG_ERROR,
  376. "ARI ConfigTuple has undocumented field %s\n",
  377. ast_json_object_iter_key(iter));
  378. res = 0;
  379. }
  380. }
  381. if (!has_attribute) {
  382. ast_log(LOG_ERROR, "ARI ConfigTuple missing required field attribute\n");
  383. res = 0;
  384. }
  385. if (!has_value) {
  386. ast_log(LOG_ERROR, "ARI ConfigTuple missing required field value\n");
  387. res = 0;
  388. }
  389. return res;
  390. }
  391. ari_validator ast_ari_validate_config_tuple_fn(void)
  392. {
  393. return ast_ari_validate_config_tuple;
  394. }
  395. int ast_ari_validate_log_channel(struct ast_json *json)
  396. {
  397. int res = 1;
  398. struct ast_json_iter *iter;
  399. int has_channel = 0;
  400. int has_configuration = 0;
  401. int has_status = 0;
  402. int has_type = 0;
  403. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  404. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  405. int prop_is_valid;
  406. has_channel = 1;
  407. prop_is_valid = ast_ari_validate_string(
  408. ast_json_object_iter_value(iter));
  409. if (!prop_is_valid) {
  410. ast_log(LOG_ERROR, "ARI LogChannel field channel failed validation\n");
  411. res = 0;
  412. }
  413. } else
  414. if (strcmp("configuration", ast_json_object_iter_key(iter)) == 0) {
  415. int prop_is_valid;
  416. has_configuration = 1;
  417. prop_is_valid = ast_ari_validate_string(
  418. ast_json_object_iter_value(iter));
  419. if (!prop_is_valid) {
  420. ast_log(LOG_ERROR, "ARI LogChannel field configuration failed validation\n");
  421. res = 0;
  422. }
  423. } else
  424. if (strcmp("status", ast_json_object_iter_key(iter)) == 0) {
  425. int prop_is_valid;
  426. has_status = 1;
  427. prop_is_valid = ast_ari_validate_string(
  428. ast_json_object_iter_value(iter));
  429. if (!prop_is_valid) {
  430. ast_log(LOG_ERROR, "ARI LogChannel field status failed validation\n");
  431. res = 0;
  432. }
  433. } else
  434. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  435. int prop_is_valid;
  436. has_type = 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 LogChannel field type failed validation\n");
  441. res = 0;
  442. }
  443. } else
  444. {
  445. ast_log(LOG_ERROR,
  446. "ARI LogChannel has undocumented field %s\n",
  447. ast_json_object_iter_key(iter));
  448. res = 0;
  449. }
  450. }
  451. if (!has_channel) {
  452. ast_log(LOG_ERROR, "ARI LogChannel missing required field channel\n");
  453. res = 0;
  454. }
  455. if (!has_configuration) {
  456. ast_log(LOG_ERROR, "ARI LogChannel missing required field configuration\n");
  457. res = 0;
  458. }
  459. if (!has_status) {
  460. ast_log(LOG_ERROR, "ARI LogChannel missing required field status\n");
  461. res = 0;
  462. }
  463. if (!has_type) {
  464. ast_log(LOG_ERROR, "ARI LogChannel missing required field type\n");
  465. res = 0;
  466. }
  467. return res;
  468. }
  469. ari_validator ast_ari_validate_log_channel_fn(void)
  470. {
  471. return ast_ari_validate_log_channel;
  472. }
  473. int ast_ari_validate_module(struct ast_json *json)
  474. {
  475. int res = 1;
  476. struct ast_json_iter *iter;
  477. int has_description = 0;
  478. int has_name = 0;
  479. int has_status = 0;
  480. int has_support_level = 0;
  481. int has_use_count = 0;
  482. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  483. if (strcmp("description", ast_json_object_iter_key(iter)) == 0) {
  484. int prop_is_valid;
  485. has_description = 1;
  486. prop_is_valid = ast_ari_validate_string(
  487. ast_json_object_iter_value(iter));
  488. if (!prop_is_valid) {
  489. ast_log(LOG_ERROR, "ARI Module field description failed validation\n");
  490. res = 0;
  491. }
  492. } else
  493. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  494. int prop_is_valid;
  495. has_name = 1;
  496. prop_is_valid = ast_ari_validate_string(
  497. ast_json_object_iter_value(iter));
  498. if (!prop_is_valid) {
  499. ast_log(LOG_ERROR, "ARI Module field name failed validation\n");
  500. res = 0;
  501. }
  502. } else
  503. if (strcmp("status", ast_json_object_iter_key(iter)) == 0) {
  504. int prop_is_valid;
  505. has_status = 1;
  506. prop_is_valid = ast_ari_validate_string(
  507. ast_json_object_iter_value(iter));
  508. if (!prop_is_valid) {
  509. ast_log(LOG_ERROR, "ARI Module field status failed validation\n");
  510. res = 0;
  511. }
  512. } else
  513. if (strcmp("support_level", ast_json_object_iter_key(iter)) == 0) {
  514. int prop_is_valid;
  515. has_support_level = 1;
  516. prop_is_valid = ast_ari_validate_string(
  517. ast_json_object_iter_value(iter));
  518. if (!prop_is_valid) {
  519. ast_log(LOG_ERROR, "ARI Module field support_level failed validation\n");
  520. res = 0;
  521. }
  522. } else
  523. if (strcmp("use_count", ast_json_object_iter_key(iter)) == 0) {
  524. int prop_is_valid;
  525. has_use_count = 1;
  526. prop_is_valid = ast_ari_validate_int(
  527. ast_json_object_iter_value(iter));
  528. if (!prop_is_valid) {
  529. ast_log(LOG_ERROR, "ARI Module field use_count failed validation\n");
  530. res = 0;
  531. }
  532. } else
  533. {
  534. ast_log(LOG_ERROR,
  535. "ARI Module has undocumented field %s\n",
  536. ast_json_object_iter_key(iter));
  537. res = 0;
  538. }
  539. }
  540. if (!has_description) {
  541. ast_log(LOG_ERROR, "ARI Module missing required field description\n");
  542. res = 0;
  543. }
  544. if (!has_name) {
  545. ast_log(LOG_ERROR, "ARI Module missing required field name\n");
  546. res = 0;
  547. }
  548. if (!has_status) {
  549. ast_log(LOG_ERROR, "ARI Module missing required field status\n");
  550. res = 0;
  551. }
  552. if (!has_support_level) {
  553. ast_log(LOG_ERROR, "ARI Module missing required field support_level\n");
  554. res = 0;
  555. }
  556. if (!has_use_count) {
  557. ast_log(LOG_ERROR, "ARI Module missing required field use_count\n");
  558. res = 0;
  559. }
  560. return res;
  561. }
  562. ari_validator ast_ari_validate_module_fn(void)
  563. {
  564. return ast_ari_validate_module;
  565. }
  566. int ast_ari_validate_set_id(struct ast_json *json)
  567. {
  568. int res = 1;
  569. struct ast_json_iter *iter;
  570. int has_group = 0;
  571. int has_user = 0;
  572. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  573. if (strcmp("group", ast_json_object_iter_key(iter)) == 0) {
  574. int prop_is_valid;
  575. has_group = 1;
  576. prop_is_valid = ast_ari_validate_string(
  577. ast_json_object_iter_value(iter));
  578. if (!prop_is_valid) {
  579. ast_log(LOG_ERROR, "ARI SetId field group failed validation\n");
  580. res = 0;
  581. }
  582. } else
  583. if (strcmp("user", ast_json_object_iter_key(iter)) == 0) {
  584. int prop_is_valid;
  585. has_user = 1;
  586. prop_is_valid = ast_ari_validate_string(
  587. ast_json_object_iter_value(iter));
  588. if (!prop_is_valid) {
  589. ast_log(LOG_ERROR, "ARI SetId field user failed validation\n");
  590. res = 0;
  591. }
  592. } else
  593. {
  594. ast_log(LOG_ERROR,
  595. "ARI SetId has undocumented field %s\n",
  596. ast_json_object_iter_key(iter));
  597. res = 0;
  598. }
  599. }
  600. if (!has_group) {
  601. ast_log(LOG_ERROR, "ARI SetId missing required field group\n");
  602. res = 0;
  603. }
  604. if (!has_user) {
  605. ast_log(LOG_ERROR, "ARI SetId missing required field user\n");
  606. res = 0;
  607. }
  608. return res;
  609. }
  610. ari_validator ast_ari_validate_set_id_fn(void)
  611. {
  612. return ast_ari_validate_set_id;
  613. }
  614. int ast_ari_validate_status_info(struct ast_json *json)
  615. {
  616. int res = 1;
  617. struct ast_json_iter *iter;
  618. int has_last_reload_time = 0;
  619. int has_startup_time = 0;
  620. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  621. if (strcmp("last_reload_time", ast_json_object_iter_key(iter)) == 0) {
  622. int prop_is_valid;
  623. has_last_reload_time = 1;
  624. prop_is_valid = ast_ari_validate_date(
  625. ast_json_object_iter_value(iter));
  626. if (!prop_is_valid) {
  627. ast_log(LOG_ERROR, "ARI StatusInfo field last_reload_time failed validation\n");
  628. res = 0;
  629. }
  630. } else
  631. if (strcmp("startup_time", ast_json_object_iter_key(iter)) == 0) {
  632. int prop_is_valid;
  633. has_startup_time = 1;
  634. prop_is_valid = ast_ari_validate_date(
  635. ast_json_object_iter_value(iter));
  636. if (!prop_is_valid) {
  637. ast_log(LOG_ERROR, "ARI StatusInfo field startup_time failed validation\n");
  638. res = 0;
  639. }
  640. } else
  641. {
  642. ast_log(LOG_ERROR,
  643. "ARI StatusInfo has undocumented field %s\n",
  644. ast_json_object_iter_key(iter));
  645. res = 0;
  646. }
  647. }
  648. if (!has_last_reload_time) {
  649. ast_log(LOG_ERROR, "ARI StatusInfo missing required field last_reload_time\n");
  650. res = 0;
  651. }
  652. if (!has_startup_time) {
  653. ast_log(LOG_ERROR, "ARI StatusInfo missing required field startup_time\n");
  654. res = 0;
  655. }
  656. return res;
  657. }
  658. ari_validator ast_ari_validate_status_info_fn(void)
  659. {
  660. return ast_ari_validate_status_info;
  661. }
  662. int ast_ari_validate_system_info(struct ast_json *json)
  663. {
  664. int res = 1;
  665. struct ast_json_iter *iter;
  666. int has_entity_id = 0;
  667. int has_version = 0;
  668. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  669. if (strcmp("entity_id", ast_json_object_iter_key(iter)) == 0) {
  670. int prop_is_valid;
  671. has_entity_id = 1;
  672. prop_is_valid = ast_ari_validate_string(
  673. ast_json_object_iter_value(iter));
  674. if (!prop_is_valid) {
  675. ast_log(LOG_ERROR, "ARI SystemInfo field entity_id failed validation\n");
  676. res = 0;
  677. }
  678. } else
  679. if (strcmp("version", ast_json_object_iter_key(iter)) == 0) {
  680. int prop_is_valid;
  681. has_version = 1;
  682. prop_is_valid = ast_ari_validate_string(
  683. ast_json_object_iter_value(iter));
  684. if (!prop_is_valid) {
  685. ast_log(LOG_ERROR, "ARI SystemInfo field version failed validation\n");
  686. res = 0;
  687. }
  688. } else
  689. {
  690. ast_log(LOG_ERROR,
  691. "ARI SystemInfo has undocumented field %s\n",
  692. ast_json_object_iter_key(iter));
  693. res = 0;
  694. }
  695. }
  696. if (!has_entity_id) {
  697. ast_log(LOG_ERROR, "ARI SystemInfo missing required field entity_id\n");
  698. res = 0;
  699. }
  700. if (!has_version) {
  701. ast_log(LOG_ERROR, "ARI SystemInfo missing required field version\n");
  702. res = 0;
  703. }
  704. return res;
  705. }
  706. ari_validator ast_ari_validate_system_info_fn(void)
  707. {
  708. return ast_ari_validate_system_info;
  709. }
  710. int ast_ari_validate_variable(struct ast_json *json)
  711. {
  712. int res = 1;
  713. struct ast_json_iter *iter;
  714. int has_value = 0;
  715. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  716. if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
  717. int prop_is_valid;
  718. has_value = 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 Variable field value failed validation\n");
  723. res = 0;
  724. }
  725. } else
  726. {
  727. ast_log(LOG_ERROR,
  728. "ARI Variable has undocumented field %s\n",
  729. ast_json_object_iter_key(iter));
  730. res = 0;
  731. }
  732. }
  733. if (!has_value) {
  734. ast_log(LOG_ERROR, "ARI Variable missing required field value\n");
  735. res = 0;
  736. }
  737. return res;
  738. }
  739. ari_validator ast_ari_validate_variable_fn(void)
  740. {
  741. return ast_ari_validate_variable;
  742. }
  743. int ast_ari_validate_endpoint(struct ast_json *json)
  744. {
  745. int res = 1;
  746. struct ast_json_iter *iter;
  747. int has_channel_ids = 0;
  748. int has_resource = 0;
  749. int has_technology = 0;
  750. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  751. if (strcmp("channel_ids", ast_json_object_iter_key(iter)) == 0) {
  752. int prop_is_valid;
  753. has_channel_ids = 1;
  754. prop_is_valid = ast_ari_validate_list(
  755. ast_json_object_iter_value(iter),
  756. ast_ari_validate_string);
  757. if (!prop_is_valid) {
  758. ast_log(LOG_ERROR, "ARI Endpoint field channel_ids failed validation\n");
  759. res = 0;
  760. }
  761. } else
  762. if (strcmp("resource", ast_json_object_iter_key(iter)) == 0) {
  763. int prop_is_valid;
  764. has_resource = 1;
  765. prop_is_valid = ast_ari_validate_string(
  766. ast_json_object_iter_value(iter));
  767. if (!prop_is_valid) {
  768. ast_log(LOG_ERROR, "ARI Endpoint field resource failed validation\n");
  769. res = 0;
  770. }
  771. } else
  772. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  773. int prop_is_valid;
  774. prop_is_valid = ast_ari_validate_string(
  775. ast_json_object_iter_value(iter));
  776. if (!prop_is_valid) {
  777. ast_log(LOG_ERROR, "ARI Endpoint field state failed validation\n");
  778. res = 0;
  779. }
  780. } else
  781. if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
  782. int prop_is_valid;
  783. has_technology = 1;
  784. prop_is_valid = ast_ari_validate_string(
  785. ast_json_object_iter_value(iter));
  786. if (!prop_is_valid) {
  787. ast_log(LOG_ERROR, "ARI Endpoint field technology failed validation\n");
  788. res = 0;
  789. }
  790. } else
  791. {
  792. ast_log(LOG_ERROR,
  793. "ARI Endpoint has undocumented field %s\n",
  794. ast_json_object_iter_key(iter));
  795. res = 0;
  796. }
  797. }
  798. if (!has_channel_ids) {
  799. ast_log(LOG_ERROR, "ARI Endpoint missing required field channel_ids\n");
  800. res = 0;
  801. }
  802. if (!has_resource) {
  803. ast_log(LOG_ERROR, "ARI Endpoint missing required field resource\n");
  804. res = 0;
  805. }
  806. if (!has_technology) {
  807. ast_log(LOG_ERROR, "ARI Endpoint missing required field technology\n");
  808. res = 0;
  809. }
  810. return res;
  811. }
  812. ari_validator ast_ari_validate_endpoint_fn(void)
  813. {
  814. return ast_ari_validate_endpoint;
  815. }
  816. int ast_ari_validate_text_message(struct ast_json *json)
  817. {
  818. int res = 1;
  819. struct ast_json_iter *iter;
  820. int has_body = 0;
  821. int has_from = 0;
  822. int has_to = 0;
  823. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  824. if (strcmp("body", ast_json_object_iter_key(iter)) == 0) {
  825. int prop_is_valid;
  826. has_body = 1;
  827. prop_is_valid = ast_ari_validate_string(
  828. ast_json_object_iter_value(iter));
  829. if (!prop_is_valid) {
  830. ast_log(LOG_ERROR, "ARI TextMessage field body failed validation\n");
  831. res = 0;
  832. }
  833. } else
  834. if (strcmp("from", ast_json_object_iter_key(iter)) == 0) {
  835. int prop_is_valid;
  836. has_from = 1;
  837. prop_is_valid = ast_ari_validate_string(
  838. ast_json_object_iter_value(iter));
  839. if (!prop_is_valid) {
  840. ast_log(LOG_ERROR, "ARI TextMessage field from failed validation\n");
  841. res = 0;
  842. }
  843. } else
  844. if (strcmp("to", ast_json_object_iter_key(iter)) == 0) {
  845. int prop_is_valid;
  846. has_to = 1;
  847. prop_is_valid = ast_ari_validate_string(
  848. ast_json_object_iter_value(iter));
  849. if (!prop_is_valid) {
  850. ast_log(LOG_ERROR, "ARI TextMessage field to failed validation\n");
  851. res = 0;
  852. }
  853. } else
  854. if (strcmp("variables", ast_json_object_iter_key(iter)) == 0) {
  855. int prop_is_valid;
  856. prop_is_valid = ast_ari_validate_list(
  857. ast_json_object_iter_value(iter),
  858. ast_ari_validate_text_message_variable);
  859. if (!prop_is_valid) {
  860. ast_log(LOG_ERROR, "ARI TextMessage field variables failed validation\n");
  861. res = 0;
  862. }
  863. } else
  864. {
  865. ast_log(LOG_ERROR,
  866. "ARI TextMessage has undocumented field %s\n",
  867. ast_json_object_iter_key(iter));
  868. res = 0;
  869. }
  870. }
  871. if (!has_body) {
  872. ast_log(LOG_ERROR, "ARI TextMessage missing required field body\n");
  873. res = 0;
  874. }
  875. if (!has_from) {
  876. ast_log(LOG_ERROR, "ARI TextMessage missing required field from\n");
  877. res = 0;
  878. }
  879. if (!has_to) {
  880. ast_log(LOG_ERROR, "ARI TextMessage missing required field to\n");
  881. res = 0;
  882. }
  883. return res;
  884. }
  885. ari_validator ast_ari_validate_text_message_fn(void)
  886. {
  887. return ast_ari_validate_text_message;
  888. }
  889. int ast_ari_validate_text_message_variable(struct ast_json *json)
  890. {
  891. int res = 1;
  892. struct ast_json_iter *iter;
  893. int has_key = 0;
  894. int has_value = 0;
  895. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  896. if (strcmp("key", ast_json_object_iter_key(iter)) == 0) {
  897. int prop_is_valid;
  898. has_key = 1;
  899. prop_is_valid = ast_ari_validate_string(
  900. ast_json_object_iter_value(iter));
  901. if (!prop_is_valid) {
  902. ast_log(LOG_ERROR, "ARI TextMessageVariable field key failed validation\n");
  903. res = 0;
  904. }
  905. } else
  906. if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
  907. int prop_is_valid;
  908. has_value = 1;
  909. prop_is_valid = ast_ari_validate_string(
  910. ast_json_object_iter_value(iter));
  911. if (!prop_is_valid) {
  912. ast_log(LOG_ERROR, "ARI TextMessageVariable field value failed validation\n");
  913. res = 0;
  914. }
  915. } else
  916. {
  917. ast_log(LOG_ERROR,
  918. "ARI TextMessageVariable has undocumented field %s\n",
  919. ast_json_object_iter_key(iter));
  920. res = 0;
  921. }
  922. }
  923. if (!has_key) {
  924. ast_log(LOG_ERROR, "ARI TextMessageVariable missing required field key\n");
  925. res = 0;
  926. }
  927. if (!has_value) {
  928. ast_log(LOG_ERROR, "ARI TextMessageVariable missing required field value\n");
  929. res = 0;
  930. }
  931. return res;
  932. }
  933. ari_validator ast_ari_validate_text_message_variable_fn(void)
  934. {
  935. return ast_ari_validate_text_message_variable;
  936. }
  937. int ast_ari_validate_caller_id(struct ast_json *json)
  938. {
  939. int res = 1;
  940. struct ast_json_iter *iter;
  941. int has_name = 0;
  942. int has_number = 0;
  943. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  944. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  945. int prop_is_valid;
  946. has_name = 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 CallerID field name failed validation\n");
  951. res = 0;
  952. }
  953. } else
  954. if (strcmp("number", ast_json_object_iter_key(iter)) == 0) {
  955. int prop_is_valid;
  956. has_number = 1;
  957. prop_is_valid = ast_ari_validate_string(
  958. ast_json_object_iter_value(iter));
  959. if (!prop_is_valid) {
  960. ast_log(LOG_ERROR, "ARI CallerID field number failed validation\n");
  961. res = 0;
  962. }
  963. } else
  964. {
  965. ast_log(LOG_ERROR,
  966. "ARI CallerID has undocumented field %s\n",
  967. ast_json_object_iter_key(iter));
  968. res = 0;
  969. }
  970. }
  971. if (!has_name) {
  972. ast_log(LOG_ERROR, "ARI CallerID missing required field name\n");
  973. res = 0;
  974. }
  975. if (!has_number) {
  976. ast_log(LOG_ERROR, "ARI CallerID missing required field number\n");
  977. res = 0;
  978. }
  979. return res;
  980. }
  981. ari_validator ast_ari_validate_caller_id_fn(void)
  982. {
  983. return ast_ari_validate_caller_id;
  984. }
  985. int ast_ari_validate_channel(struct ast_json *json)
  986. {
  987. int res = 1;
  988. struct ast_json_iter *iter;
  989. int has_accountcode = 0;
  990. int has_caller = 0;
  991. int has_connected = 0;
  992. int has_creationtime = 0;
  993. int has_dialplan = 0;
  994. int has_id = 0;
  995. int has_language = 0;
  996. int has_name = 0;
  997. int has_state = 0;
  998. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  999. if (strcmp("accountcode", ast_json_object_iter_key(iter)) == 0) {
  1000. int prop_is_valid;
  1001. has_accountcode = 1;
  1002. prop_is_valid = ast_ari_validate_string(
  1003. ast_json_object_iter_value(iter));
  1004. if (!prop_is_valid) {
  1005. ast_log(LOG_ERROR, "ARI Channel field accountcode failed validation\n");
  1006. res = 0;
  1007. }
  1008. } else
  1009. if (strcmp("caller", ast_json_object_iter_key(iter)) == 0) {
  1010. int prop_is_valid;
  1011. has_caller = 1;
  1012. prop_is_valid = ast_ari_validate_caller_id(
  1013. ast_json_object_iter_value(iter));
  1014. if (!prop_is_valid) {
  1015. ast_log(LOG_ERROR, "ARI Channel field caller failed validation\n");
  1016. res = 0;
  1017. }
  1018. } else
  1019. if (strcmp("connected", ast_json_object_iter_key(iter)) == 0) {
  1020. int prop_is_valid;
  1021. has_connected = 1;
  1022. prop_is_valid = ast_ari_validate_caller_id(
  1023. ast_json_object_iter_value(iter));
  1024. if (!prop_is_valid) {
  1025. ast_log(LOG_ERROR, "ARI Channel field connected failed validation\n");
  1026. res = 0;
  1027. }
  1028. } else
  1029. if (strcmp("creationtime", ast_json_object_iter_key(iter)) == 0) {
  1030. int prop_is_valid;
  1031. has_creationtime = 1;
  1032. prop_is_valid = ast_ari_validate_date(
  1033. ast_json_object_iter_value(iter));
  1034. if (!prop_is_valid) {
  1035. ast_log(LOG_ERROR, "ARI Channel field creationtime failed validation\n");
  1036. res = 0;
  1037. }
  1038. } else
  1039. if (strcmp("dialplan", ast_json_object_iter_key(iter)) == 0) {
  1040. int prop_is_valid;
  1041. has_dialplan = 1;
  1042. prop_is_valid = ast_ari_validate_dialplan_cep(
  1043. ast_json_object_iter_value(iter));
  1044. if (!prop_is_valid) {
  1045. ast_log(LOG_ERROR, "ARI Channel field dialplan failed validation\n");
  1046. res = 0;
  1047. }
  1048. } else
  1049. if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
  1050. int prop_is_valid;
  1051. has_id = 1;
  1052. prop_is_valid = ast_ari_validate_string(
  1053. ast_json_object_iter_value(iter));
  1054. if (!prop_is_valid) {
  1055. ast_log(LOG_ERROR, "ARI Channel field id failed validation\n");
  1056. res = 0;
  1057. }
  1058. } else
  1059. if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
  1060. int prop_is_valid;
  1061. has_language = 1;
  1062. prop_is_valid = ast_ari_validate_string(
  1063. ast_json_object_iter_value(iter));
  1064. if (!prop_is_valid) {
  1065. ast_log(LOG_ERROR, "ARI Channel field language failed validation\n");
  1066. res = 0;
  1067. }
  1068. } else
  1069. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1070. int prop_is_valid;
  1071. has_name = 1;
  1072. prop_is_valid = ast_ari_validate_string(
  1073. ast_json_object_iter_value(iter));
  1074. if (!prop_is_valid) {
  1075. ast_log(LOG_ERROR, "ARI Channel field name failed validation\n");
  1076. res = 0;
  1077. }
  1078. } else
  1079. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  1080. int prop_is_valid;
  1081. has_state = 1;
  1082. prop_is_valid = ast_ari_validate_string(
  1083. ast_json_object_iter_value(iter));
  1084. if (!prop_is_valid) {
  1085. ast_log(LOG_ERROR, "ARI Channel field state failed validation\n");
  1086. res = 0;
  1087. }
  1088. } else
  1089. {
  1090. ast_log(LOG_ERROR,
  1091. "ARI Channel has undocumented field %s\n",
  1092. ast_json_object_iter_key(iter));
  1093. res = 0;
  1094. }
  1095. }
  1096. if (!has_accountcode) {
  1097. ast_log(LOG_ERROR, "ARI Channel missing required field accountcode\n");
  1098. res = 0;
  1099. }
  1100. if (!has_caller) {
  1101. ast_log(LOG_ERROR, "ARI Channel missing required field caller\n");
  1102. res = 0;
  1103. }
  1104. if (!has_connected) {
  1105. ast_log(LOG_ERROR, "ARI Channel missing required field connected\n");
  1106. res = 0;
  1107. }
  1108. if (!has_creationtime) {
  1109. ast_log(LOG_ERROR, "ARI Channel missing required field creationtime\n");
  1110. res = 0;
  1111. }
  1112. if (!has_dialplan) {
  1113. ast_log(LOG_ERROR, "ARI Channel missing required field dialplan\n");
  1114. res = 0;
  1115. }
  1116. if (!has_id) {
  1117. ast_log(LOG_ERROR, "ARI Channel missing required field id\n");
  1118. res = 0;
  1119. }
  1120. if (!has_language) {
  1121. ast_log(LOG_ERROR, "ARI Channel missing required field language\n");
  1122. res = 0;
  1123. }
  1124. if (!has_name) {
  1125. ast_log(LOG_ERROR, "ARI Channel missing required field name\n");
  1126. res = 0;
  1127. }
  1128. if (!has_state) {
  1129. ast_log(LOG_ERROR, "ARI Channel missing required field state\n");
  1130. res = 0;
  1131. }
  1132. return res;
  1133. }
  1134. ari_validator ast_ari_validate_channel_fn(void)
  1135. {
  1136. return ast_ari_validate_channel;
  1137. }
  1138. int ast_ari_validate_dialed(struct ast_json *json)
  1139. {
  1140. int res = 1;
  1141. struct ast_json_iter *iter;
  1142. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1143. {
  1144. ast_log(LOG_ERROR,
  1145. "ARI Dialed has undocumented field %s\n",
  1146. ast_json_object_iter_key(iter));
  1147. res = 0;
  1148. }
  1149. }
  1150. return res;
  1151. }
  1152. ari_validator ast_ari_validate_dialed_fn(void)
  1153. {
  1154. return ast_ari_validate_dialed;
  1155. }
  1156. int ast_ari_validate_dialplan_cep(struct ast_json *json)
  1157. {
  1158. int res = 1;
  1159. struct ast_json_iter *iter;
  1160. int has_context = 0;
  1161. int has_exten = 0;
  1162. int has_priority = 0;
  1163. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1164. if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
  1165. int prop_is_valid;
  1166. has_context = 1;
  1167. prop_is_valid = ast_ari_validate_string(
  1168. ast_json_object_iter_value(iter));
  1169. if (!prop_is_valid) {
  1170. ast_log(LOG_ERROR, "ARI DialplanCEP field context failed validation\n");
  1171. res = 0;
  1172. }
  1173. } else
  1174. if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
  1175. int prop_is_valid;
  1176. has_exten = 1;
  1177. prop_is_valid = ast_ari_validate_string(
  1178. ast_json_object_iter_value(iter));
  1179. if (!prop_is_valid) {
  1180. ast_log(LOG_ERROR, "ARI DialplanCEP field exten failed validation\n");
  1181. res = 0;
  1182. }
  1183. } else
  1184. if (strcmp("priority", ast_json_object_iter_key(iter)) == 0) {
  1185. int prop_is_valid;
  1186. has_priority = 1;
  1187. prop_is_valid = ast_ari_validate_long(
  1188. ast_json_object_iter_value(iter));
  1189. if (!prop_is_valid) {
  1190. ast_log(LOG_ERROR, "ARI DialplanCEP field priority failed validation\n");
  1191. res = 0;
  1192. }
  1193. } else
  1194. {
  1195. ast_log(LOG_ERROR,
  1196. "ARI DialplanCEP has undocumented field %s\n",
  1197. ast_json_object_iter_key(iter));
  1198. res = 0;
  1199. }
  1200. }
  1201. if (!has_context) {
  1202. ast_log(LOG_ERROR, "ARI DialplanCEP missing required field context\n");
  1203. res = 0;
  1204. }
  1205. if (!has_exten) {
  1206. ast_log(LOG_ERROR, "ARI DialplanCEP missing required field exten\n");
  1207. res = 0;
  1208. }
  1209. if (!has_priority) {
  1210. ast_log(LOG_ERROR, "ARI DialplanCEP missing required field priority\n");
  1211. res = 0;
  1212. }
  1213. return res;
  1214. }
  1215. ari_validator ast_ari_validate_dialplan_cep_fn(void)
  1216. {
  1217. return ast_ari_validate_dialplan_cep;
  1218. }
  1219. int ast_ari_validate_bridge(struct ast_json *json)
  1220. {
  1221. int res = 1;
  1222. struct ast_json_iter *iter;
  1223. int has_bridge_class = 0;
  1224. int has_bridge_type = 0;
  1225. int has_channels = 0;
  1226. int has_creator = 0;
  1227. int has_id = 0;
  1228. int has_name = 0;
  1229. int has_technology = 0;
  1230. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1231. if (strcmp("bridge_class", ast_json_object_iter_key(iter)) == 0) {
  1232. int prop_is_valid;
  1233. has_bridge_class = 1;
  1234. prop_is_valid = ast_ari_validate_string(
  1235. ast_json_object_iter_value(iter));
  1236. if (!prop_is_valid) {
  1237. ast_log(LOG_ERROR, "ARI Bridge field bridge_class failed validation\n");
  1238. res = 0;
  1239. }
  1240. } else
  1241. if (strcmp("bridge_type", ast_json_object_iter_key(iter)) == 0) {
  1242. int prop_is_valid;
  1243. has_bridge_type = 1;
  1244. prop_is_valid = ast_ari_validate_string(
  1245. ast_json_object_iter_value(iter));
  1246. if (!prop_is_valid) {
  1247. ast_log(LOG_ERROR, "ARI Bridge field bridge_type failed validation\n");
  1248. res = 0;
  1249. }
  1250. } else
  1251. if (strcmp("channels", ast_json_object_iter_key(iter)) == 0) {
  1252. int prop_is_valid;
  1253. has_channels = 1;
  1254. prop_is_valid = ast_ari_validate_list(
  1255. ast_json_object_iter_value(iter),
  1256. ast_ari_validate_string);
  1257. if (!prop_is_valid) {
  1258. ast_log(LOG_ERROR, "ARI Bridge field channels failed validation\n");
  1259. res = 0;
  1260. }
  1261. } else
  1262. if (strcmp("creator", ast_json_object_iter_key(iter)) == 0) {
  1263. int prop_is_valid;
  1264. has_creator = 1;
  1265. prop_is_valid = ast_ari_validate_string(
  1266. ast_json_object_iter_value(iter));
  1267. if (!prop_is_valid) {
  1268. ast_log(LOG_ERROR, "ARI Bridge field creator failed validation\n");
  1269. res = 0;
  1270. }
  1271. } else
  1272. if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
  1273. int prop_is_valid;
  1274. has_id = 1;
  1275. prop_is_valid = ast_ari_validate_string(
  1276. ast_json_object_iter_value(iter));
  1277. if (!prop_is_valid) {
  1278. ast_log(LOG_ERROR, "ARI Bridge field id failed validation\n");
  1279. res = 0;
  1280. }
  1281. } else
  1282. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1283. int prop_is_valid;
  1284. has_name = 1;
  1285. prop_is_valid = ast_ari_validate_string(
  1286. ast_json_object_iter_value(iter));
  1287. if (!prop_is_valid) {
  1288. ast_log(LOG_ERROR, "ARI Bridge field name failed validation\n");
  1289. res = 0;
  1290. }
  1291. } else
  1292. if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
  1293. int prop_is_valid;
  1294. has_technology = 1;
  1295. prop_is_valid = ast_ari_validate_string(
  1296. ast_json_object_iter_value(iter));
  1297. if (!prop_is_valid) {
  1298. ast_log(LOG_ERROR, "ARI Bridge field technology failed validation\n");
  1299. res = 0;
  1300. }
  1301. } else
  1302. if (strcmp("video_mode", ast_json_object_iter_key(iter)) == 0) {
  1303. int prop_is_valid;
  1304. prop_is_valid = ast_ari_validate_string(
  1305. ast_json_object_iter_value(iter));
  1306. if (!prop_is_valid) {
  1307. ast_log(LOG_ERROR, "ARI Bridge field video_mode failed validation\n");
  1308. res = 0;
  1309. }
  1310. } else
  1311. if (strcmp("video_source_id", ast_json_object_iter_key(iter)) == 0) {
  1312. int prop_is_valid;
  1313. prop_is_valid = ast_ari_validate_string(
  1314. ast_json_object_iter_value(iter));
  1315. if (!prop_is_valid) {
  1316. ast_log(LOG_ERROR, "ARI Bridge field video_source_id failed validation\n");
  1317. res = 0;
  1318. }
  1319. } else
  1320. {
  1321. ast_log(LOG_ERROR,
  1322. "ARI Bridge has undocumented field %s\n",
  1323. ast_json_object_iter_key(iter));
  1324. res = 0;
  1325. }
  1326. }
  1327. if (!has_bridge_class) {
  1328. ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_class\n");
  1329. res = 0;
  1330. }
  1331. if (!has_bridge_type) {
  1332. ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_type\n");
  1333. res = 0;
  1334. }
  1335. if (!has_channels) {
  1336. ast_log(LOG_ERROR, "ARI Bridge missing required field channels\n");
  1337. res = 0;
  1338. }
  1339. if (!has_creator) {
  1340. ast_log(LOG_ERROR, "ARI Bridge missing required field creator\n");
  1341. res = 0;
  1342. }
  1343. if (!has_id) {
  1344. ast_log(LOG_ERROR, "ARI Bridge missing required field id\n");
  1345. res = 0;
  1346. }
  1347. if (!has_name) {
  1348. ast_log(LOG_ERROR, "ARI Bridge missing required field name\n");
  1349. res = 0;
  1350. }
  1351. if (!has_technology) {
  1352. ast_log(LOG_ERROR, "ARI Bridge missing required field technology\n");
  1353. res = 0;
  1354. }
  1355. return res;
  1356. }
  1357. ari_validator ast_ari_validate_bridge_fn(void)
  1358. {
  1359. return ast_ari_validate_bridge;
  1360. }
  1361. int ast_ari_validate_live_recording(struct ast_json *json)
  1362. {
  1363. int res = 1;
  1364. struct ast_json_iter *iter;
  1365. int has_format = 0;
  1366. int has_name = 0;
  1367. int has_state = 0;
  1368. int has_target_uri = 0;
  1369. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1370. if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
  1371. int prop_is_valid;
  1372. prop_is_valid = ast_ari_validate_string(
  1373. ast_json_object_iter_value(iter));
  1374. if (!prop_is_valid) {
  1375. ast_log(LOG_ERROR, "ARI LiveRecording field cause failed validation\n");
  1376. res = 0;
  1377. }
  1378. } else
  1379. if (strcmp("duration", ast_json_object_iter_key(iter)) == 0) {
  1380. int prop_is_valid;
  1381. prop_is_valid = ast_ari_validate_int(
  1382. ast_json_object_iter_value(iter));
  1383. if (!prop_is_valid) {
  1384. ast_log(LOG_ERROR, "ARI LiveRecording field duration failed validation\n");
  1385. res = 0;
  1386. }
  1387. } else
  1388. if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
  1389. int prop_is_valid;
  1390. has_format = 1;
  1391. prop_is_valid = ast_ari_validate_string(
  1392. ast_json_object_iter_value(iter));
  1393. if (!prop_is_valid) {
  1394. ast_log(LOG_ERROR, "ARI LiveRecording field format failed validation\n");
  1395. res = 0;
  1396. }
  1397. } else
  1398. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1399. int prop_is_valid;
  1400. has_name = 1;
  1401. prop_is_valid = ast_ari_validate_string(
  1402. ast_json_object_iter_value(iter));
  1403. if (!prop_is_valid) {
  1404. ast_log(LOG_ERROR, "ARI LiveRecording field name failed validation\n");
  1405. res = 0;
  1406. }
  1407. } else
  1408. if (strcmp("silence_duration", ast_json_object_iter_key(iter)) == 0) {
  1409. int prop_is_valid;
  1410. prop_is_valid = ast_ari_validate_int(
  1411. ast_json_object_iter_value(iter));
  1412. if (!prop_is_valid) {
  1413. ast_log(LOG_ERROR, "ARI LiveRecording field silence_duration failed validation\n");
  1414. res = 0;
  1415. }
  1416. } else
  1417. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  1418. int prop_is_valid;
  1419. has_state = 1;
  1420. prop_is_valid = ast_ari_validate_string(
  1421. ast_json_object_iter_value(iter));
  1422. if (!prop_is_valid) {
  1423. ast_log(LOG_ERROR, "ARI LiveRecording field state failed validation\n");
  1424. res = 0;
  1425. }
  1426. } else
  1427. if (strcmp("talking_duration", ast_json_object_iter_key(iter)) == 0) {
  1428. int prop_is_valid;
  1429. prop_is_valid = ast_ari_validate_int(
  1430. ast_json_object_iter_value(iter));
  1431. if (!prop_is_valid) {
  1432. ast_log(LOG_ERROR, "ARI LiveRecording field talking_duration failed validation\n");
  1433. res = 0;
  1434. }
  1435. } else
  1436. if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
  1437. int prop_is_valid;
  1438. has_target_uri = 1;
  1439. prop_is_valid = ast_ari_validate_string(
  1440. ast_json_object_iter_value(iter));
  1441. if (!prop_is_valid) {
  1442. ast_log(LOG_ERROR, "ARI LiveRecording field target_uri failed validation\n");
  1443. res = 0;
  1444. }
  1445. } else
  1446. {
  1447. ast_log(LOG_ERROR,
  1448. "ARI LiveRecording has undocumented field %s\n",
  1449. ast_json_object_iter_key(iter));
  1450. res = 0;
  1451. }
  1452. }
  1453. if (!has_format) {
  1454. ast_log(LOG_ERROR, "ARI LiveRecording missing required field format\n");
  1455. res = 0;
  1456. }
  1457. if (!has_name) {
  1458. ast_log(LOG_ERROR, "ARI LiveRecording missing required field name\n");
  1459. res = 0;
  1460. }
  1461. if (!has_state) {
  1462. ast_log(LOG_ERROR, "ARI LiveRecording missing required field state\n");
  1463. res = 0;
  1464. }
  1465. if (!has_target_uri) {
  1466. ast_log(LOG_ERROR, "ARI LiveRecording missing required field target_uri\n");
  1467. res = 0;
  1468. }
  1469. return res;
  1470. }
  1471. ari_validator ast_ari_validate_live_recording_fn(void)
  1472. {
  1473. return ast_ari_validate_live_recording;
  1474. }
  1475. int ast_ari_validate_stored_recording(struct ast_json *json)
  1476. {
  1477. int res = 1;
  1478. struct ast_json_iter *iter;
  1479. int has_format = 0;
  1480. int has_name = 0;
  1481. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1482. if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
  1483. int prop_is_valid;
  1484. has_format = 1;
  1485. prop_is_valid = ast_ari_validate_string(
  1486. ast_json_object_iter_value(iter));
  1487. if (!prop_is_valid) {
  1488. ast_log(LOG_ERROR, "ARI StoredRecording field format failed validation\n");
  1489. res = 0;
  1490. }
  1491. } else
  1492. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1493. int prop_is_valid;
  1494. has_name = 1;
  1495. prop_is_valid = ast_ari_validate_string(
  1496. ast_json_object_iter_value(iter));
  1497. if (!prop_is_valid) {
  1498. ast_log(LOG_ERROR, "ARI StoredRecording field name failed validation\n");
  1499. res = 0;
  1500. }
  1501. } else
  1502. {
  1503. ast_log(LOG_ERROR,
  1504. "ARI StoredRecording has undocumented field %s\n",
  1505. ast_json_object_iter_key(iter));
  1506. res = 0;
  1507. }
  1508. }
  1509. if (!has_format) {
  1510. ast_log(LOG_ERROR, "ARI StoredRecording missing required field format\n");
  1511. res = 0;
  1512. }
  1513. if (!has_name) {
  1514. ast_log(LOG_ERROR, "ARI StoredRecording missing required field name\n");
  1515. res = 0;
  1516. }
  1517. return res;
  1518. }
  1519. ari_validator ast_ari_validate_stored_recording_fn(void)
  1520. {
  1521. return ast_ari_validate_stored_recording;
  1522. }
  1523. int ast_ari_validate_format_lang_pair(struct ast_json *json)
  1524. {
  1525. int res = 1;
  1526. struct ast_json_iter *iter;
  1527. int has_format = 0;
  1528. int has_language = 0;
  1529. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1530. if (strcmp("format", ast_json_object_iter_key(iter)) == 0) {
  1531. int prop_is_valid;
  1532. has_format = 1;
  1533. prop_is_valid = ast_ari_validate_string(
  1534. ast_json_object_iter_value(iter));
  1535. if (!prop_is_valid) {
  1536. ast_log(LOG_ERROR, "ARI FormatLangPair field format failed validation\n");
  1537. res = 0;
  1538. }
  1539. } else
  1540. if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
  1541. int prop_is_valid;
  1542. has_language = 1;
  1543. prop_is_valid = ast_ari_validate_string(
  1544. ast_json_object_iter_value(iter));
  1545. if (!prop_is_valid) {
  1546. ast_log(LOG_ERROR, "ARI FormatLangPair field language failed validation\n");
  1547. res = 0;
  1548. }
  1549. } else
  1550. {
  1551. ast_log(LOG_ERROR,
  1552. "ARI FormatLangPair has undocumented field %s\n",
  1553. ast_json_object_iter_key(iter));
  1554. res = 0;
  1555. }
  1556. }
  1557. if (!has_format) {
  1558. ast_log(LOG_ERROR, "ARI FormatLangPair missing required field format\n");
  1559. res = 0;
  1560. }
  1561. if (!has_language) {
  1562. ast_log(LOG_ERROR, "ARI FormatLangPair missing required field language\n");
  1563. res = 0;
  1564. }
  1565. return res;
  1566. }
  1567. ari_validator ast_ari_validate_format_lang_pair_fn(void)
  1568. {
  1569. return ast_ari_validate_format_lang_pair;
  1570. }
  1571. int ast_ari_validate_sound(struct ast_json *json)
  1572. {
  1573. int res = 1;
  1574. struct ast_json_iter *iter;
  1575. int has_formats = 0;
  1576. int has_id = 0;
  1577. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1578. if (strcmp("formats", ast_json_object_iter_key(iter)) == 0) {
  1579. int prop_is_valid;
  1580. has_formats = 1;
  1581. prop_is_valid = ast_ari_validate_list(
  1582. ast_json_object_iter_value(iter),
  1583. ast_ari_validate_format_lang_pair);
  1584. if (!prop_is_valid) {
  1585. ast_log(LOG_ERROR, "ARI Sound field formats failed validation\n");
  1586. res = 0;
  1587. }
  1588. } else
  1589. if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
  1590. int prop_is_valid;
  1591. has_id = 1;
  1592. prop_is_valid = ast_ari_validate_string(
  1593. ast_json_object_iter_value(iter));
  1594. if (!prop_is_valid) {
  1595. ast_log(LOG_ERROR, "ARI Sound field id failed validation\n");
  1596. res = 0;
  1597. }
  1598. } else
  1599. if (strcmp("text", ast_json_object_iter_key(iter)) == 0) {
  1600. int prop_is_valid;
  1601. prop_is_valid = ast_ari_validate_string(
  1602. ast_json_object_iter_value(iter));
  1603. if (!prop_is_valid) {
  1604. ast_log(LOG_ERROR, "ARI Sound field text failed validation\n");
  1605. res = 0;
  1606. }
  1607. } else
  1608. {
  1609. ast_log(LOG_ERROR,
  1610. "ARI Sound has undocumented field %s\n",
  1611. ast_json_object_iter_key(iter));
  1612. res = 0;
  1613. }
  1614. }
  1615. if (!has_formats) {
  1616. ast_log(LOG_ERROR, "ARI Sound missing required field formats\n");
  1617. res = 0;
  1618. }
  1619. if (!has_id) {
  1620. ast_log(LOG_ERROR, "ARI Sound missing required field id\n");
  1621. res = 0;
  1622. }
  1623. return res;
  1624. }
  1625. ari_validator ast_ari_validate_sound_fn(void)
  1626. {
  1627. return ast_ari_validate_sound;
  1628. }
  1629. int ast_ari_validate_playback(struct ast_json *json)
  1630. {
  1631. int res = 1;
  1632. struct ast_json_iter *iter;
  1633. int has_id = 0;
  1634. int has_media_uri = 0;
  1635. int has_state = 0;
  1636. int has_target_uri = 0;
  1637. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1638. if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
  1639. int prop_is_valid;
  1640. has_id = 1;
  1641. prop_is_valid = ast_ari_validate_string(
  1642. ast_json_object_iter_value(iter));
  1643. if (!prop_is_valid) {
  1644. ast_log(LOG_ERROR, "ARI Playback field id failed validation\n");
  1645. res = 0;
  1646. }
  1647. } else
  1648. if (strcmp("language", ast_json_object_iter_key(iter)) == 0) {
  1649. int prop_is_valid;
  1650. prop_is_valid = ast_ari_validate_string(
  1651. ast_json_object_iter_value(iter));
  1652. if (!prop_is_valid) {
  1653. ast_log(LOG_ERROR, "ARI Playback field language failed validation\n");
  1654. res = 0;
  1655. }
  1656. } else
  1657. if (strcmp("media_uri", ast_json_object_iter_key(iter)) == 0) {
  1658. int prop_is_valid;
  1659. has_media_uri = 1;
  1660. prop_is_valid = ast_ari_validate_string(
  1661. ast_json_object_iter_value(iter));
  1662. if (!prop_is_valid) {
  1663. ast_log(LOG_ERROR, "ARI Playback field media_uri failed validation\n");
  1664. res = 0;
  1665. }
  1666. } else
  1667. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  1668. int prop_is_valid;
  1669. has_state = 1;
  1670. prop_is_valid = ast_ari_validate_string(
  1671. ast_json_object_iter_value(iter));
  1672. if (!prop_is_valid) {
  1673. ast_log(LOG_ERROR, "ARI Playback field state failed validation\n");
  1674. res = 0;
  1675. }
  1676. } else
  1677. if (strcmp("target_uri", ast_json_object_iter_key(iter)) == 0) {
  1678. int prop_is_valid;
  1679. has_target_uri = 1;
  1680. prop_is_valid = ast_ari_validate_string(
  1681. ast_json_object_iter_value(iter));
  1682. if (!prop_is_valid) {
  1683. ast_log(LOG_ERROR, "ARI Playback field target_uri failed validation\n");
  1684. res = 0;
  1685. }
  1686. } else
  1687. {
  1688. ast_log(LOG_ERROR,
  1689. "ARI Playback has undocumented field %s\n",
  1690. ast_json_object_iter_key(iter));
  1691. res = 0;
  1692. }
  1693. }
  1694. if (!has_id) {
  1695. ast_log(LOG_ERROR, "ARI Playback missing required field id\n");
  1696. res = 0;
  1697. }
  1698. if (!has_media_uri) {
  1699. ast_log(LOG_ERROR, "ARI Playback missing required field media_uri\n");
  1700. res = 0;
  1701. }
  1702. if (!has_state) {
  1703. ast_log(LOG_ERROR, "ARI Playback missing required field state\n");
  1704. res = 0;
  1705. }
  1706. if (!has_target_uri) {
  1707. ast_log(LOG_ERROR, "ARI Playback missing required field target_uri\n");
  1708. res = 0;
  1709. }
  1710. return res;
  1711. }
  1712. ari_validator ast_ari_validate_playback_fn(void)
  1713. {
  1714. return ast_ari_validate_playback;
  1715. }
  1716. int ast_ari_validate_device_state(struct ast_json *json)
  1717. {
  1718. int res = 1;
  1719. struct ast_json_iter *iter;
  1720. int has_name = 0;
  1721. int has_state = 0;
  1722. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1723. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1724. int prop_is_valid;
  1725. has_name = 1;
  1726. prop_is_valid = ast_ari_validate_string(
  1727. ast_json_object_iter_value(iter));
  1728. if (!prop_is_valid) {
  1729. ast_log(LOG_ERROR, "ARI DeviceState field name failed validation\n");
  1730. res = 0;
  1731. }
  1732. } else
  1733. if (strcmp("state", ast_json_object_iter_key(iter)) == 0) {
  1734. int prop_is_valid;
  1735. has_state = 1;
  1736. prop_is_valid = ast_ari_validate_string(
  1737. ast_json_object_iter_value(iter));
  1738. if (!prop_is_valid) {
  1739. ast_log(LOG_ERROR, "ARI DeviceState field state failed validation\n");
  1740. res = 0;
  1741. }
  1742. } else
  1743. {
  1744. ast_log(LOG_ERROR,
  1745. "ARI DeviceState has undocumented field %s\n",
  1746. ast_json_object_iter_key(iter));
  1747. res = 0;
  1748. }
  1749. }
  1750. if (!has_name) {
  1751. ast_log(LOG_ERROR, "ARI DeviceState missing required field name\n");
  1752. res = 0;
  1753. }
  1754. if (!has_state) {
  1755. ast_log(LOG_ERROR, "ARI DeviceState missing required field state\n");
  1756. res = 0;
  1757. }
  1758. return res;
  1759. }
  1760. ari_validator ast_ari_validate_device_state_fn(void)
  1761. {
  1762. return ast_ari_validate_device_state;
  1763. }
  1764. int ast_ari_validate_mailbox(struct ast_json *json)
  1765. {
  1766. int res = 1;
  1767. struct ast_json_iter *iter;
  1768. int has_name = 0;
  1769. int has_new_messages = 0;
  1770. int has_old_messages = 0;
  1771. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1772. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  1773. int prop_is_valid;
  1774. has_name = 1;
  1775. prop_is_valid = ast_ari_validate_string(
  1776. ast_json_object_iter_value(iter));
  1777. if (!prop_is_valid) {
  1778. ast_log(LOG_ERROR, "ARI Mailbox field name failed validation\n");
  1779. res = 0;
  1780. }
  1781. } else
  1782. if (strcmp("new_messages", ast_json_object_iter_key(iter)) == 0) {
  1783. int prop_is_valid;
  1784. has_new_messages = 1;
  1785. prop_is_valid = ast_ari_validate_int(
  1786. ast_json_object_iter_value(iter));
  1787. if (!prop_is_valid) {
  1788. ast_log(LOG_ERROR, "ARI Mailbox field new_messages failed validation\n");
  1789. res = 0;
  1790. }
  1791. } else
  1792. if (strcmp("old_messages", ast_json_object_iter_key(iter)) == 0) {
  1793. int prop_is_valid;
  1794. has_old_messages = 1;
  1795. prop_is_valid = ast_ari_validate_int(
  1796. ast_json_object_iter_value(iter));
  1797. if (!prop_is_valid) {
  1798. ast_log(LOG_ERROR, "ARI Mailbox field old_messages failed validation\n");
  1799. res = 0;
  1800. }
  1801. } else
  1802. {
  1803. ast_log(LOG_ERROR,
  1804. "ARI Mailbox has undocumented field %s\n",
  1805. ast_json_object_iter_key(iter));
  1806. res = 0;
  1807. }
  1808. }
  1809. if (!has_name) {
  1810. ast_log(LOG_ERROR, "ARI Mailbox missing required field name\n");
  1811. res = 0;
  1812. }
  1813. if (!has_new_messages) {
  1814. ast_log(LOG_ERROR, "ARI Mailbox missing required field new_messages\n");
  1815. res = 0;
  1816. }
  1817. if (!has_old_messages) {
  1818. ast_log(LOG_ERROR, "ARI Mailbox missing required field old_messages\n");
  1819. res = 0;
  1820. }
  1821. return res;
  1822. }
  1823. ari_validator ast_ari_validate_mailbox_fn(void)
  1824. {
  1825. return ast_ari_validate_mailbox;
  1826. }
  1827. int ast_ari_validate_application_replaced(struct ast_json *json)
  1828. {
  1829. int res = 1;
  1830. struct ast_json_iter *iter;
  1831. int has_type = 0;
  1832. int has_application = 0;
  1833. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1834. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  1835. int prop_is_valid;
  1836. prop_is_valid = ast_ari_validate_string(
  1837. ast_json_object_iter_value(iter));
  1838. if (!prop_is_valid) {
  1839. ast_log(LOG_ERROR, "ARI ApplicationReplaced field asterisk_id failed validation\n");
  1840. res = 0;
  1841. }
  1842. } else
  1843. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  1844. int prop_is_valid;
  1845. has_type = 1;
  1846. prop_is_valid = ast_ari_validate_string(
  1847. ast_json_object_iter_value(iter));
  1848. if (!prop_is_valid) {
  1849. ast_log(LOG_ERROR, "ARI ApplicationReplaced field type failed validation\n");
  1850. res = 0;
  1851. }
  1852. } else
  1853. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  1854. int prop_is_valid;
  1855. has_application = 1;
  1856. prop_is_valid = ast_ari_validate_string(
  1857. ast_json_object_iter_value(iter));
  1858. if (!prop_is_valid) {
  1859. ast_log(LOG_ERROR, "ARI ApplicationReplaced field application failed validation\n");
  1860. res = 0;
  1861. }
  1862. } else
  1863. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  1864. int prop_is_valid;
  1865. prop_is_valid = ast_ari_validate_date(
  1866. ast_json_object_iter_value(iter));
  1867. if (!prop_is_valid) {
  1868. ast_log(LOG_ERROR, "ARI ApplicationReplaced field timestamp failed validation\n");
  1869. res = 0;
  1870. }
  1871. } else
  1872. {
  1873. ast_log(LOG_ERROR,
  1874. "ARI ApplicationReplaced has undocumented field %s\n",
  1875. ast_json_object_iter_key(iter));
  1876. res = 0;
  1877. }
  1878. }
  1879. if (!has_type) {
  1880. ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field type\n");
  1881. res = 0;
  1882. }
  1883. if (!has_application) {
  1884. ast_log(LOG_ERROR, "ARI ApplicationReplaced missing required field application\n");
  1885. res = 0;
  1886. }
  1887. return res;
  1888. }
  1889. ari_validator ast_ari_validate_application_replaced_fn(void)
  1890. {
  1891. return ast_ari_validate_application_replaced;
  1892. }
  1893. int ast_ari_validate_bridge_attended_transfer(struct ast_json *json)
  1894. {
  1895. int res = 1;
  1896. struct ast_json_iter *iter;
  1897. int has_type = 0;
  1898. int has_application = 0;
  1899. int has_destination_type = 0;
  1900. int has_is_external = 0;
  1901. int has_result = 0;
  1902. int has_transferer_first_leg = 0;
  1903. int has_transferer_second_leg = 0;
  1904. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  1905. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  1906. int prop_is_valid;
  1907. prop_is_valid = ast_ari_validate_string(
  1908. ast_json_object_iter_value(iter));
  1909. if (!prop_is_valid) {
  1910. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field asterisk_id failed validation\n");
  1911. res = 0;
  1912. }
  1913. } else
  1914. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  1915. int prop_is_valid;
  1916. has_type = 1;
  1917. prop_is_valid = ast_ari_validate_string(
  1918. ast_json_object_iter_value(iter));
  1919. if (!prop_is_valid) {
  1920. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field type failed validation\n");
  1921. res = 0;
  1922. }
  1923. } else
  1924. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  1925. int prop_is_valid;
  1926. has_application = 1;
  1927. prop_is_valid = ast_ari_validate_string(
  1928. ast_json_object_iter_value(iter));
  1929. if (!prop_is_valid) {
  1930. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field application failed validation\n");
  1931. res = 0;
  1932. }
  1933. } else
  1934. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  1935. int prop_is_valid;
  1936. prop_is_valid = ast_ari_validate_date(
  1937. ast_json_object_iter_value(iter));
  1938. if (!prop_is_valid) {
  1939. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field timestamp failed validation\n");
  1940. res = 0;
  1941. }
  1942. } else
  1943. if (strcmp("destination_application", ast_json_object_iter_key(iter)) == 0) {
  1944. int prop_is_valid;
  1945. prop_is_valid = ast_ari_validate_string(
  1946. ast_json_object_iter_value(iter));
  1947. if (!prop_is_valid) {
  1948. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_application failed validation\n");
  1949. res = 0;
  1950. }
  1951. } else
  1952. if (strcmp("destination_bridge", ast_json_object_iter_key(iter)) == 0) {
  1953. int prop_is_valid;
  1954. prop_is_valid = ast_ari_validate_string(
  1955. ast_json_object_iter_value(iter));
  1956. if (!prop_is_valid) {
  1957. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_bridge failed validation\n");
  1958. res = 0;
  1959. }
  1960. } else
  1961. if (strcmp("destination_link_first_leg", ast_json_object_iter_key(iter)) == 0) {
  1962. int prop_is_valid;
  1963. prop_is_valid = ast_ari_validate_channel(
  1964. ast_json_object_iter_value(iter));
  1965. if (!prop_is_valid) {
  1966. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_first_leg failed validation\n");
  1967. res = 0;
  1968. }
  1969. } else
  1970. if (strcmp("destination_link_second_leg", ast_json_object_iter_key(iter)) == 0) {
  1971. int prop_is_valid;
  1972. prop_is_valid = ast_ari_validate_channel(
  1973. ast_json_object_iter_value(iter));
  1974. if (!prop_is_valid) {
  1975. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_second_leg failed validation\n");
  1976. res = 0;
  1977. }
  1978. } else
  1979. if (strcmp("destination_threeway_bridge", ast_json_object_iter_key(iter)) == 0) {
  1980. int prop_is_valid;
  1981. prop_is_valid = ast_ari_validate_bridge(
  1982. ast_json_object_iter_value(iter));
  1983. if (!prop_is_valid) {
  1984. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_bridge failed validation\n");
  1985. res = 0;
  1986. }
  1987. } else
  1988. if (strcmp("destination_threeway_channel", ast_json_object_iter_key(iter)) == 0) {
  1989. int prop_is_valid;
  1990. prop_is_valid = ast_ari_validate_channel(
  1991. ast_json_object_iter_value(iter));
  1992. if (!prop_is_valid) {
  1993. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_channel failed validation\n");
  1994. res = 0;
  1995. }
  1996. } else
  1997. if (strcmp("destination_type", ast_json_object_iter_key(iter)) == 0) {
  1998. int prop_is_valid;
  1999. has_destination_type = 1;
  2000. prop_is_valid = ast_ari_validate_string(
  2001. ast_json_object_iter_value(iter));
  2002. if (!prop_is_valid) {
  2003. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_type failed validation\n");
  2004. res = 0;
  2005. }
  2006. } else
  2007. if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
  2008. int prop_is_valid;
  2009. has_is_external = 1;
  2010. prop_is_valid = ast_ari_validate_boolean(
  2011. ast_json_object_iter_value(iter));
  2012. if (!prop_is_valid) {
  2013. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field is_external failed validation\n");
  2014. res = 0;
  2015. }
  2016. } else
  2017. if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
  2018. int prop_is_valid;
  2019. prop_is_valid = ast_ari_validate_channel(
  2020. ast_json_object_iter_value(iter));
  2021. if (!prop_is_valid) {
  2022. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field replace_channel failed validation\n");
  2023. res = 0;
  2024. }
  2025. } else
  2026. if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
  2027. int prop_is_valid;
  2028. has_result = 1;
  2029. prop_is_valid = ast_ari_validate_string(
  2030. ast_json_object_iter_value(iter));
  2031. if (!prop_is_valid) {
  2032. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field result failed validation\n");
  2033. res = 0;
  2034. }
  2035. } else
  2036. if (strcmp("transfer_target", ast_json_object_iter_key(iter)) == 0) {
  2037. int prop_is_valid;
  2038. prop_is_valid = ast_ari_validate_channel(
  2039. ast_json_object_iter_value(iter));
  2040. if (!prop_is_valid) {
  2041. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transfer_target failed validation\n");
  2042. res = 0;
  2043. }
  2044. } else
  2045. if (strcmp("transferee", ast_json_object_iter_key(iter)) == 0) {
  2046. int prop_is_valid;
  2047. prop_is_valid = ast_ari_validate_channel(
  2048. ast_json_object_iter_value(iter));
  2049. if (!prop_is_valid) {
  2050. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferee failed validation\n");
  2051. res = 0;
  2052. }
  2053. } else
  2054. if (strcmp("transferer_first_leg", ast_json_object_iter_key(iter)) == 0) {
  2055. int prop_is_valid;
  2056. has_transferer_first_leg = 1;
  2057. prop_is_valid = ast_ari_validate_channel(
  2058. ast_json_object_iter_value(iter));
  2059. if (!prop_is_valid) {
  2060. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_first_leg failed validation\n");
  2061. res = 0;
  2062. }
  2063. } else
  2064. if (strcmp("transferer_first_leg_bridge", ast_json_object_iter_key(iter)) == 0) {
  2065. int prop_is_valid;
  2066. prop_is_valid = ast_ari_validate_bridge(
  2067. ast_json_object_iter_value(iter));
  2068. if (!prop_is_valid) {
  2069. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_first_leg_bridge failed validation\n");
  2070. res = 0;
  2071. }
  2072. } else
  2073. if (strcmp("transferer_second_leg", ast_json_object_iter_key(iter)) == 0) {
  2074. int prop_is_valid;
  2075. has_transferer_second_leg = 1;
  2076. prop_is_valid = ast_ari_validate_channel(
  2077. ast_json_object_iter_value(iter));
  2078. if (!prop_is_valid) {
  2079. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_second_leg failed validation\n");
  2080. res = 0;
  2081. }
  2082. } else
  2083. if (strcmp("transferer_second_leg_bridge", ast_json_object_iter_key(iter)) == 0) {
  2084. int prop_is_valid;
  2085. prop_is_valid = ast_ari_validate_bridge(
  2086. ast_json_object_iter_value(iter));
  2087. if (!prop_is_valid) {
  2088. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_second_leg_bridge failed validation\n");
  2089. res = 0;
  2090. }
  2091. } else
  2092. {
  2093. ast_log(LOG_ERROR,
  2094. "ARI BridgeAttendedTransfer has undocumented field %s\n",
  2095. ast_json_object_iter_key(iter));
  2096. res = 0;
  2097. }
  2098. }
  2099. if (!has_type) {
  2100. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field type\n");
  2101. res = 0;
  2102. }
  2103. if (!has_application) {
  2104. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field application\n");
  2105. res = 0;
  2106. }
  2107. if (!has_destination_type) {
  2108. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field destination_type\n");
  2109. res = 0;
  2110. }
  2111. if (!has_is_external) {
  2112. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field is_external\n");
  2113. res = 0;
  2114. }
  2115. if (!has_result) {
  2116. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field result\n");
  2117. res = 0;
  2118. }
  2119. if (!has_transferer_first_leg) {
  2120. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field transferer_first_leg\n");
  2121. res = 0;
  2122. }
  2123. if (!has_transferer_second_leg) {
  2124. ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field transferer_second_leg\n");
  2125. res = 0;
  2126. }
  2127. return res;
  2128. }
  2129. ari_validator ast_ari_validate_bridge_attended_transfer_fn(void)
  2130. {
  2131. return ast_ari_validate_bridge_attended_transfer;
  2132. }
  2133. int ast_ari_validate_bridge_blind_transfer(struct ast_json *json)
  2134. {
  2135. int res = 1;
  2136. struct ast_json_iter *iter;
  2137. int has_type = 0;
  2138. int has_application = 0;
  2139. int has_channel = 0;
  2140. int has_context = 0;
  2141. int has_exten = 0;
  2142. int has_is_external = 0;
  2143. int has_result = 0;
  2144. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2145. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2146. int prop_is_valid;
  2147. prop_is_valid = ast_ari_validate_string(
  2148. ast_json_object_iter_value(iter));
  2149. if (!prop_is_valid) {
  2150. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field asterisk_id failed validation\n");
  2151. res = 0;
  2152. }
  2153. } else
  2154. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2155. int prop_is_valid;
  2156. has_type = 1;
  2157. prop_is_valid = ast_ari_validate_string(
  2158. ast_json_object_iter_value(iter));
  2159. if (!prop_is_valid) {
  2160. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field type failed validation\n");
  2161. res = 0;
  2162. }
  2163. } else
  2164. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2165. int prop_is_valid;
  2166. has_application = 1;
  2167. prop_is_valid = ast_ari_validate_string(
  2168. ast_json_object_iter_value(iter));
  2169. if (!prop_is_valid) {
  2170. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field application failed validation\n");
  2171. res = 0;
  2172. }
  2173. } else
  2174. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2175. int prop_is_valid;
  2176. prop_is_valid = ast_ari_validate_date(
  2177. ast_json_object_iter_value(iter));
  2178. if (!prop_is_valid) {
  2179. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field timestamp failed validation\n");
  2180. res = 0;
  2181. }
  2182. } else
  2183. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2184. int prop_is_valid;
  2185. prop_is_valid = ast_ari_validate_bridge(
  2186. ast_json_object_iter_value(iter));
  2187. if (!prop_is_valid) {
  2188. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field bridge failed validation\n");
  2189. res = 0;
  2190. }
  2191. } else
  2192. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2193. int prop_is_valid;
  2194. has_channel = 1;
  2195. prop_is_valid = ast_ari_validate_channel(
  2196. ast_json_object_iter_value(iter));
  2197. if (!prop_is_valid) {
  2198. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field channel failed validation\n");
  2199. res = 0;
  2200. }
  2201. } else
  2202. if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
  2203. int prop_is_valid;
  2204. has_context = 1;
  2205. prop_is_valid = ast_ari_validate_string(
  2206. ast_json_object_iter_value(iter));
  2207. if (!prop_is_valid) {
  2208. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field context failed validation\n");
  2209. res = 0;
  2210. }
  2211. } else
  2212. if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
  2213. int prop_is_valid;
  2214. has_exten = 1;
  2215. prop_is_valid = ast_ari_validate_string(
  2216. ast_json_object_iter_value(iter));
  2217. if (!prop_is_valid) {
  2218. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field exten failed validation\n");
  2219. res = 0;
  2220. }
  2221. } else
  2222. if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
  2223. int prop_is_valid;
  2224. has_is_external = 1;
  2225. prop_is_valid = ast_ari_validate_boolean(
  2226. ast_json_object_iter_value(iter));
  2227. if (!prop_is_valid) {
  2228. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field is_external failed validation\n");
  2229. res = 0;
  2230. }
  2231. } else
  2232. if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
  2233. int prop_is_valid;
  2234. prop_is_valid = ast_ari_validate_channel(
  2235. ast_json_object_iter_value(iter));
  2236. if (!prop_is_valid) {
  2237. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field replace_channel failed validation\n");
  2238. res = 0;
  2239. }
  2240. } else
  2241. if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
  2242. int prop_is_valid;
  2243. has_result = 1;
  2244. prop_is_valid = ast_ari_validate_string(
  2245. ast_json_object_iter_value(iter));
  2246. if (!prop_is_valid) {
  2247. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field result failed validation\n");
  2248. res = 0;
  2249. }
  2250. } else
  2251. if (strcmp("transferee", ast_json_object_iter_key(iter)) == 0) {
  2252. int prop_is_valid;
  2253. prop_is_valid = ast_ari_validate_channel(
  2254. ast_json_object_iter_value(iter));
  2255. if (!prop_is_valid) {
  2256. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field transferee failed validation\n");
  2257. res = 0;
  2258. }
  2259. } else
  2260. {
  2261. ast_log(LOG_ERROR,
  2262. "ARI BridgeBlindTransfer has undocumented field %s\n",
  2263. ast_json_object_iter_key(iter));
  2264. res = 0;
  2265. }
  2266. }
  2267. if (!has_type) {
  2268. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field type\n");
  2269. res = 0;
  2270. }
  2271. if (!has_application) {
  2272. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field application\n");
  2273. res = 0;
  2274. }
  2275. if (!has_channel) {
  2276. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field channel\n");
  2277. res = 0;
  2278. }
  2279. if (!has_context) {
  2280. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field context\n");
  2281. res = 0;
  2282. }
  2283. if (!has_exten) {
  2284. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field exten\n");
  2285. res = 0;
  2286. }
  2287. if (!has_is_external) {
  2288. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field is_external\n");
  2289. res = 0;
  2290. }
  2291. if (!has_result) {
  2292. ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field result\n");
  2293. res = 0;
  2294. }
  2295. return res;
  2296. }
  2297. ari_validator ast_ari_validate_bridge_blind_transfer_fn(void)
  2298. {
  2299. return ast_ari_validate_bridge_blind_transfer;
  2300. }
  2301. int ast_ari_validate_bridge_created(struct ast_json *json)
  2302. {
  2303. int res = 1;
  2304. struct ast_json_iter *iter;
  2305. int has_type = 0;
  2306. int has_application = 0;
  2307. int has_bridge = 0;
  2308. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2309. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2310. int prop_is_valid;
  2311. prop_is_valid = ast_ari_validate_string(
  2312. ast_json_object_iter_value(iter));
  2313. if (!prop_is_valid) {
  2314. ast_log(LOG_ERROR, "ARI BridgeCreated field asterisk_id failed validation\n");
  2315. res = 0;
  2316. }
  2317. } else
  2318. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2319. int prop_is_valid;
  2320. has_type = 1;
  2321. prop_is_valid = ast_ari_validate_string(
  2322. ast_json_object_iter_value(iter));
  2323. if (!prop_is_valid) {
  2324. ast_log(LOG_ERROR, "ARI BridgeCreated field type failed validation\n");
  2325. res = 0;
  2326. }
  2327. } else
  2328. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2329. int prop_is_valid;
  2330. has_application = 1;
  2331. prop_is_valid = ast_ari_validate_string(
  2332. ast_json_object_iter_value(iter));
  2333. if (!prop_is_valid) {
  2334. ast_log(LOG_ERROR, "ARI BridgeCreated field application failed validation\n");
  2335. res = 0;
  2336. }
  2337. } else
  2338. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2339. int prop_is_valid;
  2340. prop_is_valid = ast_ari_validate_date(
  2341. ast_json_object_iter_value(iter));
  2342. if (!prop_is_valid) {
  2343. ast_log(LOG_ERROR, "ARI BridgeCreated field timestamp failed validation\n");
  2344. res = 0;
  2345. }
  2346. } else
  2347. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2348. int prop_is_valid;
  2349. has_bridge = 1;
  2350. prop_is_valid = ast_ari_validate_bridge(
  2351. ast_json_object_iter_value(iter));
  2352. if (!prop_is_valid) {
  2353. ast_log(LOG_ERROR, "ARI BridgeCreated field bridge failed validation\n");
  2354. res = 0;
  2355. }
  2356. } else
  2357. {
  2358. ast_log(LOG_ERROR,
  2359. "ARI BridgeCreated has undocumented field %s\n",
  2360. ast_json_object_iter_key(iter));
  2361. res = 0;
  2362. }
  2363. }
  2364. if (!has_type) {
  2365. ast_log(LOG_ERROR, "ARI BridgeCreated missing required field type\n");
  2366. res = 0;
  2367. }
  2368. if (!has_application) {
  2369. ast_log(LOG_ERROR, "ARI BridgeCreated missing required field application\n");
  2370. res = 0;
  2371. }
  2372. if (!has_bridge) {
  2373. ast_log(LOG_ERROR, "ARI BridgeCreated missing required field bridge\n");
  2374. res = 0;
  2375. }
  2376. return res;
  2377. }
  2378. ari_validator ast_ari_validate_bridge_created_fn(void)
  2379. {
  2380. return ast_ari_validate_bridge_created;
  2381. }
  2382. int ast_ari_validate_bridge_destroyed(struct ast_json *json)
  2383. {
  2384. int res = 1;
  2385. struct ast_json_iter *iter;
  2386. int has_type = 0;
  2387. int has_application = 0;
  2388. int has_bridge = 0;
  2389. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2390. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2391. int prop_is_valid;
  2392. prop_is_valid = ast_ari_validate_string(
  2393. ast_json_object_iter_value(iter));
  2394. if (!prop_is_valid) {
  2395. ast_log(LOG_ERROR, "ARI BridgeDestroyed field asterisk_id failed validation\n");
  2396. res = 0;
  2397. }
  2398. } else
  2399. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2400. int prop_is_valid;
  2401. has_type = 1;
  2402. prop_is_valid = ast_ari_validate_string(
  2403. ast_json_object_iter_value(iter));
  2404. if (!prop_is_valid) {
  2405. ast_log(LOG_ERROR, "ARI BridgeDestroyed field type failed validation\n");
  2406. res = 0;
  2407. }
  2408. } else
  2409. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2410. int prop_is_valid;
  2411. has_application = 1;
  2412. prop_is_valid = ast_ari_validate_string(
  2413. ast_json_object_iter_value(iter));
  2414. if (!prop_is_valid) {
  2415. ast_log(LOG_ERROR, "ARI BridgeDestroyed field application failed validation\n");
  2416. res = 0;
  2417. }
  2418. } else
  2419. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2420. int prop_is_valid;
  2421. prop_is_valid = ast_ari_validate_date(
  2422. ast_json_object_iter_value(iter));
  2423. if (!prop_is_valid) {
  2424. ast_log(LOG_ERROR, "ARI BridgeDestroyed field timestamp failed validation\n");
  2425. res = 0;
  2426. }
  2427. } else
  2428. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2429. int prop_is_valid;
  2430. has_bridge = 1;
  2431. prop_is_valid = ast_ari_validate_bridge(
  2432. ast_json_object_iter_value(iter));
  2433. if (!prop_is_valid) {
  2434. ast_log(LOG_ERROR, "ARI BridgeDestroyed field bridge failed validation\n");
  2435. res = 0;
  2436. }
  2437. } else
  2438. {
  2439. ast_log(LOG_ERROR,
  2440. "ARI BridgeDestroyed has undocumented field %s\n",
  2441. ast_json_object_iter_key(iter));
  2442. res = 0;
  2443. }
  2444. }
  2445. if (!has_type) {
  2446. ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field type\n");
  2447. res = 0;
  2448. }
  2449. if (!has_application) {
  2450. ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field application\n");
  2451. res = 0;
  2452. }
  2453. if (!has_bridge) {
  2454. ast_log(LOG_ERROR, "ARI BridgeDestroyed missing required field bridge\n");
  2455. res = 0;
  2456. }
  2457. return res;
  2458. }
  2459. ari_validator ast_ari_validate_bridge_destroyed_fn(void)
  2460. {
  2461. return ast_ari_validate_bridge_destroyed;
  2462. }
  2463. int ast_ari_validate_bridge_merged(struct ast_json *json)
  2464. {
  2465. int res = 1;
  2466. struct ast_json_iter *iter;
  2467. int has_type = 0;
  2468. int has_application = 0;
  2469. int has_bridge = 0;
  2470. int has_bridge_from = 0;
  2471. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2472. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2473. int prop_is_valid;
  2474. prop_is_valid = ast_ari_validate_string(
  2475. ast_json_object_iter_value(iter));
  2476. if (!prop_is_valid) {
  2477. ast_log(LOG_ERROR, "ARI BridgeMerged field asterisk_id failed validation\n");
  2478. res = 0;
  2479. }
  2480. } else
  2481. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2482. int prop_is_valid;
  2483. has_type = 1;
  2484. prop_is_valid = ast_ari_validate_string(
  2485. ast_json_object_iter_value(iter));
  2486. if (!prop_is_valid) {
  2487. ast_log(LOG_ERROR, "ARI BridgeMerged field type failed validation\n");
  2488. res = 0;
  2489. }
  2490. } else
  2491. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2492. int prop_is_valid;
  2493. has_application = 1;
  2494. prop_is_valid = ast_ari_validate_string(
  2495. ast_json_object_iter_value(iter));
  2496. if (!prop_is_valid) {
  2497. ast_log(LOG_ERROR, "ARI BridgeMerged field application failed validation\n");
  2498. res = 0;
  2499. }
  2500. } else
  2501. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2502. int prop_is_valid;
  2503. prop_is_valid = ast_ari_validate_date(
  2504. ast_json_object_iter_value(iter));
  2505. if (!prop_is_valid) {
  2506. ast_log(LOG_ERROR, "ARI BridgeMerged field timestamp failed validation\n");
  2507. res = 0;
  2508. }
  2509. } else
  2510. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2511. int prop_is_valid;
  2512. has_bridge = 1;
  2513. prop_is_valid = ast_ari_validate_bridge(
  2514. ast_json_object_iter_value(iter));
  2515. if (!prop_is_valid) {
  2516. ast_log(LOG_ERROR, "ARI BridgeMerged field bridge failed validation\n");
  2517. res = 0;
  2518. }
  2519. } else
  2520. if (strcmp("bridge_from", ast_json_object_iter_key(iter)) == 0) {
  2521. int prop_is_valid;
  2522. has_bridge_from = 1;
  2523. prop_is_valid = ast_ari_validate_bridge(
  2524. ast_json_object_iter_value(iter));
  2525. if (!prop_is_valid) {
  2526. ast_log(LOG_ERROR, "ARI BridgeMerged field bridge_from failed validation\n");
  2527. res = 0;
  2528. }
  2529. } else
  2530. {
  2531. ast_log(LOG_ERROR,
  2532. "ARI BridgeMerged has undocumented field %s\n",
  2533. ast_json_object_iter_key(iter));
  2534. res = 0;
  2535. }
  2536. }
  2537. if (!has_type) {
  2538. ast_log(LOG_ERROR, "ARI BridgeMerged missing required field type\n");
  2539. res = 0;
  2540. }
  2541. if (!has_application) {
  2542. ast_log(LOG_ERROR, "ARI BridgeMerged missing required field application\n");
  2543. res = 0;
  2544. }
  2545. if (!has_bridge) {
  2546. ast_log(LOG_ERROR, "ARI BridgeMerged missing required field bridge\n");
  2547. res = 0;
  2548. }
  2549. if (!has_bridge_from) {
  2550. ast_log(LOG_ERROR, "ARI BridgeMerged missing required field bridge_from\n");
  2551. res = 0;
  2552. }
  2553. return res;
  2554. }
  2555. ari_validator ast_ari_validate_bridge_merged_fn(void)
  2556. {
  2557. return ast_ari_validate_bridge_merged;
  2558. }
  2559. int ast_ari_validate_bridge_video_source_changed(struct ast_json *json)
  2560. {
  2561. int res = 1;
  2562. struct ast_json_iter *iter;
  2563. int has_type = 0;
  2564. int has_application = 0;
  2565. int has_bridge = 0;
  2566. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2567. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2568. int prop_is_valid;
  2569. prop_is_valid = ast_ari_validate_string(
  2570. ast_json_object_iter_value(iter));
  2571. if (!prop_is_valid) {
  2572. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged field asterisk_id failed validation\n");
  2573. res = 0;
  2574. }
  2575. } else
  2576. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2577. int prop_is_valid;
  2578. has_type = 1;
  2579. prop_is_valid = ast_ari_validate_string(
  2580. ast_json_object_iter_value(iter));
  2581. if (!prop_is_valid) {
  2582. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged field type failed validation\n");
  2583. res = 0;
  2584. }
  2585. } else
  2586. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2587. int prop_is_valid;
  2588. has_application = 1;
  2589. prop_is_valid = ast_ari_validate_string(
  2590. ast_json_object_iter_value(iter));
  2591. if (!prop_is_valid) {
  2592. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged field application failed validation\n");
  2593. res = 0;
  2594. }
  2595. } else
  2596. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2597. int prop_is_valid;
  2598. prop_is_valid = ast_ari_validate_date(
  2599. ast_json_object_iter_value(iter));
  2600. if (!prop_is_valid) {
  2601. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged field timestamp failed validation\n");
  2602. res = 0;
  2603. }
  2604. } else
  2605. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  2606. int prop_is_valid;
  2607. has_bridge = 1;
  2608. prop_is_valid = ast_ari_validate_bridge(
  2609. ast_json_object_iter_value(iter));
  2610. if (!prop_is_valid) {
  2611. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged field bridge failed validation\n");
  2612. res = 0;
  2613. }
  2614. } else
  2615. if (strcmp("old_video_source_id", ast_json_object_iter_key(iter)) == 0) {
  2616. int prop_is_valid;
  2617. prop_is_valid = ast_ari_validate_string(
  2618. ast_json_object_iter_value(iter));
  2619. if (!prop_is_valid) {
  2620. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged field old_video_source_id failed validation\n");
  2621. res = 0;
  2622. }
  2623. } else
  2624. {
  2625. ast_log(LOG_ERROR,
  2626. "ARI BridgeVideoSourceChanged has undocumented field %s\n",
  2627. ast_json_object_iter_key(iter));
  2628. res = 0;
  2629. }
  2630. }
  2631. if (!has_type) {
  2632. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged missing required field type\n");
  2633. res = 0;
  2634. }
  2635. if (!has_application) {
  2636. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged missing required field application\n");
  2637. res = 0;
  2638. }
  2639. if (!has_bridge) {
  2640. ast_log(LOG_ERROR, "ARI BridgeVideoSourceChanged missing required field bridge\n");
  2641. res = 0;
  2642. }
  2643. return res;
  2644. }
  2645. ari_validator ast_ari_validate_bridge_video_source_changed_fn(void)
  2646. {
  2647. return ast_ari_validate_bridge_video_source_changed;
  2648. }
  2649. int ast_ari_validate_channel_caller_id(struct ast_json *json)
  2650. {
  2651. int res = 1;
  2652. struct ast_json_iter *iter;
  2653. int has_type = 0;
  2654. int has_application = 0;
  2655. int has_caller_presentation = 0;
  2656. int has_caller_presentation_txt = 0;
  2657. int has_channel = 0;
  2658. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2659. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2660. int prop_is_valid;
  2661. prop_is_valid = ast_ari_validate_string(
  2662. ast_json_object_iter_value(iter));
  2663. if (!prop_is_valid) {
  2664. ast_log(LOG_ERROR, "ARI ChannelCallerId field asterisk_id failed validation\n");
  2665. res = 0;
  2666. }
  2667. } else
  2668. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2669. int prop_is_valid;
  2670. has_type = 1;
  2671. prop_is_valid = ast_ari_validate_string(
  2672. ast_json_object_iter_value(iter));
  2673. if (!prop_is_valid) {
  2674. ast_log(LOG_ERROR, "ARI ChannelCallerId field type failed validation\n");
  2675. res = 0;
  2676. }
  2677. } else
  2678. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2679. int prop_is_valid;
  2680. has_application = 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 ChannelCallerId field application failed validation\n");
  2685. res = 0;
  2686. }
  2687. } else
  2688. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2689. int prop_is_valid;
  2690. prop_is_valid = ast_ari_validate_date(
  2691. ast_json_object_iter_value(iter));
  2692. if (!prop_is_valid) {
  2693. ast_log(LOG_ERROR, "ARI ChannelCallerId field timestamp failed validation\n");
  2694. res = 0;
  2695. }
  2696. } else
  2697. if (strcmp("caller_presentation", ast_json_object_iter_key(iter)) == 0) {
  2698. int prop_is_valid;
  2699. has_caller_presentation = 1;
  2700. prop_is_valid = ast_ari_validate_int(
  2701. ast_json_object_iter_value(iter));
  2702. if (!prop_is_valid) {
  2703. ast_log(LOG_ERROR, "ARI ChannelCallerId field caller_presentation failed validation\n");
  2704. res = 0;
  2705. }
  2706. } else
  2707. if (strcmp("caller_presentation_txt", ast_json_object_iter_key(iter)) == 0) {
  2708. int prop_is_valid;
  2709. has_caller_presentation_txt = 1;
  2710. prop_is_valid = ast_ari_validate_string(
  2711. ast_json_object_iter_value(iter));
  2712. if (!prop_is_valid) {
  2713. ast_log(LOG_ERROR, "ARI ChannelCallerId field caller_presentation_txt 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. has_channel = 1;
  2720. prop_is_valid = ast_ari_validate_channel(
  2721. ast_json_object_iter_value(iter));
  2722. if (!prop_is_valid) {
  2723. ast_log(LOG_ERROR, "ARI ChannelCallerId field channel failed validation\n");
  2724. res = 0;
  2725. }
  2726. } else
  2727. {
  2728. ast_log(LOG_ERROR,
  2729. "ARI ChannelCallerId has undocumented field %s\n",
  2730. ast_json_object_iter_key(iter));
  2731. res = 0;
  2732. }
  2733. }
  2734. if (!has_type) {
  2735. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field type\n");
  2736. res = 0;
  2737. }
  2738. if (!has_application) {
  2739. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field application\n");
  2740. res = 0;
  2741. }
  2742. if (!has_caller_presentation) {
  2743. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field caller_presentation\n");
  2744. res = 0;
  2745. }
  2746. if (!has_caller_presentation_txt) {
  2747. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field caller_presentation_txt\n");
  2748. res = 0;
  2749. }
  2750. if (!has_channel) {
  2751. ast_log(LOG_ERROR, "ARI ChannelCallerId missing required field channel\n");
  2752. res = 0;
  2753. }
  2754. return res;
  2755. }
  2756. ari_validator ast_ari_validate_channel_caller_id_fn(void)
  2757. {
  2758. return ast_ari_validate_channel_caller_id;
  2759. }
  2760. int ast_ari_validate_channel_connected_line(struct ast_json *json)
  2761. {
  2762. int res = 1;
  2763. struct ast_json_iter *iter;
  2764. int has_type = 0;
  2765. int has_application = 0;
  2766. int has_channel = 0;
  2767. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2768. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2769. int prop_is_valid;
  2770. prop_is_valid = ast_ari_validate_string(
  2771. ast_json_object_iter_value(iter));
  2772. if (!prop_is_valid) {
  2773. ast_log(LOG_ERROR, "ARI ChannelConnectedLine field asterisk_id failed validation\n");
  2774. res = 0;
  2775. }
  2776. } else
  2777. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2778. int prop_is_valid;
  2779. has_type = 1;
  2780. prop_is_valid = ast_ari_validate_string(
  2781. ast_json_object_iter_value(iter));
  2782. if (!prop_is_valid) {
  2783. ast_log(LOG_ERROR, "ARI ChannelConnectedLine field type failed validation\n");
  2784. res = 0;
  2785. }
  2786. } else
  2787. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2788. int prop_is_valid;
  2789. has_application = 1;
  2790. prop_is_valid = ast_ari_validate_string(
  2791. ast_json_object_iter_value(iter));
  2792. if (!prop_is_valid) {
  2793. ast_log(LOG_ERROR, "ARI ChannelConnectedLine field application failed validation\n");
  2794. res = 0;
  2795. }
  2796. } else
  2797. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2798. int prop_is_valid;
  2799. prop_is_valid = ast_ari_validate_date(
  2800. ast_json_object_iter_value(iter));
  2801. if (!prop_is_valid) {
  2802. ast_log(LOG_ERROR, "ARI ChannelConnectedLine field timestamp failed validation\n");
  2803. res = 0;
  2804. }
  2805. } else
  2806. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2807. int prop_is_valid;
  2808. has_channel = 1;
  2809. prop_is_valid = ast_ari_validate_channel(
  2810. ast_json_object_iter_value(iter));
  2811. if (!prop_is_valid) {
  2812. ast_log(LOG_ERROR, "ARI ChannelConnectedLine field channel failed validation\n");
  2813. res = 0;
  2814. }
  2815. } else
  2816. {
  2817. ast_log(LOG_ERROR,
  2818. "ARI ChannelConnectedLine 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 ChannelConnectedLine missing required field type\n");
  2825. res = 0;
  2826. }
  2827. if (!has_application) {
  2828. ast_log(LOG_ERROR, "ARI ChannelConnectedLine missing required field application\n");
  2829. res = 0;
  2830. }
  2831. if (!has_channel) {
  2832. ast_log(LOG_ERROR, "ARI ChannelConnectedLine missing required field channel\n");
  2833. res = 0;
  2834. }
  2835. return res;
  2836. }
  2837. ari_validator ast_ari_validate_channel_connected_line_fn(void)
  2838. {
  2839. return ast_ari_validate_channel_connected_line;
  2840. }
  2841. int ast_ari_validate_channel_created(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_channel = 0;
  2848. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2849. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2850. int prop_is_valid;
  2851. prop_is_valid = ast_ari_validate_string(
  2852. ast_json_object_iter_value(iter));
  2853. if (!prop_is_valid) {
  2854. ast_log(LOG_ERROR, "ARI ChannelCreated field asterisk_id failed validation\n");
  2855. res = 0;
  2856. }
  2857. } else
  2858. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2859. int prop_is_valid;
  2860. has_type = 1;
  2861. prop_is_valid = ast_ari_validate_string(
  2862. ast_json_object_iter_value(iter));
  2863. if (!prop_is_valid) {
  2864. ast_log(LOG_ERROR, "ARI ChannelCreated field type failed validation\n");
  2865. res = 0;
  2866. }
  2867. } else
  2868. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2869. int prop_is_valid;
  2870. has_application = 1;
  2871. prop_is_valid = ast_ari_validate_string(
  2872. ast_json_object_iter_value(iter));
  2873. if (!prop_is_valid) {
  2874. ast_log(LOG_ERROR, "ARI ChannelCreated field application failed validation\n");
  2875. res = 0;
  2876. }
  2877. } else
  2878. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2879. int prop_is_valid;
  2880. prop_is_valid = ast_ari_validate_date(
  2881. ast_json_object_iter_value(iter));
  2882. if (!prop_is_valid) {
  2883. ast_log(LOG_ERROR, "ARI ChannelCreated field timestamp failed validation\n");
  2884. res = 0;
  2885. }
  2886. } else
  2887. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2888. int prop_is_valid;
  2889. has_channel = 1;
  2890. prop_is_valid = ast_ari_validate_channel(
  2891. ast_json_object_iter_value(iter));
  2892. if (!prop_is_valid) {
  2893. ast_log(LOG_ERROR, "ARI ChannelCreated field channel failed validation\n");
  2894. res = 0;
  2895. }
  2896. } else
  2897. {
  2898. ast_log(LOG_ERROR,
  2899. "ARI ChannelCreated has undocumented field %s\n",
  2900. ast_json_object_iter_key(iter));
  2901. res = 0;
  2902. }
  2903. }
  2904. if (!has_type) {
  2905. ast_log(LOG_ERROR, "ARI ChannelCreated missing required field type\n");
  2906. res = 0;
  2907. }
  2908. if (!has_application) {
  2909. ast_log(LOG_ERROR, "ARI ChannelCreated missing required field application\n");
  2910. res = 0;
  2911. }
  2912. if (!has_channel) {
  2913. ast_log(LOG_ERROR, "ARI ChannelCreated missing required field channel\n");
  2914. res = 0;
  2915. }
  2916. return res;
  2917. }
  2918. ari_validator ast_ari_validate_channel_created_fn(void)
  2919. {
  2920. return ast_ari_validate_channel_created;
  2921. }
  2922. int ast_ari_validate_channel_destroyed(struct ast_json *json)
  2923. {
  2924. int res = 1;
  2925. struct ast_json_iter *iter;
  2926. int has_type = 0;
  2927. int has_application = 0;
  2928. int has_cause = 0;
  2929. int has_cause_txt = 0;
  2930. int has_channel = 0;
  2931. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  2932. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  2933. int prop_is_valid;
  2934. prop_is_valid = ast_ari_validate_string(
  2935. ast_json_object_iter_value(iter));
  2936. if (!prop_is_valid) {
  2937. ast_log(LOG_ERROR, "ARI ChannelDestroyed field asterisk_id failed validation\n");
  2938. res = 0;
  2939. }
  2940. } else
  2941. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  2942. int prop_is_valid;
  2943. has_type = 1;
  2944. prop_is_valid = ast_ari_validate_string(
  2945. ast_json_object_iter_value(iter));
  2946. if (!prop_is_valid) {
  2947. ast_log(LOG_ERROR, "ARI ChannelDestroyed field type failed validation\n");
  2948. res = 0;
  2949. }
  2950. } else
  2951. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  2952. int prop_is_valid;
  2953. has_application = 1;
  2954. prop_is_valid = ast_ari_validate_string(
  2955. ast_json_object_iter_value(iter));
  2956. if (!prop_is_valid) {
  2957. ast_log(LOG_ERROR, "ARI ChannelDestroyed field application failed validation\n");
  2958. res = 0;
  2959. }
  2960. } else
  2961. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  2962. int prop_is_valid;
  2963. prop_is_valid = ast_ari_validate_date(
  2964. ast_json_object_iter_value(iter));
  2965. if (!prop_is_valid) {
  2966. ast_log(LOG_ERROR, "ARI ChannelDestroyed field timestamp failed validation\n");
  2967. res = 0;
  2968. }
  2969. } else
  2970. if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
  2971. int prop_is_valid;
  2972. has_cause = 1;
  2973. prop_is_valid = ast_ari_validate_int(
  2974. ast_json_object_iter_value(iter));
  2975. if (!prop_is_valid) {
  2976. ast_log(LOG_ERROR, "ARI ChannelDestroyed field cause failed validation\n");
  2977. res = 0;
  2978. }
  2979. } else
  2980. if (strcmp("cause_txt", ast_json_object_iter_key(iter)) == 0) {
  2981. int prop_is_valid;
  2982. has_cause_txt = 1;
  2983. prop_is_valid = ast_ari_validate_string(
  2984. ast_json_object_iter_value(iter));
  2985. if (!prop_is_valid) {
  2986. ast_log(LOG_ERROR, "ARI ChannelDestroyed field cause_txt failed validation\n");
  2987. res = 0;
  2988. }
  2989. } else
  2990. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  2991. int prop_is_valid;
  2992. has_channel = 1;
  2993. prop_is_valid = ast_ari_validate_channel(
  2994. ast_json_object_iter_value(iter));
  2995. if (!prop_is_valid) {
  2996. ast_log(LOG_ERROR, "ARI ChannelDestroyed field channel failed validation\n");
  2997. res = 0;
  2998. }
  2999. } else
  3000. {
  3001. ast_log(LOG_ERROR,
  3002. "ARI ChannelDestroyed has undocumented field %s\n",
  3003. ast_json_object_iter_key(iter));
  3004. res = 0;
  3005. }
  3006. }
  3007. if (!has_type) {
  3008. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field type\n");
  3009. res = 0;
  3010. }
  3011. if (!has_application) {
  3012. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field application\n");
  3013. res = 0;
  3014. }
  3015. if (!has_cause) {
  3016. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field cause\n");
  3017. res = 0;
  3018. }
  3019. if (!has_cause_txt) {
  3020. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field cause_txt\n");
  3021. res = 0;
  3022. }
  3023. if (!has_channel) {
  3024. ast_log(LOG_ERROR, "ARI ChannelDestroyed missing required field channel\n");
  3025. res = 0;
  3026. }
  3027. return res;
  3028. }
  3029. ari_validator ast_ari_validate_channel_destroyed_fn(void)
  3030. {
  3031. return ast_ari_validate_channel_destroyed;
  3032. }
  3033. int ast_ari_validate_channel_dialplan(struct ast_json *json)
  3034. {
  3035. int res = 1;
  3036. struct ast_json_iter *iter;
  3037. int has_type = 0;
  3038. int has_application = 0;
  3039. int has_channel = 0;
  3040. int has_dialplan_app = 0;
  3041. int has_dialplan_app_data = 0;
  3042. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3043. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3044. int prop_is_valid;
  3045. prop_is_valid = ast_ari_validate_string(
  3046. ast_json_object_iter_value(iter));
  3047. if (!prop_is_valid) {
  3048. ast_log(LOG_ERROR, "ARI ChannelDialplan field asterisk_id failed validation\n");
  3049. res = 0;
  3050. }
  3051. } else
  3052. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3053. int prop_is_valid;
  3054. has_type = 1;
  3055. prop_is_valid = ast_ari_validate_string(
  3056. ast_json_object_iter_value(iter));
  3057. if (!prop_is_valid) {
  3058. ast_log(LOG_ERROR, "ARI ChannelDialplan field type failed validation\n");
  3059. res = 0;
  3060. }
  3061. } else
  3062. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3063. int prop_is_valid;
  3064. has_application = 1;
  3065. prop_is_valid = ast_ari_validate_string(
  3066. ast_json_object_iter_value(iter));
  3067. if (!prop_is_valid) {
  3068. ast_log(LOG_ERROR, "ARI ChannelDialplan field application failed validation\n");
  3069. res = 0;
  3070. }
  3071. } else
  3072. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3073. int prop_is_valid;
  3074. prop_is_valid = ast_ari_validate_date(
  3075. ast_json_object_iter_value(iter));
  3076. if (!prop_is_valid) {
  3077. ast_log(LOG_ERROR, "ARI ChannelDialplan field timestamp failed validation\n");
  3078. res = 0;
  3079. }
  3080. } else
  3081. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3082. int prop_is_valid;
  3083. has_channel = 1;
  3084. prop_is_valid = ast_ari_validate_channel(
  3085. ast_json_object_iter_value(iter));
  3086. if (!prop_is_valid) {
  3087. ast_log(LOG_ERROR, "ARI ChannelDialplan field channel failed validation\n");
  3088. res = 0;
  3089. }
  3090. } else
  3091. if (strcmp("dialplan_app", ast_json_object_iter_key(iter)) == 0) {
  3092. int prop_is_valid;
  3093. has_dialplan_app = 1;
  3094. prop_is_valid = ast_ari_validate_string(
  3095. ast_json_object_iter_value(iter));
  3096. if (!prop_is_valid) {
  3097. ast_log(LOG_ERROR, "ARI ChannelDialplan field dialplan_app failed validation\n");
  3098. res = 0;
  3099. }
  3100. } else
  3101. if (strcmp("dialplan_app_data", ast_json_object_iter_key(iter)) == 0) {
  3102. int prop_is_valid;
  3103. has_dialplan_app_data = 1;
  3104. prop_is_valid = ast_ari_validate_string(
  3105. ast_json_object_iter_value(iter));
  3106. if (!prop_is_valid) {
  3107. ast_log(LOG_ERROR, "ARI ChannelDialplan field dialplan_app_data failed validation\n");
  3108. res = 0;
  3109. }
  3110. } else
  3111. {
  3112. ast_log(LOG_ERROR,
  3113. "ARI ChannelDialplan has undocumented field %s\n",
  3114. ast_json_object_iter_key(iter));
  3115. res = 0;
  3116. }
  3117. }
  3118. if (!has_type) {
  3119. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field type\n");
  3120. res = 0;
  3121. }
  3122. if (!has_application) {
  3123. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field application\n");
  3124. res = 0;
  3125. }
  3126. if (!has_channel) {
  3127. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field channel\n");
  3128. res = 0;
  3129. }
  3130. if (!has_dialplan_app) {
  3131. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field dialplan_app\n");
  3132. res = 0;
  3133. }
  3134. if (!has_dialplan_app_data) {
  3135. ast_log(LOG_ERROR, "ARI ChannelDialplan missing required field dialplan_app_data\n");
  3136. res = 0;
  3137. }
  3138. return res;
  3139. }
  3140. ari_validator ast_ari_validate_channel_dialplan_fn(void)
  3141. {
  3142. return ast_ari_validate_channel_dialplan;
  3143. }
  3144. int ast_ari_validate_channel_dtmf_received(struct ast_json *json)
  3145. {
  3146. int res = 1;
  3147. struct ast_json_iter *iter;
  3148. int has_type = 0;
  3149. int has_application = 0;
  3150. int has_channel = 0;
  3151. int has_digit = 0;
  3152. int has_duration_ms = 0;
  3153. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3154. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3155. int prop_is_valid;
  3156. prop_is_valid = ast_ari_validate_string(
  3157. ast_json_object_iter_value(iter));
  3158. if (!prop_is_valid) {
  3159. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field asterisk_id failed validation\n");
  3160. res = 0;
  3161. }
  3162. } else
  3163. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3164. int prop_is_valid;
  3165. has_type = 1;
  3166. prop_is_valid = ast_ari_validate_string(
  3167. ast_json_object_iter_value(iter));
  3168. if (!prop_is_valid) {
  3169. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field type failed validation\n");
  3170. res = 0;
  3171. }
  3172. } else
  3173. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3174. int prop_is_valid;
  3175. has_application = 1;
  3176. prop_is_valid = ast_ari_validate_string(
  3177. ast_json_object_iter_value(iter));
  3178. if (!prop_is_valid) {
  3179. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field application failed validation\n");
  3180. res = 0;
  3181. }
  3182. } else
  3183. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3184. int prop_is_valid;
  3185. prop_is_valid = ast_ari_validate_date(
  3186. ast_json_object_iter_value(iter));
  3187. if (!prop_is_valid) {
  3188. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field timestamp failed validation\n");
  3189. res = 0;
  3190. }
  3191. } else
  3192. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3193. int prop_is_valid;
  3194. has_channel = 1;
  3195. prop_is_valid = ast_ari_validate_channel(
  3196. ast_json_object_iter_value(iter));
  3197. if (!prop_is_valid) {
  3198. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field channel failed validation\n");
  3199. res = 0;
  3200. }
  3201. } else
  3202. if (strcmp("digit", ast_json_object_iter_key(iter)) == 0) {
  3203. int prop_is_valid;
  3204. has_digit = 1;
  3205. prop_is_valid = ast_ari_validate_string(
  3206. ast_json_object_iter_value(iter));
  3207. if (!prop_is_valid) {
  3208. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field digit failed validation\n");
  3209. res = 0;
  3210. }
  3211. } else
  3212. if (strcmp("duration_ms", ast_json_object_iter_key(iter)) == 0) {
  3213. int prop_is_valid;
  3214. has_duration_ms = 1;
  3215. prop_is_valid = ast_ari_validate_int(
  3216. ast_json_object_iter_value(iter));
  3217. if (!prop_is_valid) {
  3218. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived field duration_ms failed validation\n");
  3219. res = 0;
  3220. }
  3221. } else
  3222. {
  3223. ast_log(LOG_ERROR,
  3224. "ARI ChannelDtmfReceived has undocumented field %s\n",
  3225. ast_json_object_iter_key(iter));
  3226. res = 0;
  3227. }
  3228. }
  3229. if (!has_type) {
  3230. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field type\n");
  3231. res = 0;
  3232. }
  3233. if (!has_application) {
  3234. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field application\n");
  3235. res = 0;
  3236. }
  3237. if (!has_channel) {
  3238. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field channel\n");
  3239. res = 0;
  3240. }
  3241. if (!has_digit) {
  3242. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field digit\n");
  3243. res = 0;
  3244. }
  3245. if (!has_duration_ms) {
  3246. ast_log(LOG_ERROR, "ARI ChannelDtmfReceived missing required field duration_ms\n");
  3247. res = 0;
  3248. }
  3249. return res;
  3250. }
  3251. ari_validator ast_ari_validate_channel_dtmf_received_fn(void)
  3252. {
  3253. return ast_ari_validate_channel_dtmf_received;
  3254. }
  3255. int ast_ari_validate_channel_entered_bridge(struct ast_json *json)
  3256. {
  3257. int res = 1;
  3258. struct ast_json_iter *iter;
  3259. int has_type = 0;
  3260. int has_application = 0;
  3261. int has_bridge = 0;
  3262. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3263. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3264. int prop_is_valid;
  3265. prop_is_valid = ast_ari_validate_string(
  3266. ast_json_object_iter_value(iter));
  3267. if (!prop_is_valid) {
  3268. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field asterisk_id failed validation\n");
  3269. res = 0;
  3270. }
  3271. } else
  3272. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3273. int prop_is_valid;
  3274. has_type = 1;
  3275. prop_is_valid = ast_ari_validate_string(
  3276. ast_json_object_iter_value(iter));
  3277. if (!prop_is_valid) {
  3278. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field type failed validation\n");
  3279. res = 0;
  3280. }
  3281. } else
  3282. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3283. int prop_is_valid;
  3284. has_application = 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 ChannelEnteredBridge field application failed validation\n");
  3289. res = 0;
  3290. }
  3291. } else
  3292. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3293. int prop_is_valid;
  3294. prop_is_valid = ast_ari_validate_date(
  3295. ast_json_object_iter_value(iter));
  3296. if (!prop_is_valid) {
  3297. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field timestamp failed validation\n");
  3298. res = 0;
  3299. }
  3300. } else
  3301. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  3302. int prop_is_valid;
  3303. has_bridge = 1;
  3304. prop_is_valid = ast_ari_validate_bridge(
  3305. ast_json_object_iter_value(iter));
  3306. if (!prop_is_valid) {
  3307. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge field bridge 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 ChannelEnteredBridge field channel failed validation\n");
  3317. res = 0;
  3318. }
  3319. } else
  3320. {
  3321. ast_log(LOG_ERROR,
  3322. "ARI ChannelEnteredBridge has undocumented field %s\n",
  3323. ast_json_object_iter_key(iter));
  3324. res = 0;
  3325. }
  3326. }
  3327. if (!has_type) {
  3328. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field type\n");
  3329. res = 0;
  3330. }
  3331. if (!has_application) {
  3332. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field application\n");
  3333. res = 0;
  3334. }
  3335. if (!has_bridge) {
  3336. ast_log(LOG_ERROR, "ARI ChannelEnteredBridge missing required field bridge\n");
  3337. res = 0;
  3338. }
  3339. return res;
  3340. }
  3341. ari_validator ast_ari_validate_channel_entered_bridge_fn(void)
  3342. {
  3343. return ast_ari_validate_channel_entered_bridge;
  3344. }
  3345. int ast_ari_validate_channel_hangup_request(struct ast_json *json)
  3346. {
  3347. int res = 1;
  3348. struct ast_json_iter *iter;
  3349. int has_type = 0;
  3350. int has_application = 0;
  3351. int has_channel = 0;
  3352. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3353. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3354. int prop_is_valid;
  3355. prop_is_valid = ast_ari_validate_string(
  3356. ast_json_object_iter_value(iter));
  3357. if (!prop_is_valid) {
  3358. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field asterisk_id failed validation\n");
  3359. res = 0;
  3360. }
  3361. } else
  3362. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3363. int prop_is_valid;
  3364. has_type = 1;
  3365. prop_is_valid = ast_ari_validate_string(
  3366. ast_json_object_iter_value(iter));
  3367. if (!prop_is_valid) {
  3368. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field type failed validation\n");
  3369. res = 0;
  3370. }
  3371. } else
  3372. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3373. int prop_is_valid;
  3374. has_application = 1;
  3375. prop_is_valid = ast_ari_validate_string(
  3376. ast_json_object_iter_value(iter));
  3377. if (!prop_is_valid) {
  3378. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field application failed validation\n");
  3379. res = 0;
  3380. }
  3381. } else
  3382. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3383. int prop_is_valid;
  3384. prop_is_valid = ast_ari_validate_date(
  3385. ast_json_object_iter_value(iter));
  3386. if (!prop_is_valid) {
  3387. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field timestamp failed validation\n");
  3388. res = 0;
  3389. }
  3390. } else
  3391. if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
  3392. int prop_is_valid;
  3393. prop_is_valid = ast_ari_validate_int(
  3394. ast_json_object_iter_value(iter));
  3395. if (!prop_is_valid) {
  3396. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field cause failed validation\n");
  3397. res = 0;
  3398. }
  3399. } else
  3400. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3401. int prop_is_valid;
  3402. has_channel = 1;
  3403. prop_is_valid = ast_ari_validate_channel(
  3404. ast_json_object_iter_value(iter));
  3405. if (!prop_is_valid) {
  3406. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field channel failed validation\n");
  3407. res = 0;
  3408. }
  3409. } else
  3410. if (strcmp("soft", ast_json_object_iter_key(iter)) == 0) {
  3411. int prop_is_valid;
  3412. prop_is_valid = ast_ari_validate_boolean(
  3413. ast_json_object_iter_value(iter));
  3414. if (!prop_is_valid) {
  3415. ast_log(LOG_ERROR, "ARI ChannelHangupRequest field soft failed validation\n");
  3416. res = 0;
  3417. }
  3418. } else
  3419. {
  3420. ast_log(LOG_ERROR,
  3421. "ARI ChannelHangupRequest has undocumented field %s\n",
  3422. ast_json_object_iter_key(iter));
  3423. res = 0;
  3424. }
  3425. }
  3426. if (!has_type) {
  3427. ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field type\n");
  3428. res = 0;
  3429. }
  3430. if (!has_application) {
  3431. ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field application\n");
  3432. res = 0;
  3433. }
  3434. if (!has_channel) {
  3435. ast_log(LOG_ERROR, "ARI ChannelHangupRequest missing required field channel\n");
  3436. res = 0;
  3437. }
  3438. return res;
  3439. }
  3440. ari_validator ast_ari_validate_channel_hangup_request_fn(void)
  3441. {
  3442. return ast_ari_validate_channel_hangup_request;
  3443. }
  3444. int ast_ari_validate_channel_hold(struct ast_json *json)
  3445. {
  3446. int res = 1;
  3447. struct ast_json_iter *iter;
  3448. int has_type = 0;
  3449. int has_application = 0;
  3450. int has_channel = 0;
  3451. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3452. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3453. int prop_is_valid;
  3454. prop_is_valid = ast_ari_validate_string(
  3455. ast_json_object_iter_value(iter));
  3456. if (!prop_is_valid) {
  3457. ast_log(LOG_ERROR, "ARI ChannelHold field asterisk_id failed validation\n");
  3458. res = 0;
  3459. }
  3460. } else
  3461. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3462. int prop_is_valid;
  3463. has_type = 1;
  3464. prop_is_valid = ast_ari_validate_string(
  3465. ast_json_object_iter_value(iter));
  3466. if (!prop_is_valid) {
  3467. ast_log(LOG_ERROR, "ARI ChannelHold field type failed validation\n");
  3468. res = 0;
  3469. }
  3470. } else
  3471. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3472. int prop_is_valid;
  3473. has_application = 1;
  3474. prop_is_valid = ast_ari_validate_string(
  3475. ast_json_object_iter_value(iter));
  3476. if (!prop_is_valid) {
  3477. ast_log(LOG_ERROR, "ARI ChannelHold field application failed validation\n");
  3478. res = 0;
  3479. }
  3480. } else
  3481. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3482. int prop_is_valid;
  3483. prop_is_valid = ast_ari_validate_date(
  3484. ast_json_object_iter_value(iter));
  3485. if (!prop_is_valid) {
  3486. ast_log(LOG_ERROR, "ARI ChannelHold field timestamp failed validation\n");
  3487. res = 0;
  3488. }
  3489. } else
  3490. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3491. int prop_is_valid;
  3492. has_channel = 1;
  3493. prop_is_valid = ast_ari_validate_channel(
  3494. ast_json_object_iter_value(iter));
  3495. if (!prop_is_valid) {
  3496. ast_log(LOG_ERROR, "ARI ChannelHold field channel failed validation\n");
  3497. res = 0;
  3498. }
  3499. } else
  3500. if (strcmp("musicclass", ast_json_object_iter_key(iter)) == 0) {
  3501. int prop_is_valid;
  3502. prop_is_valid = ast_ari_validate_string(
  3503. ast_json_object_iter_value(iter));
  3504. if (!prop_is_valid) {
  3505. ast_log(LOG_ERROR, "ARI ChannelHold field musicclass failed validation\n");
  3506. res = 0;
  3507. }
  3508. } else
  3509. {
  3510. ast_log(LOG_ERROR,
  3511. "ARI ChannelHold has undocumented field %s\n",
  3512. ast_json_object_iter_key(iter));
  3513. res = 0;
  3514. }
  3515. }
  3516. if (!has_type) {
  3517. ast_log(LOG_ERROR, "ARI ChannelHold missing required field type\n");
  3518. res = 0;
  3519. }
  3520. if (!has_application) {
  3521. ast_log(LOG_ERROR, "ARI ChannelHold missing required field application\n");
  3522. res = 0;
  3523. }
  3524. if (!has_channel) {
  3525. ast_log(LOG_ERROR, "ARI ChannelHold missing required field channel\n");
  3526. res = 0;
  3527. }
  3528. return res;
  3529. }
  3530. ari_validator ast_ari_validate_channel_hold_fn(void)
  3531. {
  3532. return ast_ari_validate_channel_hold;
  3533. }
  3534. int ast_ari_validate_channel_left_bridge(struct ast_json *json)
  3535. {
  3536. int res = 1;
  3537. struct ast_json_iter *iter;
  3538. int has_type = 0;
  3539. int has_application = 0;
  3540. int has_bridge = 0;
  3541. int has_channel = 0;
  3542. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3543. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3544. int prop_is_valid;
  3545. prop_is_valid = ast_ari_validate_string(
  3546. ast_json_object_iter_value(iter));
  3547. if (!prop_is_valid) {
  3548. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field asterisk_id failed validation\n");
  3549. res = 0;
  3550. }
  3551. } else
  3552. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3553. int prop_is_valid;
  3554. has_type = 1;
  3555. prop_is_valid = ast_ari_validate_string(
  3556. ast_json_object_iter_value(iter));
  3557. if (!prop_is_valid) {
  3558. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field type failed validation\n");
  3559. res = 0;
  3560. }
  3561. } else
  3562. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3563. int prop_is_valid;
  3564. has_application = 1;
  3565. prop_is_valid = ast_ari_validate_string(
  3566. ast_json_object_iter_value(iter));
  3567. if (!prop_is_valid) {
  3568. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field application failed validation\n");
  3569. res = 0;
  3570. }
  3571. } else
  3572. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3573. int prop_is_valid;
  3574. prop_is_valid = ast_ari_validate_date(
  3575. ast_json_object_iter_value(iter));
  3576. if (!prop_is_valid) {
  3577. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field timestamp failed validation\n");
  3578. res = 0;
  3579. }
  3580. } else
  3581. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  3582. int prop_is_valid;
  3583. has_bridge = 1;
  3584. prop_is_valid = ast_ari_validate_bridge(
  3585. ast_json_object_iter_value(iter));
  3586. if (!prop_is_valid) {
  3587. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field bridge failed validation\n");
  3588. res = 0;
  3589. }
  3590. } else
  3591. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3592. int prop_is_valid;
  3593. has_channel = 1;
  3594. prop_is_valid = ast_ari_validate_channel(
  3595. ast_json_object_iter_value(iter));
  3596. if (!prop_is_valid) {
  3597. ast_log(LOG_ERROR, "ARI ChannelLeftBridge field channel failed validation\n");
  3598. res = 0;
  3599. }
  3600. } else
  3601. {
  3602. ast_log(LOG_ERROR,
  3603. "ARI ChannelLeftBridge has undocumented field %s\n",
  3604. ast_json_object_iter_key(iter));
  3605. res = 0;
  3606. }
  3607. }
  3608. if (!has_type) {
  3609. ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field type\n");
  3610. res = 0;
  3611. }
  3612. if (!has_application) {
  3613. ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field application\n");
  3614. res = 0;
  3615. }
  3616. if (!has_bridge) {
  3617. ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field bridge\n");
  3618. res = 0;
  3619. }
  3620. if (!has_channel) {
  3621. ast_log(LOG_ERROR, "ARI ChannelLeftBridge missing required field channel\n");
  3622. res = 0;
  3623. }
  3624. return res;
  3625. }
  3626. ari_validator ast_ari_validate_channel_left_bridge_fn(void)
  3627. {
  3628. return ast_ari_validate_channel_left_bridge;
  3629. }
  3630. int ast_ari_validate_channel_state_change(struct ast_json *json)
  3631. {
  3632. int res = 1;
  3633. struct ast_json_iter *iter;
  3634. int has_type = 0;
  3635. int has_application = 0;
  3636. int has_channel = 0;
  3637. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3638. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3639. int prop_is_valid;
  3640. prop_is_valid = ast_ari_validate_string(
  3641. ast_json_object_iter_value(iter));
  3642. if (!prop_is_valid) {
  3643. ast_log(LOG_ERROR, "ARI ChannelStateChange field asterisk_id failed validation\n");
  3644. res = 0;
  3645. }
  3646. } else
  3647. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3648. int prop_is_valid;
  3649. has_type = 1;
  3650. prop_is_valid = ast_ari_validate_string(
  3651. ast_json_object_iter_value(iter));
  3652. if (!prop_is_valid) {
  3653. ast_log(LOG_ERROR, "ARI ChannelStateChange field type failed validation\n");
  3654. res = 0;
  3655. }
  3656. } else
  3657. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3658. int prop_is_valid;
  3659. has_application = 1;
  3660. prop_is_valid = ast_ari_validate_string(
  3661. ast_json_object_iter_value(iter));
  3662. if (!prop_is_valid) {
  3663. ast_log(LOG_ERROR, "ARI ChannelStateChange field application failed validation\n");
  3664. res = 0;
  3665. }
  3666. } else
  3667. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3668. int prop_is_valid;
  3669. prop_is_valid = ast_ari_validate_date(
  3670. ast_json_object_iter_value(iter));
  3671. if (!prop_is_valid) {
  3672. ast_log(LOG_ERROR, "ARI ChannelStateChange field timestamp failed validation\n");
  3673. res = 0;
  3674. }
  3675. } else
  3676. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3677. int prop_is_valid;
  3678. has_channel = 1;
  3679. prop_is_valid = ast_ari_validate_channel(
  3680. ast_json_object_iter_value(iter));
  3681. if (!prop_is_valid) {
  3682. ast_log(LOG_ERROR, "ARI ChannelStateChange field channel failed validation\n");
  3683. res = 0;
  3684. }
  3685. } else
  3686. {
  3687. ast_log(LOG_ERROR,
  3688. "ARI ChannelStateChange has undocumented field %s\n",
  3689. ast_json_object_iter_key(iter));
  3690. res = 0;
  3691. }
  3692. }
  3693. if (!has_type) {
  3694. ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field type\n");
  3695. res = 0;
  3696. }
  3697. if (!has_application) {
  3698. ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field application\n");
  3699. res = 0;
  3700. }
  3701. if (!has_channel) {
  3702. ast_log(LOG_ERROR, "ARI ChannelStateChange missing required field channel\n");
  3703. res = 0;
  3704. }
  3705. return res;
  3706. }
  3707. ari_validator ast_ari_validate_channel_state_change_fn(void)
  3708. {
  3709. return ast_ari_validate_channel_state_change;
  3710. }
  3711. int ast_ari_validate_channel_talking_finished(struct ast_json *json)
  3712. {
  3713. int res = 1;
  3714. struct ast_json_iter *iter;
  3715. int has_type = 0;
  3716. int has_application = 0;
  3717. int has_channel = 0;
  3718. int has_duration = 0;
  3719. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3720. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3721. int prop_is_valid;
  3722. prop_is_valid = ast_ari_validate_string(
  3723. ast_json_object_iter_value(iter));
  3724. if (!prop_is_valid) {
  3725. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field asterisk_id failed validation\n");
  3726. res = 0;
  3727. }
  3728. } else
  3729. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3730. int prop_is_valid;
  3731. has_type = 1;
  3732. prop_is_valid = ast_ari_validate_string(
  3733. ast_json_object_iter_value(iter));
  3734. if (!prop_is_valid) {
  3735. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field type failed validation\n");
  3736. res = 0;
  3737. }
  3738. } else
  3739. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3740. int prop_is_valid;
  3741. has_application = 1;
  3742. prop_is_valid = ast_ari_validate_string(
  3743. ast_json_object_iter_value(iter));
  3744. if (!prop_is_valid) {
  3745. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field application failed validation\n");
  3746. res = 0;
  3747. }
  3748. } else
  3749. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3750. int prop_is_valid;
  3751. prop_is_valid = ast_ari_validate_date(
  3752. ast_json_object_iter_value(iter));
  3753. if (!prop_is_valid) {
  3754. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field timestamp failed validation\n");
  3755. res = 0;
  3756. }
  3757. } else
  3758. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3759. int prop_is_valid;
  3760. has_channel = 1;
  3761. prop_is_valid = ast_ari_validate_channel(
  3762. ast_json_object_iter_value(iter));
  3763. if (!prop_is_valid) {
  3764. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field channel failed validation\n");
  3765. res = 0;
  3766. }
  3767. } else
  3768. if (strcmp("duration", ast_json_object_iter_key(iter)) == 0) {
  3769. int prop_is_valid;
  3770. has_duration = 1;
  3771. prop_is_valid = ast_ari_validate_int(
  3772. ast_json_object_iter_value(iter));
  3773. if (!prop_is_valid) {
  3774. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished field duration failed validation\n");
  3775. res = 0;
  3776. }
  3777. } else
  3778. {
  3779. ast_log(LOG_ERROR,
  3780. "ARI ChannelTalkingFinished has undocumented field %s\n",
  3781. ast_json_object_iter_key(iter));
  3782. res = 0;
  3783. }
  3784. }
  3785. if (!has_type) {
  3786. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished missing required field type\n");
  3787. res = 0;
  3788. }
  3789. if (!has_application) {
  3790. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished missing required field application\n");
  3791. res = 0;
  3792. }
  3793. if (!has_channel) {
  3794. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished missing required field channel\n");
  3795. res = 0;
  3796. }
  3797. if (!has_duration) {
  3798. ast_log(LOG_ERROR, "ARI ChannelTalkingFinished missing required field duration\n");
  3799. res = 0;
  3800. }
  3801. return res;
  3802. }
  3803. ari_validator ast_ari_validate_channel_talking_finished_fn(void)
  3804. {
  3805. return ast_ari_validate_channel_talking_finished;
  3806. }
  3807. int ast_ari_validate_channel_talking_started(struct ast_json *json)
  3808. {
  3809. int res = 1;
  3810. struct ast_json_iter *iter;
  3811. int has_type = 0;
  3812. int has_application = 0;
  3813. int has_channel = 0;
  3814. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3815. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3816. int prop_is_valid;
  3817. prop_is_valid = ast_ari_validate_string(
  3818. ast_json_object_iter_value(iter));
  3819. if (!prop_is_valid) {
  3820. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field asterisk_id failed validation\n");
  3821. res = 0;
  3822. }
  3823. } else
  3824. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3825. int prop_is_valid;
  3826. has_type = 1;
  3827. prop_is_valid = ast_ari_validate_string(
  3828. ast_json_object_iter_value(iter));
  3829. if (!prop_is_valid) {
  3830. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field type failed validation\n");
  3831. res = 0;
  3832. }
  3833. } else
  3834. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3835. int prop_is_valid;
  3836. has_application = 1;
  3837. prop_is_valid = ast_ari_validate_string(
  3838. ast_json_object_iter_value(iter));
  3839. if (!prop_is_valid) {
  3840. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field application failed validation\n");
  3841. res = 0;
  3842. }
  3843. } else
  3844. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3845. int prop_is_valid;
  3846. prop_is_valid = ast_ari_validate_date(
  3847. ast_json_object_iter_value(iter));
  3848. if (!prop_is_valid) {
  3849. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field timestamp failed validation\n");
  3850. res = 0;
  3851. }
  3852. } else
  3853. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3854. int prop_is_valid;
  3855. has_channel = 1;
  3856. prop_is_valid = ast_ari_validate_channel(
  3857. ast_json_object_iter_value(iter));
  3858. if (!prop_is_valid) {
  3859. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted field channel failed validation\n");
  3860. res = 0;
  3861. }
  3862. } else
  3863. {
  3864. ast_log(LOG_ERROR,
  3865. "ARI ChannelTalkingStarted has undocumented field %s\n",
  3866. ast_json_object_iter_key(iter));
  3867. res = 0;
  3868. }
  3869. }
  3870. if (!has_type) {
  3871. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted missing required field type\n");
  3872. res = 0;
  3873. }
  3874. if (!has_application) {
  3875. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted missing required field application\n");
  3876. res = 0;
  3877. }
  3878. if (!has_channel) {
  3879. ast_log(LOG_ERROR, "ARI ChannelTalkingStarted missing required field channel\n");
  3880. res = 0;
  3881. }
  3882. return res;
  3883. }
  3884. ari_validator ast_ari_validate_channel_talking_started_fn(void)
  3885. {
  3886. return ast_ari_validate_channel_talking_started;
  3887. }
  3888. int ast_ari_validate_channel_unhold(struct ast_json *json)
  3889. {
  3890. int res = 1;
  3891. struct ast_json_iter *iter;
  3892. int has_type = 0;
  3893. int has_application = 0;
  3894. int has_channel = 0;
  3895. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3896. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3897. int prop_is_valid;
  3898. prop_is_valid = ast_ari_validate_string(
  3899. ast_json_object_iter_value(iter));
  3900. if (!prop_is_valid) {
  3901. ast_log(LOG_ERROR, "ARI ChannelUnhold field asterisk_id failed validation\n");
  3902. res = 0;
  3903. }
  3904. } else
  3905. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3906. int prop_is_valid;
  3907. has_type = 1;
  3908. prop_is_valid = ast_ari_validate_string(
  3909. ast_json_object_iter_value(iter));
  3910. if (!prop_is_valid) {
  3911. ast_log(LOG_ERROR, "ARI ChannelUnhold field type failed validation\n");
  3912. res = 0;
  3913. }
  3914. } else
  3915. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3916. int prop_is_valid;
  3917. has_application = 1;
  3918. prop_is_valid = ast_ari_validate_string(
  3919. ast_json_object_iter_value(iter));
  3920. if (!prop_is_valid) {
  3921. ast_log(LOG_ERROR, "ARI ChannelUnhold field application failed validation\n");
  3922. res = 0;
  3923. }
  3924. } else
  3925. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  3926. int prop_is_valid;
  3927. prop_is_valid = ast_ari_validate_date(
  3928. ast_json_object_iter_value(iter));
  3929. if (!prop_is_valid) {
  3930. ast_log(LOG_ERROR, "ARI ChannelUnhold field timestamp failed validation\n");
  3931. res = 0;
  3932. }
  3933. } else
  3934. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  3935. int prop_is_valid;
  3936. has_channel = 1;
  3937. prop_is_valid = ast_ari_validate_channel(
  3938. ast_json_object_iter_value(iter));
  3939. if (!prop_is_valid) {
  3940. ast_log(LOG_ERROR, "ARI ChannelUnhold field channel failed validation\n");
  3941. res = 0;
  3942. }
  3943. } else
  3944. {
  3945. ast_log(LOG_ERROR,
  3946. "ARI ChannelUnhold has undocumented field %s\n",
  3947. ast_json_object_iter_key(iter));
  3948. res = 0;
  3949. }
  3950. }
  3951. if (!has_type) {
  3952. ast_log(LOG_ERROR, "ARI ChannelUnhold missing required field type\n");
  3953. res = 0;
  3954. }
  3955. if (!has_application) {
  3956. ast_log(LOG_ERROR, "ARI ChannelUnhold missing required field application\n");
  3957. res = 0;
  3958. }
  3959. if (!has_channel) {
  3960. ast_log(LOG_ERROR, "ARI ChannelUnhold missing required field channel\n");
  3961. res = 0;
  3962. }
  3963. return res;
  3964. }
  3965. ari_validator ast_ari_validate_channel_unhold_fn(void)
  3966. {
  3967. return ast_ari_validate_channel_unhold;
  3968. }
  3969. int ast_ari_validate_channel_userevent(struct ast_json *json)
  3970. {
  3971. int res = 1;
  3972. struct ast_json_iter *iter;
  3973. int has_type = 0;
  3974. int has_application = 0;
  3975. int has_eventname = 0;
  3976. int has_userevent = 0;
  3977. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  3978. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  3979. int prop_is_valid;
  3980. prop_is_valid = ast_ari_validate_string(
  3981. ast_json_object_iter_value(iter));
  3982. if (!prop_is_valid) {
  3983. ast_log(LOG_ERROR, "ARI ChannelUserevent field asterisk_id failed validation\n");
  3984. res = 0;
  3985. }
  3986. } else
  3987. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  3988. int prop_is_valid;
  3989. has_type = 1;
  3990. prop_is_valid = ast_ari_validate_string(
  3991. ast_json_object_iter_value(iter));
  3992. if (!prop_is_valid) {
  3993. ast_log(LOG_ERROR, "ARI ChannelUserevent field type failed validation\n");
  3994. res = 0;
  3995. }
  3996. } else
  3997. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  3998. int prop_is_valid;
  3999. has_application = 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 ChannelUserevent field application failed validation\n");
  4004. res = 0;
  4005. }
  4006. } else
  4007. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4008. int prop_is_valid;
  4009. prop_is_valid = ast_ari_validate_date(
  4010. ast_json_object_iter_value(iter));
  4011. if (!prop_is_valid) {
  4012. ast_log(LOG_ERROR, "ARI ChannelUserevent field timestamp failed validation\n");
  4013. res = 0;
  4014. }
  4015. } else
  4016. if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
  4017. int prop_is_valid;
  4018. prop_is_valid = ast_ari_validate_bridge(
  4019. ast_json_object_iter_value(iter));
  4020. if (!prop_is_valid) {
  4021. ast_log(LOG_ERROR, "ARI ChannelUserevent field bridge failed validation\n");
  4022. res = 0;
  4023. }
  4024. } else
  4025. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  4026. int prop_is_valid;
  4027. prop_is_valid = ast_ari_validate_channel(
  4028. ast_json_object_iter_value(iter));
  4029. if (!prop_is_valid) {
  4030. ast_log(LOG_ERROR, "ARI ChannelUserevent field channel failed validation\n");
  4031. res = 0;
  4032. }
  4033. } else
  4034. if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
  4035. int prop_is_valid;
  4036. prop_is_valid = ast_ari_validate_endpoint(
  4037. ast_json_object_iter_value(iter));
  4038. if (!prop_is_valid) {
  4039. ast_log(LOG_ERROR, "ARI ChannelUserevent field endpoint failed validation\n");
  4040. res = 0;
  4041. }
  4042. } else
  4043. if (strcmp("eventname", ast_json_object_iter_key(iter)) == 0) {
  4044. int prop_is_valid;
  4045. has_eventname = 1;
  4046. prop_is_valid = ast_ari_validate_string(
  4047. ast_json_object_iter_value(iter));
  4048. if (!prop_is_valid) {
  4049. ast_log(LOG_ERROR, "ARI ChannelUserevent field eventname failed validation\n");
  4050. res = 0;
  4051. }
  4052. } else
  4053. if (strcmp("userevent", ast_json_object_iter_key(iter)) == 0) {
  4054. int prop_is_valid;
  4055. has_userevent = 1;
  4056. prop_is_valid = ast_ari_validate_object(
  4057. ast_json_object_iter_value(iter));
  4058. if (!prop_is_valid) {
  4059. ast_log(LOG_ERROR, "ARI ChannelUserevent field userevent failed validation\n");
  4060. res = 0;
  4061. }
  4062. } else
  4063. {
  4064. ast_log(LOG_ERROR,
  4065. "ARI ChannelUserevent has undocumented field %s\n",
  4066. ast_json_object_iter_key(iter));
  4067. res = 0;
  4068. }
  4069. }
  4070. if (!has_type) {
  4071. ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field type\n");
  4072. res = 0;
  4073. }
  4074. if (!has_application) {
  4075. ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field application\n");
  4076. res = 0;
  4077. }
  4078. if (!has_eventname) {
  4079. ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field eventname\n");
  4080. res = 0;
  4081. }
  4082. if (!has_userevent) {
  4083. ast_log(LOG_ERROR, "ARI ChannelUserevent missing required field userevent\n");
  4084. res = 0;
  4085. }
  4086. return res;
  4087. }
  4088. ari_validator ast_ari_validate_channel_userevent_fn(void)
  4089. {
  4090. return ast_ari_validate_channel_userevent;
  4091. }
  4092. int ast_ari_validate_channel_varset(struct ast_json *json)
  4093. {
  4094. int res = 1;
  4095. struct ast_json_iter *iter;
  4096. int has_type = 0;
  4097. int has_application = 0;
  4098. int has_value = 0;
  4099. int has_variable = 0;
  4100. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4101. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  4102. int prop_is_valid;
  4103. prop_is_valid = ast_ari_validate_string(
  4104. ast_json_object_iter_value(iter));
  4105. if (!prop_is_valid) {
  4106. ast_log(LOG_ERROR, "ARI ChannelVarset field asterisk_id failed validation\n");
  4107. res = 0;
  4108. }
  4109. } else
  4110. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4111. int prop_is_valid;
  4112. has_type = 1;
  4113. prop_is_valid = ast_ari_validate_string(
  4114. ast_json_object_iter_value(iter));
  4115. if (!prop_is_valid) {
  4116. ast_log(LOG_ERROR, "ARI ChannelVarset field type failed validation\n");
  4117. res = 0;
  4118. }
  4119. } else
  4120. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4121. int prop_is_valid;
  4122. has_application = 1;
  4123. prop_is_valid = ast_ari_validate_string(
  4124. ast_json_object_iter_value(iter));
  4125. if (!prop_is_valid) {
  4126. ast_log(LOG_ERROR, "ARI ChannelVarset field application failed validation\n");
  4127. res = 0;
  4128. }
  4129. } else
  4130. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4131. int prop_is_valid;
  4132. prop_is_valid = ast_ari_validate_date(
  4133. ast_json_object_iter_value(iter));
  4134. if (!prop_is_valid) {
  4135. ast_log(LOG_ERROR, "ARI ChannelVarset field timestamp failed validation\n");
  4136. res = 0;
  4137. }
  4138. } else
  4139. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  4140. int prop_is_valid;
  4141. prop_is_valid = ast_ari_validate_channel(
  4142. ast_json_object_iter_value(iter));
  4143. if (!prop_is_valid) {
  4144. ast_log(LOG_ERROR, "ARI ChannelVarset field channel failed validation\n");
  4145. res = 0;
  4146. }
  4147. } else
  4148. if (strcmp("value", ast_json_object_iter_key(iter)) == 0) {
  4149. int prop_is_valid;
  4150. has_value = 1;
  4151. prop_is_valid = ast_ari_validate_string(
  4152. ast_json_object_iter_value(iter));
  4153. if (!prop_is_valid) {
  4154. ast_log(LOG_ERROR, "ARI ChannelVarset field value failed validation\n");
  4155. res = 0;
  4156. }
  4157. } else
  4158. if (strcmp("variable", ast_json_object_iter_key(iter)) == 0) {
  4159. int prop_is_valid;
  4160. has_variable = 1;
  4161. prop_is_valid = ast_ari_validate_string(
  4162. ast_json_object_iter_value(iter));
  4163. if (!prop_is_valid) {
  4164. ast_log(LOG_ERROR, "ARI ChannelVarset field variable failed validation\n");
  4165. res = 0;
  4166. }
  4167. } else
  4168. {
  4169. ast_log(LOG_ERROR,
  4170. "ARI ChannelVarset has undocumented field %s\n",
  4171. ast_json_object_iter_key(iter));
  4172. res = 0;
  4173. }
  4174. }
  4175. if (!has_type) {
  4176. ast_log(LOG_ERROR, "ARI ChannelVarset missing required field type\n");
  4177. res = 0;
  4178. }
  4179. if (!has_application) {
  4180. ast_log(LOG_ERROR, "ARI ChannelVarset missing required field application\n");
  4181. res = 0;
  4182. }
  4183. if (!has_value) {
  4184. ast_log(LOG_ERROR, "ARI ChannelVarset missing required field value\n");
  4185. res = 0;
  4186. }
  4187. if (!has_variable) {
  4188. ast_log(LOG_ERROR, "ARI ChannelVarset missing required field variable\n");
  4189. res = 0;
  4190. }
  4191. return res;
  4192. }
  4193. ari_validator ast_ari_validate_channel_varset_fn(void)
  4194. {
  4195. return ast_ari_validate_channel_varset;
  4196. }
  4197. int ast_ari_validate_contact_info(struct ast_json *json)
  4198. {
  4199. int res = 1;
  4200. struct ast_json_iter *iter;
  4201. int has_aor = 0;
  4202. int has_contact_status = 0;
  4203. int has_uri = 0;
  4204. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4205. if (strcmp("aor", ast_json_object_iter_key(iter)) == 0) {
  4206. int prop_is_valid;
  4207. has_aor = 1;
  4208. prop_is_valid = ast_ari_validate_string(
  4209. ast_json_object_iter_value(iter));
  4210. if (!prop_is_valid) {
  4211. ast_log(LOG_ERROR, "ARI ContactInfo field aor failed validation\n");
  4212. res = 0;
  4213. }
  4214. } else
  4215. if (strcmp("contact_status", ast_json_object_iter_key(iter)) == 0) {
  4216. int prop_is_valid;
  4217. has_contact_status = 1;
  4218. prop_is_valid = ast_ari_validate_string(
  4219. ast_json_object_iter_value(iter));
  4220. if (!prop_is_valid) {
  4221. ast_log(LOG_ERROR, "ARI ContactInfo field contact_status failed validation\n");
  4222. res = 0;
  4223. }
  4224. } else
  4225. if (strcmp("roundtrip_usec", ast_json_object_iter_key(iter)) == 0) {
  4226. int prop_is_valid;
  4227. prop_is_valid = ast_ari_validate_string(
  4228. ast_json_object_iter_value(iter));
  4229. if (!prop_is_valid) {
  4230. ast_log(LOG_ERROR, "ARI ContactInfo field roundtrip_usec failed validation\n");
  4231. res = 0;
  4232. }
  4233. } else
  4234. if (strcmp("uri", ast_json_object_iter_key(iter)) == 0) {
  4235. int prop_is_valid;
  4236. has_uri = 1;
  4237. prop_is_valid = ast_ari_validate_string(
  4238. ast_json_object_iter_value(iter));
  4239. if (!prop_is_valid) {
  4240. ast_log(LOG_ERROR, "ARI ContactInfo field uri failed validation\n");
  4241. res = 0;
  4242. }
  4243. } else
  4244. {
  4245. ast_log(LOG_ERROR,
  4246. "ARI ContactInfo has undocumented field %s\n",
  4247. ast_json_object_iter_key(iter));
  4248. res = 0;
  4249. }
  4250. }
  4251. if (!has_aor) {
  4252. ast_log(LOG_ERROR, "ARI ContactInfo missing required field aor\n");
  4253. res = 0;
  4254. }
  4255. if (!has_contact_status) {
  4256. ast_log(LOG_ERROR, "ARI ContactInfo missing required field contact_status\n");
  4257. res = 0;
  4258. }
  4259. if (!has_uri) {
  4260. ast_log(LOG_ERROR, "ARI ContactInfo missing required field uri\n");
  4261. res = 0;
  4262. }
  4263. return res;
  4264. }
  4265. ari_validator ast_ari_validate_contact_info_fn(void)
  4266. {
  4267. return ast_ari_validate_contact_info;
  4268. }
  4269. int ast_ari_validate_contact_status_change(struct ast_json *json)
  4270. {
  4271. int res = 1;
  4272. struct ast_json_iter *iter;
  4273. int has_type = 0;
  4274. int has_application = 0;
  4275. int has_contact_info = 0;
  4276. int has_endpoint = 0;
  4277. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4278. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  4279. int prop_is_valid;
  4280. prop_is_valid = ast_ari_validate_string(
  4281. ast_json_object_iter_value(iter));
  4282. if (!prop_is_valid) {
  4283. ast_log(LOG_ERROR, "ARI ContactStatusChange field asterisk_id failed validation\n");
  4284. res = 0;
  4285. }
  4286. } else
  4287. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4288. int prop_is_valid;
  4289. has_type = 1;
  4290. prop_is_valid = ast_ari_validate_string(
  4291. ast_json_object_iter_value(iter));
  4292. if (!prop_is_valid) {
  4293. ast_log(LOG_ERROR, "ARI ContactStatusChange field type failed validation\n");
  4294. res = 0;
  4295. }
  4296. } else
  4297. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4298. int prop_is_valid;
  4299. has_application = 1;
  4300. prop_is_valid = ast_ari_validate_string(
  4301. ast_json_object_iter_value(iter));
  4302. if (!prop_is_valid) {
  4303. ast_log(LOG_ERROR, "ARI ContactStatusChange field application failed validation\n");
  4304. res = 0;
  4305. }
  4306. } else
  4307. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4308. int prop_is_valid;
  4309. prop_is_valid = ast_ari_validate_date(
  4310. ast_json_object_iter_value(iter));
  4311. if (!prop_is_valid) {
  4312. ast_log(LOG_ERROR, "ARI ContactStatusChange field timestamp failed validation\n");
  4313. res = 0;
  4314. }
  4315. } else
  4316. if (strcmp("contact_info", ast_json_object_iter_key(iter)) == 0) {
  4317. int prop_is_valid;
  4318. has_contact_info = 1;
  4319. prop_is_valid = ast_ari_validate_contact_info(
  4320. ast_json_object_iter_value(iter));
  4321. if (!prop_is_valid) {
  4322. ast_log(LOG_ERROR, "ARI ContactStatusChange field contact_info failed validation\n");
  4323. res = 0;
  4324. }
  4325. } else
  4326. if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
  4327. int prop_is_valid;
  4328. has_endpoint = 1;
  4329. prop_is_valid = ast_ari_validate_endpoint(
  4330. ast_json_object_iter_value(iter));
  4331. if (!prop_is_valid) {
  4332. ast_log(LOG_ERROR, "ARI ContactStatusChange field endpoint failed validation\n");
  4333. res = 0;
  4334. }
  4335. } else
  4336. {
  4337. ast_log(LOG_ERROR,
  4338. "ARI ContactStatusChange has undocumented field %s\n",
  4339. ast_json_object_iter_key(iter));
  4340. res = 0;
  4341. }
  4342. }
  4343. if (!has_type) {
  4344. ast_log(LOG_ERROR, "ARI ContactStatusChange missing required field type\n");
  4345. res = 0;
  4346. }
  4347. if (!has_application) {
  4348. ast_log(LOG_ERROR, "ARI ContactStatusChange missing required field application\n");
  4349. res = 0;
  4350. }
  4351. if (!has_contact_info) {
  4352. ast_log(LOG_ERROR, "ARI ContactStatusChange missing required field contact_info\n");
  4353. res = 0;
  4354. }
  4355. if (!has_endpoint) {
  4356. ast_log(LOG_ERROR, "ARI ContactStatusChange missing required field endpoint\n");
  4357. res = 0;
  4358. }
  4359. return res;
  4360. }
  4361. ari_validator ast_ari_validate_contact_status_change_fn(void)
  4362. {
  4363. return ast_ari_validate_contact_status_change;
  4364. }
  4365. int ast_ari_validate_device_state_changed(struct ast_json *json)
  4366. {
  4367. int res = 1;
  4368. struct ast_json_iter *iter;
  4369. int has_type = 0;
  4370. int has_application = 0;
  4371. int has_device_state = 0;
  4372. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4373. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  4374. int prop_is_valid;
  4375. prop_is_valid = ast_ari_validate_string(
  4376. ast_json_object_iter_value(iter));
  4377. if (!prop_is_valid) {
  4378. ast_log(LOG_ERROR, "ARI DeviceStateChanged field asterisk_id failed validation\n");
  4379. res = 0;
  4380. }
  4381. } else
  4382. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4383. int prop_is_valid;
  4384. has_type = 1;
  4385. prop_is_valid = ast_ari_validate_string(
  4386. ast_json_object_iter_value(iter));
  4387. if (!prop_is_valid) {
  4388. ast_log(LOG_ERROR, "ARI DeviceStateChanged field type failed validation\n");
  4389. res = 0;
  4390. }
  4391. } else
  4392. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4393. int prop_is_valid;
  4394. has_application = 1;
  4395. prop_is_valid = ast_ari_validate_string(
  4396. ast_json_object_iter_value(iter));
  4397. if (!prop_is_valid) {
  4398. ast_log(LOG_ERROR, "ARI DeviceStateChanged field application failed validation\n");
  4399. res = 0;
  4400. }
  4401. } else
  4402. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4403. int prop_is_valid;
  4404. prop_is_valid = ast_ari_validate_date(
  4405. ast_json_object_iter_value(iter));
  4406. if (!prop_is_valid) {
  4407. ast_log(LOG_ERROR, "ARI DeviceStateChanged field timestamp failed validation\n");
  4408. res = 0;
  4409. }
  4410. } else
  4411. if (strcmp("device_state", ast_json_object_iter_key(iter)) == 0) {
  4412. int prop_is_valid;
  4413. has_device_state = 1;
  4414. prop_is_valid = ast_ari_validate_device_state(
  4415. ast_json_object_iter_value(iter));
  4416. if (!prop_is_valid) {
  4417. ast_log(LOG_ERROR, "ARI DeviceStateChanged field device_state failed validation\n");
  4418. res = 0;
  4419. }
  4420. } else
  4421. {
  4422. ast_log(LOG_ERROR,
  4423. "ARI DeviceStateChanged has undocumented field %s\n",
  4424. ast_json_object_iter_key(iter));
  4425. res = 0;
  4426. }
  4427. }
  4428. if (!has_type) {
  4429. ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field type\n");
  4430. res = 0;
  4431. }
  4432. if (!has_application) {
  4433. ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field application\n");
  4434. res = 0;
  4435. }
  4436. if (!has_device_state) {
  4437. ast_log(LOG_ERROR, "ARI DeviceStateChanged missing required field device_state\n");
  4438. res = 0;
  4439. }
  4440. return res;
  4441. }
  4442. ari_validator ast_ari_validate_device_state_changed_fn(void)
  4443. {
  4444. return ast_ari_validate_device_state_changed;
  4445. }
  4446. int ast_ari_validate_dial(struct ast_json *json)
  4447. {
  4448. int res = 1;
  4449. struct ast_json_iter *iter;
  4450. int has_type = 0;
  4451. int has_application = 0;
  4452. int has_dialstatus = 0;
  4453. int has_peer = 0;
  4454. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4455. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  4456. int prop_is_valid;
  4457. prop_is_valid = ast_ari_validate_string(
  4458. ast_json_object_iter_value(iter));
  4459. if (!prop_is_valid) {
  4460. ast_log(LOG_ERROR, "ARI Dial field asterisk_id failed validation\n");
  4461. res = 0;
  4462. }
  4463. } else
  4464. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4465. int prop_is_valid;
  4466. has_type = 1;
  4467. prop_is_valid = ast_ari_validate_string(
  4468. ast_json_object_iter_value(iter));
  4469. if (!prop_is_valid) {
  4470. ast_log(LOG_ERROR, "ARI Dial field type failed validation\n");
  4471. res = 0;
  4472. }
  4473. } else
  4474. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4475. int prop_is_valid;
  4476. has_application = 1;
  4477. prop_is_valid = ast_ari_validate_string(
  4478. ast_json_object_iter_value(iter));
  4479. if (!prop_is_valid) {
  4480. ast_log(LOG_ERROR, "ARI Dial field application failed validation\n");
  4481. res = 0;
  4482. }
  4483. } else
  4484. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4485. int prop_is_valid;
  4486. prop_is_valid = ast_ari_validate_date(
  4487. ast_json_object_iter_value(iter));
  4488. if (!prop_is_valid) {
  4489. ast_log(LOG_ERROR, "ARI Dial field timestamp failed validation\n");
  4490. res = 0;
  4491. }
  4492. } else
  4493. if (strcmp("caller", ast_json_object_iter_key(iter)) == 0) {
  4494. int prop_is_valid;
  4495. prop_is_valid = ast_ari_validate_channel(
  4496. ast_json_object_iter_value(iter));
  4497. if (!prop_is_valid) {
  4498. ast_log(LOG_ERROR, "ARI Dial field caller failed validation\n");
  4499. res = 0;
  4500. }
  4501. } else
  4502. if (strcmp("dialstatus", ast_json_object_iter_key(iter)) == 0) {
  4503. int prop_is_valid;
  4504. has_dialstatus = 1;
  4505. prop_is_valid = ast_ari_validate_string(
  4506. ast_json_object_iter_value(iter));
  4507. if (!prop_is_valid) {
  4508. ast_log(LOG_ERROR, "ARI Dial field dialstatus failed validation\n");
  4509. res = 0;
  4510. }
  4511. } else
  4512. if (strcmp("dialstring", ast_json_object_iter_key(iter)) == 0) {
  4513. int prop_is_valid;
  4514. prop_is_valid = ast_ari_validate_string(
  4515. ast_json_object_iter_value(iter));
  4516. if (!prop_is_valid) {
  4517. ast_log(LOG_ERROR, "ARI Dial field dialstring failed validation\n");
  4518. res = 0;
  4519. }
  4520. } else
  4521. if (strcmp("forward", ast_json_object_iter_key(iter)) == 0) {
  4522. int prop_is_valid;
  4523. prop_is_valid = ast_ari_validate_string(
  4524. ast_json_object_iter_value(iter));
  4525. if (!prop_is_valid) {
  4526. ast_log(LOG_ERROR, "ARI Dial field forward failed validation\n");
  4527. res = 0;
  4528. }
  4529. } else
  4530. if (strcmp("forwarded", ast_json_object_iter_key(iter)) == 0) {
  4531. int prop_is_valid;
  4532. prop_is_valid = ast_ari_validate_channel(
  4533. ast_json_object_iter_value(iter));
  4534. if (!prop_is_valid) {
  4535. ast_log(LOG_ERROR, "ARI Dial field forwarded failed validation\n");
  4536. res = 0;
  4537. }
  4538. } else
  4539. if (strcmp("peer", ast_json_object_iter_key(iter)) == 0) {
  4540. int prop_is_valid;
  4541. has_peer = 1;
  4542. prop_is_valid = ast_ari_validate_channel(
  4543. ast_json_object_iter_value(iter));
  4544. if (!prop_is_valid) {
  4545. ast_log(LOG_ERROR, "ARI Dial field peer failed validation\n");
  4546. res = 0;
  4547. }
  4548. } else
  4549. {
  4550. ast_log(LOG_ERROR,
  4551. "ARI Dial has undocumented field %s\n",
  4552. ast_json_object_iter_key(iter));
  4553. res = 0;
  4554. }
  4555. }
  4556. if (!has_type) {
  4557. ast_log(LOG_ERROR, "ARI Dial missing required field type\n");
  4558. res = 0;
  4559. }
  4560. if (!has_application) {
  4561. ast_log(LOG_ERROR, "ARI Dial missing required field application\n");
  4562. res = 0;
  4563. }
  4564. if (!has_dialstatus) {
  4565. ast_log(LOG_ERROR, "ARI Dial missing required field dialstatus\n");
  4566. res = 0;
  4567. }
  4568. if (!has_peer) {
  4569. ast_log(LOG_ERROR, "ARI Dial missing required field peer\n");
  4570. res = 0;
  4571. }
  4572. return res;
  4573. }
  4574. ari_validator ast_ari_validate_dial_fn(void)
  4575. {
  4576. return ast_ari_validate_dial;
  4577. }
  4578. int ast_ari_validate_endpoint_state_change(struct ast_json *json)
  4579. {
  4580. int res = 1;
  4581. struct ast_json_iter *iter;
  4582. int has_type = 0;
  4583. int has_application = 0;
  4584. int has_endpoint = 0;
  4585. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4586. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  4587. int prop_is_valid;
  4588. prop_is_valid = ast_ari_validate_string(
  4589. ast_json_object_iter_value(iter));
  4590. if (!prop_is_valid) {
  4591. ast_log(LOG_ERROR, "ARI EndpointStateChange field asterisk_id failed validation\n");
  4592. res = 0;
  4593. }
  4594. } else
  4595. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4596. int prop_is_valid;
  4597. has_type = 1;
  4598. prop_is_valid = ast_ari_validate_string(
  4599. ast_json_object_iter_value(iter));
  4600. if (!prop_is_valid) {
  4601. ast_log(LOG_ERROR, "ARI EndpointStateChange field type failed validation\n");
  4602. res = 0;
  4603. }
  4604. } else
  4605. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4606. int prop_is_valid;
  4607. has_application = 1;
  4608. prop_is_valid = ast_ari_validate_string(
  4609. ast_json_object_iter_value(iter));
  4610. if (!prop_is_valid) {
  4611. ast_log(LOG_ERROR, "ARI EndpointStateChange field application failed validation\n");
  4612. res = 0;
  4613. }
  4614. } else
  4615. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4616. int prop_is_valid;
  4617. prop_is_valid = ast_ari_validate_date(
  4618. ast_json_object_iter_value(iter));
  4619. if (!prop_is_valid) {
  4620. ast_log(LOG_ERROR, "ARI EndpointStateChange field timestamp failed validation\n");
  4621. res = 0;
  4622. }
  4623. } else
  4624. if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
  4625. int prop_is_valid;
  4626. has_endpoint = 1;
  4627. prop_is_valid = ast_ari_validate_endpoint(
  4628. ast_json_object_iter_value(iter));
  4629. if (!prop_is_valid) {
  4630. ast_log(LOG_ERROR, "ARI EndpointStateChange field endpoint failed validation\n");
  4631. res = 0;
  4632. }
  4633. } else
  4634. {
  4635. ast_log(LOG_ERROR,
  4636. "ARI EndpointStateChange has undocumented field %s\n",
  4637. ast_json_object_iter_key(iter));
  4638. res = 0;
  4639. }
  4640. }
  4641. if (!has_type) {
  4642. ast_log(LOG_ERROR, "ARI EndpointStateChange missing required field type\n");
  4643. res = 0;
  4644. }
  4645. if (!has_application) {
  4646. ast_log(LOG_ERROR, "ARI EndpointStateChange missing required field application\n");
  4647. res = 0;
  4648. }
  4649. if (!has_endpoint) {
  4650. ast_log(LOG_ERROR, "ARI EndpointStateChange missing required field endpoint\n");
  4651. res = 0;
  4652. }
  4653. return res;
  4654. }
  4655. ari_validator ast_ari_validate_endpoint_state_change_fn(void)
  4656. {
  4657. return ast_ari_validate_endpoint_state_change;
  4658. }
  4659. int ast_ari_validate_event(struct ast_json *json)
  4660. {
  4661. int res = 1;
  4662. struct ast_json_iter *iter;
  4663. int has_type = 0;
  4664. int has_application = 0;
  4665. const char *discriminator;
  4666. discriminator = ast_json_string_get(ast_json_object_get(json, "type"));
  4667. if (!discriminator) {
  4668. ast_log(LOG_ERROR, "ARI Event missing required field type\n");
  4669. return 0;
  4670. }
  4671. if (strcmp("Event", discriminator) == 0) {
  4672. /* Self type; fall through */
  4673. } else
  4674. if (strcmp("ApplicationReplaced", discriminator) == 0) {
  4675. return ast_ari_validate_application_replaced(json);
  4676. } else
  4677. if (strcmp("BridgeAttendedTransfer", discriminator) == 0) {
  4678. return ast_ari_validate_bridge_attended_transfer(json);
  4679. } else
  4680. if (strcmp("BridgeBlindTransfer", discriminator) == 0) {
  4681. return ast_ari_validate_bridge_blind_transfer(json);
  4682. } else
  4683. if (strcmp("BridgeCreated", discriminator) == 0) {
  4684. return ast_ari_validate_bridge_created(json);
  4685. } else
  4686. if (strcmp("BridgeDestroyed", discriminator) == 0) {
  4687. return ast_ari_validate_bridge_destroyed(json);
  4688. } else
  4689. if (strcmp("BridgeMerged", discriminator) == 0) {
  4690. return ast_ari_validate_bridge_merged(json);
  4691. } else
  4692. if (strcmp("BridgeVideoSourceChanged", discriminator) == 0) {
  4693. return ast_ari_validate_bridge_video_source_changed(json);
  4694. } else
  4695. if (strcmp("ChannelCallerId", discriminator) == 0) {
  4696. return ast_ari_validate_channel_caller_id(json);
  4697. } else
  4698. if (strcmp("ChannelConnectedLine", discriminator) == 0) {
  4699. return ast_ari_validate_channel_connected_line(json);
  4700. } else
  4701. if (strcmp("ChannelCreated", discriminator) == 0) {
  4702. return ast_ari_validate_channel_created(json);
  4703. } else
  4704. if (strcmp("ChannelDestroyed", discriminator) == 0) {
  4705. return ast_ari_validate_channel_destroyed(json);
  4706. } else
  4707. if (strcmp("ChannelDialplan", discriminator) == 0) {
  4708. return ast_ari_validate_channel_dialplan(json);
  4709. } else
  4710. if (strcmp("ChannelDtmfReceived", discriminator) == 0) {
  4711. return ast_ari_validate_channel_dtmf_received(json);
  4712. } else
  4713. if (strcmp("ChannelEnteredBridge", discriminator) == 0) {
  4714. return ast_ari_validate_channel_entered_bridge(json);
  4715. } else
  4716. if (strcmp("ChannelHangupRequest", discriminator) == 0) {
  4717. return ast_ari_validate_channel_hangup_request(json);
  4718. } else
  4719. if (strcmp("ChannelHold", discriminator) == 0) {
  4720. return ast_ari_validate_channel_hold(json);
  4721. } else
  4722. if (strcmp("ChannelLeftBridge", discriminator) == 0) {
  4723. return ast_ari_validate_channel_left_bridge(json);
  4724. } else
  4725. if (strcmp("ChannelStateChange", discriminator) == 0) {
  4726. return ast_ari_validate_channel_state_change(json);
  4727. } else
  4728. if (strcmp("ChannelTalkingFinished", discriminator) == 0) {
  4729. return ast_ari_validate_channel_talking_finished(json);
  4730. } else
  4731. if (strcmp("ChannelTalkingStarted", discriminator) == 0) {
  4732. return ast_ari_validate_channel_talking_started(json);
  4733. } else
  4734. if (strcmp("ChannelUnhold", discriminator) == 0) {
  4735. return ast_ari_validate_channel_unhold(json);
  4736. } else
  4737. if (strcmp("ChannelUserevent", discriminator) == 0) {
  4738. return ast_ari_validate_channel_userevent(json);
  4739. } else
  4740. if (strcmp("ChannelVarset", discriminator) == 0) {
  4741. return ast_ari_validate_channel_varset(json);
  4742. } else
  4743. if (strcmp("ContactStatusChange", discriminator) == 0) {
  4744. return ast_ari_validate_contact_status_change(json);
  4745. } else
  4746. if (strcmp("DeviceStateChanged", discriminator) == 0) {
  4747. return ast_ari_validate_device_state_changed(json);
  4748. } else
  4749. if (strcmp("Dial", discriminator) == 0) {
  4750. return ast_ari_validate_dial(json);
  4751. } else
  4752. if (strcmp("EndpointStateChange", discriminator) == 0) {
  4753. return ast_ari_validate_endpoint_state_change(json);
  4754. } else
  4755. if (strcmp("PeerStatusChange", discriminator) == 0) {
  4756. return ast_ari_validate_peer_status_change(json);
  4757. } else
  4758. if (strcmp("PlaybackFinished", discriminator) == 0) {
  4759. return ast_ari_validate_playback_finished(json);
  4760. } else
  4761. if (strcmp("PlaybackStarted", discriminator) == 0) {
  4762. return ast_ari_validate_playback_started(json);
  4763. } else
  4764. if (strcmp("RecordingFailed", discriminator) == 0) {
  4765. return ast_ari_validate_recording_failed(json);
  4766. } else
  4767. if (strcmp("RecordingFinished", discriminator) == 0) {
  4768. return ast_ari_validate_recording_finished(json);
  4769. } else
  4770. if (strcmp("RecordingStarted", discriminator) == 0) {
  4771. return ast_ari_validate_recording_started(json);
  4772. } else
  4773. if (strcmp("StasisEnd", discriminator) == 0) {
  4774. return ast_ari_validate_stasis_end(json);
  4775. } else
  4776. if (strcmp("StasisStart", discriminator) == 0) {
  4777. return ast_ari_validate_stasis_start(json);
  4778. } else
  4779. if (strcmp("TextMessageReceived", discriminator) == 0) {
  4780. return ast_ari_validate_text_message_received(json);
  4781. } else
  4782. {
  4783. ast_log(LOG_ERROR, "ARI Event has undocumented subtype %s\n",
  4784. discriminator);
  4785. res = 0;
  4786. }
  4787. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4788. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  4789. int prop_is_valid;
  4790. prop_is_valid = ast_ari_validate_string(
  4791. ast_json_object_iter_value(iter));
  4792. if (!prop_is_valid) {
  4793. ast_log(LOG_ERROR, "ARI Event field asterisk_id failed validation\n");
  4794. res = 0;
  4795. }
  4796. } else
  4797. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4798. int prop_is_valid;
  4799. has_type = 1;
  4800. prop_is_valid = ast_ari_validate_string(
  4801. ast_json_object_iter_value(iter));
  4802. if (!prop_is_valid) {
  4803. ast_log(LOG_ERROR, "ARI Event field type failed validation\n");
  4804. res = 0;
  4805. }
  4806. } else
  4807. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  4808. int prop_is_valid;
  4809. has_application = 1;
  4810. prop_is_valid = ast_ari_validate_string(
  4811. ast_json_object_iter_value(iter));
  4812. if (!prop_is_valid) {
  4813. ast_log(LOG_ERROR, "ARI Event field application failed validation\n");
  4814. res = 0;
  4815. }
  4816. } else
  4817. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  4818. int prop_is_valid;
  4819. prop_is_valid = ast_ari_validate_date(
  4820. ast_json_object_iter_value(iter));
  4821. if (!prop_is_valid) {
  4822. ast_log(LOG_ERROR, "ARI Event field timestamp failed validation\n");
  4823. res = 0;
  4824. }
  4825. } else
  4826. {
  4827. ast_log(LOG_ERROR,
  4828. "ARI Event has undocumented field %s\n",
  4829. ast_json_object_iter_key(iter));
  4830. res = 0;
  4831. }
  4832. }
  4833. if (!has_type) {
  4834. ast_log(LOG_ERROR, "ARI Event missing required field type\n");
  4835. res = 0;
  4836. }
  4837. if (!has_application) {
  4838. ast_log(LOG_ERROR, "ARI Event missing required field application\n");
  4839. res = 0;
  4840. }
  4841. return res;
  4842. }
  4843. ari_validator ast_ari_validate_event_fn(void)
  4844. {
  4845. return ast_ari_validate_event;
  4846. }
  4847. int ast_ari_validate_message(struct ast_json *json)
  4848. {
  4849. int res = 1;
  4850. struct ast_json_iter *iter;
  4851. int has_type = 0;
  4852. const char *discriminator;
  4853. discriminator = ast_json_string_get(ast_json_object_get(json, "type"));
  4854. if (!discriminator) {
  4855. ast_log(LOG_ERROR, "ARI Message missing required field type\n");
  4856. return 0;
  4857. }
  4858. if (strcmp("Message", discriminator) == 0) {
  4859. /* Self type; fall through */
  4860. } else
  4861. if (strcmp("ApplicationReplaced", discriminator) == 0) {
  4862. return ast_ari_validate_application_replaced(json);
  4863. } else
  4864. if (strcmp("BridgeAttendedTransfer", discriminator) == 0) {
  4865. return ast_ari_validate_bridge_attended_transfer(json);
  4866. } else
  4867. if (strcmp("BridgeBlindTransfer", discriminator) == 0) {
  4868. return ast_ari_validate_bridge_blind_transfer(json);
  4869. } else
  4870. if (strcmp("BridgeCreated", discriminator) == 0) {
  4871. return ast_ari_validate_bridge_created(json);
  4872. } else
  4873. if (strcmp("BridgeDestroyed", discriminator) == 0) {
  4874. return ast_ari_validate_bridge_destroyed(json);
  4875. } else
  4876. if (strcmp("BridgeMerged", discriminator) == 0) {
  4877. return ast_ari_validate_bridge_merged(json);
  4878. } else
  4879. if (strcmp("BridgeVideoSourceChanged", discriminator) == 0) {
  4880. return ast_ari_validate_bridge_video_source_changed(json);
  4881. } else
  4882. if (strcmp("ChannelCallerId", discriminator) == 0) {
  4883. return ast_ari_validate_channel_caller_id(json);
  4884. } else
  4885. if (strcmp("ChannelConnectedLine", discriminator) == 0) {
  4886. return ast_ari_validate_channel_connected_line(json);
  4887. } else
  4888. if (strcmp("ChannelCreated", discriminator) == 0) {
  4889. return ast_ari_validate_channel_created(json);
  4890. } else
  4891. if (strcmp("ChannelDestroyed", discriminator) == 0) {
  4892. return ast_ari_validate_channel_destroyed(json);
  4893. } else
  4894. if (strcmp("ChannelDialplan", discriminator) == 0) {
  4895. return ast_ari_validate_channel_dialplan(json);
  4896. } else
  4897. if (strcmp("ChannelDtmfReceived", discriminator) == 0) {
  4898. return ast_ari_validate_channel_dtmf_received(json);
  4899. } else
  4900. if (strcmp("ChannelEnteredBridge", discriminator) == 0) {
  4901. return ast_ari_validate_channel_entered_bridge(json);
  4902. } else
  4903. if (strcmp("ChannelHangupRequest", discriminator) == 0) {
  4904. return ast_ari_validate_channel_hangup_request(json);
  4905. } else
  4906. if (strcmp("ChannelHold", discriminator) == 0) {
  4907. return ast_ari_validate_channel_hold(json);
  4908. } else
  4909. if (strcmp("ChannelLeftBridge", discriminator) == 0) {
  4910. return ast_ari_validate_channel_left_bridge(json);
  4911. } else
  4912. if (strcmp("ChannelStateChange", discriminator) == 0) {
  4913. return ast_ari_validate_channel_state_change(json);
  4914. } else
  4915. if (strcmp("ChannelTalkingFinished", discriminator) == 0) {
  4916. return ast_ari_validate_channel_talking_finished(json);
  4917. } else
  4918. if (strcmp("ChannelTalkingStarted", discriminator) == 0) {
  4919. return ast_ari_validate_channel_talking_started(json);
  4920. } else
  4921. if (strcmp("ChannelUnhold", discriminator) == 0) {
  4922. return ast_ari_validate_channel_unhold(json);
  4923. } else
  4924. if (strcmp("ChannelUserevent", discriminator) == 0) {
  4925. return ast_ari_validate_channel_userevent(json);
  4926. } else
  4927. if (strcmp("ChannelVarset", discriminator) == 0) {
  4928. return ast_ari_validate_channel_varset(json);
  4929. } else
  4930. if (strcmp("ContactStatusChange", discriminator) == 0) {
  4931. return ast_ari_validate_contact_status_change(json);
  4932. } else
  4933. if (strcmp("DeviceStateChanged", discriminator) == 0) {
  4934. return ast_ari_validate_device_state_changed(json);
  4935. } else
  4936. if (strcmp("Dial", discriminator) == 0) {
  4937. return ast_ari_validate_dial(json);
  4938. } else
  4939. if (strcmp("EndpointStateChange", discriminator) == 0) {
  4940. return ast_ari_validate_endpoint_state_change(json);
  4941. } else
  4942. if (strcmp("Event", discriminator) == 0) {
  4943. return ast_ari_validate_event(json);
  4944. } else
  4945. if (strcmp("MissingParams", discriminator) == 0) {
  4946. return ast_ari_validate_missing_params(json);
  4947. } else
  4948. if (strcmp("PeerStatusChange", discriminator) == 0) {
  4949. return ast_ari_validate_peer_status_change(json);
  4950. } else
  4951. if (strcmp("PlaybackFinished", discriminator) == 0) {
  4952. return ast_ari_validate_playback_finished(json);
  4953. } else
  4954. if (strcmp("PlaybackStarted", discriminator) == 0) {
  4955. return ast_ari_validate_playback_started(json);
  4956. } else
  4957. if (strcmp("RecordingFailed", discriminator) == 0) {
  4958. return ast_ari_validate_recording_failed(json);
  4959. } else
  4960. if (strcmp("RecordingFinished", discriminator) == 0) {
  4961. return ast_ari_validate_recording_finished(json);
  4962. } else
  4963. if (strcmp("RecordingStarted", discriminator) == 0) {
  4964. return ast_ari_validate_recording_started(json);
  4965. } else
  4966. if (strcmp("StasisEnd", discriminator) == 0) {
  4967. return ast_ari_validate_stasis_end(json);
  4968. } else
  4969. if (strcmp("StasisStart", discriminator) == 0) {
  4970. return ast_ari_validate_stasis_start(json);
  4971. } else
  4972. if (strcmp("TextMessageReceived", discriminator) == 0) {
  4973. return ast_ari_validate_text_message_received(json);
  4974. } else
  4975. {
  4976. ast_log(LOG_ERROR, "ARI Message has undocumented subtype %s\n",
  4977. discriminator);
  4978. res = 0;
  4979. }
  4980. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  4981. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  4982. int prop_is_valid;
  4983. prop_is_valid = ast_ari_validate_string(
  4984. ast_json_object_iter_value(iter));
  4985. if (!prop_is_valid) {
  4986. ast_log(LOG_ERROR, "ARI Message field asterisk_id failed validation\n");
  4987. res = 0;
  4988. }
  4989. } else
  4990. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  4991. int prop_is_valid;
  4992. has_type = 1;
  4993. prop_is_valid = ast_ari_validate_string(
  4994. ast_json_object_iter_value(iter));
  4995. if (!prop_is_valid) {
  4996. ast_log(LOG_ERROR, "ARI Message field type failed validation\n");
  4997. res = 0;
  4998. }
  4999. } else
  5000. {
  5001. ast_log(LOG_ERROR,
  5002. "ARI Message has undocumented field %s\n",
  5003. ast_json_object_iter_key(iter));
  5004. res = 0;
  5005. }
  5006. }
  5007. if (!has_type) {
  5008. ast_log(LOG_ERROR, "ARI Message missing required field type\n");
  5009. res = 0;
  5010. }
  5011. return res;
  5012. }
  5013. ari_validator ast_ari_validate_message_fn(void)
  5014. {
  5015. return ast_ari_validate_message;
  5016. }
  5017. int ast_ari_validate_missing_params(struct ast_json *json)
  5018. {
  5019. int res = 1;
  5020. struct ast_json_iter *iter;
  5021. int has_type = 0;
  5022. int has_params = 0;
  5023. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5024. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5025. int prop_is_valid;
  5026. prop_is_valid = ast_ari_validate_string(
  5027. ast_json_object_iter_value(iter));
  5028. if (!prop_is_valid) {
  5029. ast_log(LOG_ERROR, "ARI MissingParams field asterisk_id failed validation\n");
  5030. res = 0;
  5031. }
  5032. } else
  5033. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5034. int prop_is_valid;
  5035. has_type = 1;
  5036. prop_is_valid = ast_ari_validate_string(
  5037. ast_json_object_iter_value(iter));
  5038. if (!prop_is_valid) {
  5039. ast_log(LOG_ERROR, "ARI MissingParams field type failed validation\n");
  5040. res = 0;
  5041. }
  5042. } else
  5043. if (strcmp("params", ast_json_object_iter_key(iter)) == 0) {
  5044. int prop_is_valid;
  5045. has_params = 1;
  5046. prop_is_valid = ast_ari_validate_list(
  5047. ast_json_object_iter_value(iter),
  5048. ast_ari_validate_string);
  5049. if (!prop_is_valid) {
  5050. ast_log(LOG_ERROR, "ARI MissingParams field params failed validation\n");
  5051. res = 0;
  5052. }
  5053. } else
  5054. {
  5055. ast_log(LOG_ERROR,
  5056. "ARI MissingParams has undocumented field %s\n",
  5057. ast_json_object_iter_key(iter));
  5058. res = 0;
  5059. }
  5060. }
  5061. if (!has_type) {
  5062. ast_log(LOG_ERROR, "ARI MissingParams missing required field type\n");
  5063. res = 0;
  5064. }
  5065. if (!has_params) {
  5066. ast_log(LOG_ERROR, "ARI MissingParams missing required field params\n");
  5067. res = 0;
  5068. }
  5069. return res;
  5070. }
  5071. ari_validator ast_ari_validate_missing_params_fn(void)
  5072. {
  5073. return ast_ari_validate_missing_params;
  5074. }
  5075. int ast_ari_validate_peer(struct ast_json *json)
  5076. {
  5077. int res = 1;
  5078. struct ast_json_iter *iter;
  5079. int has_peer_status = 0;
  5080. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5081. if (strcmp("address", ast_json_object_iter_key(iter)) == 0) {
  5082. int prop_is_valid;
  5083. prop_is_valid = ast_ari_validate_string(
  5084. ast_json_object_iter_value(iter));
  5085. if (!prop_is_valid) {
  5086. ast_log(LOG_ERROR, "ARI Peer field address failed validation\n");
  5087. res = 0;
  5088. }
  5089. } else
  5090. if (strcmp("cause", ast_json_object_iter_key(iter)) == 0) {
  5091. int prop_is_valid;
  5092. prop_is_valid = ast_ari_validate_string(
  5093. ast_json_object_iter_value(iter));
  5094. if (!prop_is_valid) {
  5095. ast_log(LOG_ERROR, "ARI Peer field cause failed validation\n");
  5096. res = 0;
  5097. }
  5098. } else
  5099. if (strcmp("peer_status", ast_json_object_iter_key(iter)) == 0) {
  5100. int prop_is_valid;
  5101. has_peer_status = 1;
  5102. prop_is_valid = ast_ari_validate_string(
  5103. ast_json_object_iter_value(iter));
  5104. if (!prop_is_valid) {
  5105. ast_log(LOG_ERROR, "ARI Peer field peer_status failed validation\n");
  5106. res = 0;
  5107. }
  5108. } else
  5109. if (strcmp("port", ast_json_object_iter_key(iter)) == 0) {
  5110. int prop_is_valid;
  5111. prop_is_valid = ast_ari_validate_string(
  5112. ast_json_object_iter_value(iter));
  5113. if (!prop_is_valid) {
  5114. ast_log(LOG_ERROR, "ARI Peer field port failed validation\n");
  5115. res = 0;
  5116. }
  5117. } else
  5118. if (strcmp("time", ast_json_object_iter_key(iter)) == 0) {
  5119. int prop_is_valid;
  5120. prop_is_valid = ast_ari_validate_string(
  5121. ast_json_object_iter_value(iter));
  5122. if (!prop_is_valid) {
  5123. ast_log(LOG_ERROR, "ARI Peer field time failed validation\n");
  5124. res = 0;
  5125. }
  5126. } else
  5127. {
  5128. ast_log(LOG_ERROR,
  5129. "ARI Peer has undocumented field %s\n",
  5130. ast_json_object_iter_key(iter));
  5131. res = 0;
  5132. }
  5133. }
  5134. if (!has_peer_status) {
  5135. ast_log(LOG_ERROR, "ARI Peer missing required field peer_status\n");
  5136. res = 0;
  5137. }
  5138. return res;
  5139. }
  5140. ari_validator ast_ari_validate_peer_fn(void)
  5141. {
  5142. return ast_ari_validate_peer;
  5143. }
  5144. int ast_ari_validate_peer_status_change(struct ast_json *json)
  5145. {
  5146. int res = 1;
  5147. struct ast_json_iter *iter;
  5148. int has_type = 0;
  5149. int has_application = 0;
  5150. int has_endpoint = 0;
  5151. int has_peer = 0;
  5152. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5153. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5154. int prop_is_valid;
  5155. prop_is_valid = ast_ari_validate_string(
  5156. ast_json_object_iter_value(iter));
  5157. if (!prop_is_valid) {
  5158. ast_log(LOG_ERROR, "ARI PeerStatusChange field asterisk_id failed validation\n");
  5159. res = 0;
  5160. }
  5161. } else
  5162. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5163. int prop_is_valid;
  5164. has_type = 1;
  5165. prop_is_valid = ast_ari_validate_string(
  5166. ast_json_object_iter_value(iter));
  5167. if (!prop_is_valid) {
  5168. ast_log(LOG_ERROR, "ARI PeerStatusChange field type failed validation\n");
  5169. res = 0;
  5170. }
  5171. } else
  5172. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5173. int prop_is_valid;
  5174. has_application = 1;
  5175. prop_is_valid = ast_ari_validate_string(
  5176. ast_json_object_iter_value(iter));
  5177. if (!prop_is_valid) {
  5178. ast_log(LOG_ERROR, "ARI PeerStatusChange field application failed validation\n");
  5179. res = 0;
  5180. }
  5181. } else
  5182. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5183. int prop_is_valid;
  5184. prop_is_valid = ast_ari_validate_date(
  5185. ast_json_object_iter_value(iter));
  5186. if (!prop_is_valid) {
  5187. ast_log(LOG_ERROR, "ARI PeerStatusChange field timestamp failed validation\n");
  5188. res = 0;
  5189. }
  5190. } else
  5191. if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
  5192. int prop_is_valid;
  5193. has_endpoint = 1;
  5194. prop_is_valid = ast_ari_validate_endpoint(
  5195. ast_json_object_iter_value(iter));
  5196. if (!prop_is_valid) {
  5197. ast_log(LOG_ERROR, "ARI PeerStatusChange field endpoint failed validation\n");
  5198. res = 0;
  5199. }
  5200. } else
  5201. if (strcmp("peer", ast_json_object_iter_key(iter)) == 0) {
  5202. int prop_is_valid;
  5203. has_peer = 1;
  5204. prop_is_valid = ast_ari_validate_peer(
  5205. ast_json_object_iter_value(iter));
  5206. if (!prop_is_valid) {
  5207. ast_log(LOG_ERROR, "ARI PeerStatusChange field peer failed validation\n");
  5208. res = 0;
  5209. }
  5210. } else
  5211. {
  5212. ast_log(LOG_ERROR,
  5213. "ARI PeerStatusChange has undocumented field %s\n",
  5214. ast_json_object_iter_key(iter));
  5215. res = 0;
  5216. }
  5217. }
  5218. if (!has_type) {
  5219. ast_log(LOG_ERROR, "ARI PeerStatusChange missing required field type\n");
  5220. res = 0;
  5221. }
  5222. if (!has_application) {
  5223. ast_log(LOG_ERROR, "ARI PeerStatusChange missing required field application\n");
  5224. res = 0;
  5225. }
  5226. if (!has_endpoint) {
  5227. ast_log(LOG_ERROR, "ARI PeerStatusChange missing required field endpoint\n");
  5228. res = 0;
  5229. }
  5230. if (!has_peer) {
  5231. ast_log(LOG_ERROR, "ARI PeerStatusChange missing required field peer\n");
  5232. res = 0;
  5233. }
  5234. return res;
  5235. }
  5236. ari_validator ast_ari_validate_peer_status_change_fn(void)
  5237. {
  5238. return ast_ari_validate_peer_status_change;
  5239. }
  5240. int ast_ari_validate_playback_finished(struct ast_json *json)
  5241. {
  5242. int res = 1;
  5243. struct ast_json_iter *iter;
  5244. int has_type = 0;
  5245. int has_application = 0;
  5246. int has_playback = 0;
  5247. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5248. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5249. int prop_is_valid;
  5250. prop_is_valid = ast_ari_validate_string(
  5251. ast_json_object_iter_value(iter));
  5252. if (!prop_is_valid) {
  5253. ast_log(LOG_ERROR, "ARI PlaybackFinished field asterisk_id failed validation\n");
  5254. res = 0;
  5255. }
  5256. } else
  5257. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5258. int prop_is_valid;
  5259. has_type = 1;
  5260. prop_is_valid = ast_ari_validate_string(
  5261. ast_json_object_iter_value(iter));
  5262. if (!prop_is_valid) {
  5263. ast_log(LOG_ERROR, "ARI PlaybackFinished field type failed validation\n");
  5264. res = 0;
  5265. }
  5266. } else
  5267. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5268. int prop_is_valid;
  5269. has_application = 1;
  5270. prop_is_valid = ast_ari_validate_string(
  5271. ast_json_object_iter_value(iter));
  5272. if (!prop_is_valid) {
  5273. ast_log(LOG_ERROR, "ARI PlaybackFinished field application failed validation\n");
  5274. res = 0;
  5275. }
  5276. } else
  5277. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5278. int prop_is_valid;
  5279. prop_is_valid = ast_ari_validate_date(
  5280. ast_json_object_iter_value(iter));
  5281. if (!prop_is_valid) {
  5282. ast_log(LOG_ERROR, "ARI PlaybackFinished field timestamp failed validation\n");
  5283. res = 0;
  5284. }
  5285. } else
  5286. if (strcmp("playback", ast_json_object_iter_key(iter)) == 0) {
  5287. int prop_is_valid;
  5288. has_playback = 1;
  5289. prop_is_valid = ast_ari_validate_playback(
  5290. ast_json_object_iter_value(iter));
  5291. if (!prop_is_valid) {
  5292. ast_log(LOG_ERROR, "ARI PlaybackFinished field playback failed validation\n");
  5293. res = 0;
  5294. }
  5295. } else
  5296. {
  5297. ast_log(LOG_ERROR,
  5298. "ARI PlaybackFinished has undocumented field %s\n",
  5299. ast_json_object_iter_key(iter));
  5300. res = 0;
  5301. }
  5302. }
  5303. if (!has_type) {
  5304. ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field type\n");
  5305. res = 0;
  5306. }
  5307. if (!has_application) {
  5308. ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field application\n");
  5309. res = 0;
  5310. }
  5311. if (!has_playback) {
  5312. ast_log(LOG_ERROR, "ARI PlaybackFinished missing required field playback\n");
  5313. res = 0;
  5314. }
  5315. return res;
  5316. }
  5317. ari_validator ast_ari_validate_playback_finished_fn(void)
  5318. {
  5319. return ast_ari_validate_playback_finished;
  5320. }
  5321. int ast_ari_validate_playback_started(struct ast_json *json)
  5322. {
  5323. int res = 1;
  5324. struct ast_json_iter *iter;
  5325. int has_type = 0;
  5326. int has_application = 0;
  5327. int has_playback = 0;
  5328. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5329. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5330. int prop_is_valid;
  5331. prop_is_valid = ast_ari_validate_string(
  5332. ast_json_object_iter_value(iter));
  5333. if (!prop_is_valid) {
  5334. ast_log(LOG_ERROR, "ARI PlaybackStarted field asterisk_id failed validation\n");
  5335. res = 0;
  5336. }
  5337. } else
  5338. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5339. int prop_is_valid;
  5340. has_type = 1;
  5341. prop_is_valid = ast_ari_validate_string(
  5342. ast_json_object_iter_value(iter));
  5343. if (!prop_is_valid) {
  5344. ast_log(LOG_ERROR, "ARI PlaybackStarted field type failed validation\n");
  5345. res = 0;
  5346. }
  5347. } else
  5348. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5349. int prop_is_valid;
  5350. has_application = 1;
  5351. prop_is_valid = ast_ari_validate_string(
  5352. ast_json_object_iter_value(iter));
  5353. if (!prop_is_valid) {
  5354. ast_log(LOG_ERROR, "ARI PlaybackStarted field application failed validation\n");
  5355. res = 0;
  5356. }
  5357. } else
  5358. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5359. int prop_is_valid;
  5360. prop_is_valid = ast_ari_validate_date(
  5361. ast_json_object_iter_value(iter));
  5362. if (!prop_is_valid) {
  5363. ast_log(LOG_ERROR, "ARI PlaybackStarted field timestamp failed validation\n");
  5364. res = 0;
  5365. }
  5366. } else
  5367. if (strcmp("playback", ast_json_object_iter_key(iter)) == 0) {
  5368. int prop_is_valid;
  5369. has_playback = 1;
  5370. prop_is_valid = ast_ari_validate_playback(
  5371. ast_json_object_iter_value(iter));
  5372. if (!prop_is_valid) {
  5373. ast_log(LOG_ERROR, "ARI PlaybackStarted field playback failed validation\n");
  5374. res = 0;
  5375. }
  5376. } else
  5377. {
  5378. ast_log(LOG_ERROR,
  5379. "ARI PlaybackStarted has undocumented field %s\n",
  5380. ast_json_object_iter_key(iter));
  5381. res = 0;
  5382. }
  5383. }
  5384. if (!has_type) {
  5385. ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field type\n");
  5386. res = 0;
  5387. }
  5388. if (!has_application) {
  5389. ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field application\n");
  5390. res = 0;
  5391. }
  5392. if (!has_playback) {
  5393. ast_log(LOG_ERROR, "ARI PlaybackStarted missing required field playback\n");
  5394. res = 0;
  5395. }
  5396. return res;
  5397. }
  5398. ari_validator ast_ari_validate_playback_started_fn(void)
  5399. {
  5400. return ast_ari_validate_playback_started;
  5401. }
  5402. int ast_ari_validate_recording_failed(struct ast_json *json)
  5403. {
  5404. int res = 1;
  5405. struct ast_json_iter *iter;
  5406. int has_type = 0;
  5407. int has_application = 0;
  5408. int has_recording = 0;
  5409. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5410. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5411. int prop_is_valid;
  5412. prop_is_valid = ast_ari_validate_string(
  5413. ast_json_object_iter_value(iter));
  5414. if (!prop_is_valid) {
  5415. ast_log(LOG_ERROR, "ARI RecordingFailed field asterisk_id failed validation\n");
  5416. res = 0;
  5417. }
  5418. } else
  5419. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5420. int prop_is_valid;
  5421. has_type = 1;
  5422. prop_is_valid = ast_ari_validate_string(
  5423. ast_json_object_iter_value(iter));
  5424. if (!prop_is_valid) {
  5425. ast_log(LOG_ERROR, "ARI RecordingFailed field type failed validation\n");
  5426. res = 0;
  5427. }
  5428. } else
  5429. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5430. int prop_is_valid;
  5431. has_application = 1;
  5432. prop_is_valid = ast_ari_validate_string(
  5433. ast_json_object_iter_value(iter));
  5434. if (!prop_is_valid) {
  5435. ast_log(LOG_ERROR, "ARI RecordingFailed field application failed validation\n");
  5436. res = 0;
  5437. }
  5438. } else
  5439. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5440. int prop_is_valid;
  5441. prop_is_valid = ast_ari_validate_date(
  5442. ast_json_object_iter_value(iter));
  5443. if (!prop_is_valid) {
  5444. ast_log(LOG_ERROR, "ARI RecordingFailed field timestamp failed validation\n");
  5445. res = 0;
  5446. }
  5447. } else
  5448. if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
  5449. int prop_is_valid;
  5450. has_recording = 1;
  5451. prop_is_valid = ast_ari_validate_live_recording(
  5452. ast_json_object_iter_value(iter));
  5453. if (!prop_is_valid) {
  5454. ast_log(LOG_ERROR, "ARI RecordingFailed field recording failed validation\n");
  5455. res = 0;
  5456. }
  5457. } else
  5458. {
  5459. ast_log(LOG_ERROR,
  5460. "ARI RecordingFailed has undocumented field %s\n",
  5461. ast_json_object_iter_key(iter));
  5462. res = 0;
  5463. }
  5464. }
  5465. if (!has_type) {
  5466. ast_log(LOG_ERROR, "ARI RecordingFailed missing required field type\n");
  5467. res = 0;
  5468. }
  5469. if (!has_application) {
  5470. ast_log(LOG_ERROR, "ARI RecordingFailed missing required field application\n");
  5471. res = 0;
  5472. }
  5473. if (!has_recording) {
  5474. ast_log(LOG_ERROR, "ARI RecordingFailed missing required field recording\n");
  5475. res = 0;
  5476. }
  5477. return res;
  5478. }
  5479. ari_validator ast_ari_validate_recording_failed_fn(void)
  5480. {
  5481. return ast_ari_validate_recording_failed;
  5482. }
  5483. int ast_ari_validate_recording_finished(struct ast_json *json)
  5484. {
  5485. int res = 1;
  5486. struct ast_json_iter *iter;
  5487. int has_type = 0;
  5488. int has_application = 0;
  5489. int has_recording = 0;
  5490. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5491. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5492. int prop_is_valid;
  5493. prop_is_valid = ast_ari_validate_string(
  5494. ast_json_object_iter_value(iter));
  5495. if (!prop_is_valid) {
  5496. ast_log(LOG_ERROR, "ARI RecordingFinished field asterisk_id failed validation\n");
  5497. res = 0;
  5498. }
  5499. } else
  5500. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5501. int prop_is_valid;
  5502. has_type = 1;
  5503. prop_is_valid = ast_ari_validate_string(
  5504. ast_json_object_iter_value(iter));
  5505. if (!prop_is_valid) {
  5506. ast_log(LOG_ERROR, "ARI RecordingFinished field type failed validation\n");
  5507. res = 0;
  5508. }
  5509. } else
  5510. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5511. int prop_is_valid;
  5512. has_application = 1;
  5513. prop_is_valid = ast_ari_validate_string(
  5514. ast_json_object_iter_value(iter));
  5515. if (!prop_is_valid) {
  5516. ast_log(LOG_ERROR, "ARI RecordingFinished field application failed validation\n");
  5517. res = 0;
  5518. }
  5519. } else
  5520. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5521. int prop_is_valid;
  5522. prop_is_valid = ast_ari_validate_date(
  5523. ast_json_object_iter_value(iter));
  5524. if (!prop_is_valid) {
  5525. ast_log(LOG_ERROR, "ARI RecordingFinished field timestamp failed validation\n");
  5526. res = 0;
  5527. }
  5528. } else
  5529. if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
  5530. int prop_is_valid;
  5531. has_recording = 1;
  5532. prop_is_valid = ast_ari_validate_live_recording(
  5533. ast_json_object_iter_value(iter));
  5534. if (!prop_is_valid) {
  5535. ast_log(LOG_ERROR, "ARI RecordingFinished field recording failed validation\n");
  5536. res = 0;
  5537. }
  5538. } else
  5539. {
  5540. ast_log(LOG_ERROR,
  5541. "ARI RecordingFinished has undocumented field %s\n",
  5542. ast_json_object_iter_key(iter));
  5543. res = 0;
  5544. }
  5545. }
  5546. if (!has_type) {
  5547. ast_log(LOG_ERROR, "ARI RecordingFinished missing required field type\n");
  5548. res = 0;
  5549. }
  5550. if (!has_application) {
  5551. ast_log(LOG_ERROR, "ARI RecordingFinished missing required field application\n");
  5552. res = 0;
  5553. }
  5554. if (!has_recording) {
  5555. ast_log(LOG_ERROR, "ARI RecordingFinished missing required field recording\n");
  5556. res = 0;
  5557. }
  5558. return res;
  5559. }
  5560. ari_validator ast_ari_validate_recording_finished_fn(void)
  5561. {
  5562. return ast_ari_validate_recording_finished;
  5563. }
  5564. int ast_ari_validate_recording_started(struct ast_json *json)
  5565. {
  5566. int res = 1;
  5567. struct ast_json_iter *iter;
  5568. int has_type = 0;
  5569. int has_application = 0;
  5570. int has_recording = 0;
  5571. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5572. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5573. int prop_is_valid;
  5574. prop_is_valid = ast_ari_validate_string(
  5575. ast_json_object_iter_value(iter));
  5576. if (!prop_is_valid) {
  5577. ast_log(LOG_ERROR, "ARI RecordingStarted field asterisk_id failed validation\n");
  5578. res = 0;
  5579. }
  5580. } else
  5581. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5582. int prop_is_valid;
  5583. has_type = 1;
  5584. prop_is_valid = ast_ari_validate_string(
  5585. ast_json_object_iter_value(iter));
  5586. if (!prop_is_valid) {
  5587. ast_log(LOG_ERROR, "ARI RecordingStarted field type failed validation\n");
  5588. res = 0;
  5589. }
  5590. } else
  5591. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5592. int prop_is_valid;
  5593. has_application = 1;
  5594. prop_is_valid = ast_ari_validate_string(
  5595. ast_json_object_iter_value(iter));
  5596. if (!prop_is_valid) {
  5597. ast_log(LOG_ERROR, "ARI RecordingStarted field application failed validation\n");
  5598. res = 0;
  5599. }
  5600. } else
  5601. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5602. int prop_is_valid;
  5603. prop_is_valid = ast_ari_validate_date(
  5604. ast_json_object_iter_value(iter));
  5605. if (!prop_is_valid) {
  5606. ast_log(LOG_ERROR, "ARI RecordingStarted field timestamp failed validation\n");
  5607. res = 0;
  5608. }
  5609. } else
  5610. if (strcmp("recording", ast_json_object_iter_key(iter)) == 0) {
  5611. int prop_is_valid;
  5612. has_recording = 1;
  5613. prop_is_valid = ast_ari_validate_live_recording(
  5614. ast_json_object_iter_value(iter));
  5615. if (!prop_is_valid) {
  5616. ast_log(LOG_ERROR, "ARI RecordingStarted field recording failed validation\n");
  5617. res = 0;
  5618. }
  5619. } else
  5620. {
  5621. ast_log(LOG_ERROR,
  5622. "ARI RecordingStarted has undocumented field %s\n",
  5623. ast_json_object_iter_key(iter));
  5624. res = 0;
  5625. }
  5626. }
  5627. if (!has_type) {
  5628. ast_log(LOG_ERROR, "ARI RecordingStarted missing required field type\n");
  5629. res = 0;
  5630. }
  5631. if (!has_application) {
  5632. ast_log(LOG_ERROR, "ARI RecordingStarted missing required field application\n");
  5633. res = 0;
  5634. }
  5635. if (!has_recording) {
  5636. ast_log(LOG_ERROR, "ARI RecordingStarted missing required field recording\n");
  5637. res = 0;
  5638. }
  5639. return res;
  5640. }
  5641. ari_validator ast_ari_validate_recording_started_fn(void)
  5642. {
  5643. return ast_ari_validate_recording_started;
  5644. }
  5645. int ast_ari_validate_stasis_end(struct ast_json *json)
  5646. {
  5647. int res = 1;
  5648. struct ast_json_iter *iter;
  5649. int has_type = 0;
  5650. int has_application = 0;
  5651. int has_channel = 0;
  5652. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5653. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5654. int prop_is_valid;
  5655. prop_is_valid = ast_ari_validate_string(
  5656. ast_json_object_iter_value(iter));
  5657. if (!prop_is_valid) {
  5658. ast_log(LOG_ERROR, "ARI StasisEnd field asterisk_id failed validation\n");
  5659. res = 0;
  5660. }
  5661. } else
  5662. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5663. int prop_is_valid;
  5664. has_type = 1;
  5665. prop_is_valid = ast_ari_validate_string(
  5666. ast_json_object_iter_value(iter));
  5667. if (!prop_is_valid) {
  5668. ast_log(LOG_ERROR, "ARI StasisEnd field type failed validation\n");
  5669. res = 0;
  5670. }
  5671. } else
  5672. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5673. int prop_is_valid;
  5674. has_application = 1;
  5675. prop_is_valid = ast_ari_validate_string(
  5676. ast_json_object_iter_value(iter));
  5677. if (!prop_is_valid) {
  5678. ast_log(LOG_ERROR, "ARI StasisEnd field application failed validation\n");
  5679. res = 0;
  5680. }
  5681. } else
  5682. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5683. int prop_is_valid;
  5684. prop_is_valid = ast_ari_validate_date(
  5685. ast_json_object_iter_value(iter));
  5686. if (!prop_is_valid) {
  5687. ast_log(LOG_ERROR, "ARI StasisEnd field timestamp failed validation\n");
  5688. res = 0;
  5689. }
  5690. } else
  5691. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  5692. int prop_is_valid;
  5693. has_channel = 1;
  5694. prop_is_valid = ast_ari_validate_channel(
  5695. ast_json_object_iter_value(iter));
  5696. if (!prop_is_valid) {
  5697. ast_log(LOG_ERROR, "ARI StasisEnd field channel failed validation\n");
  5698. res = 0;
  5699. }
  5700. } else
  5701. {
  5702. ast_log(LOG_ERROR,
  5703. "ARI StasisEnd has undocumented field %s\n",
  5704. ast_json_object_iter_key(iter));
  5705. res = 0;
  5706. }
  5707. }
  5708. if (!has_type) {
  5709. ast_log(LOG_ERROR, "ARI StasisEnd missing required field type\n");
  5710. res = 0;
  5711. }
  5712. if (!has_application) {
  5713. ast_log(LOG_ERROR, "ARI StasisEnd missing required field application\n");
  5714. res = 0;
  5715. }
  5716. if (!has_channel) {
  5717. ast_log(LOG_ERROR, "ARI StasisEnd missing required field channel\n");
  5718. res = 0;
  5719. }
  5720. return res;
  5721. }
  5722. ari_validator ast_ari_validate_stasis_end_fn(void)
  5723. {
  5724. return ast_ari_validate_stasis_end;
  5725. }
  5726. int ast_ari_validate_stasis_start(struct ast_json *json)
  5727. {
  5728. int res = 1;
  5729. struct ast_json_iter *iter;
  5730. int has_type = 0;
  5731. int has_application = 0;
  5732. int has_args = 0;
  5733. int has_channel = 0;
  5734. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5735. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5736. int prop_is_valid;
  5737. prop_is_valid = ast_ari_validate_string(
  5738. ast_json_object_iter_value(iter));
  5739. if (!prop_is_valid) {
  5740. ast_log(LOG_ERROR, "ARI StasisStart field asterisk_id failed validation\n");
  5741. res = 0;
  5742. }
  5743. } else
  5744. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5745. int prop_is_valid;
  5746. has_type = 1;
  5747. prop_is_valid = ast_ari_validate_string(
  5748. ast_json_object_iter_value(iter));
  5749. if (!prop_is_valid) {
  5750. ast_log(LOG_ERROR, "ARI StasisStart field type failed validation\n");
  5751. res = 0;
  5752. }
  5753. } else
  5754. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5755. int prop_is_valid;
  5756. has_application = 1;
  5757. prop_is_valid = ast_ari_validate_string(
  5758. ast_json_object_iter_value(iter));
  5759. if (!prop_is_valid) {
  5760. ast_log(LOG_ERROR, "ARI StasisStart field application failed validation\n");
  5761. res = 0;
  5762. }
  5763. } else
  5764. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5765. int prop_is_valid;
  5766. prop_is_valid = ast_ari_validate_date(
  5767. ast_json_object_iter_value(iter));
  5768. if (!prop_is_valid) {
  5769. ast_log(LOG_ERROR, "ARI StasisStart field timestamp failed validation\n");
  5770. res = 0;
  5771. }
  5772. } else
  5773. if (strcmp("args", ast_json_object_iter_key(iter)) == 0) {
  5774. int prop_is_valid;
  5775. has_args = 1;
  5776. prop_is_valid = ast_ari_validate_list(
  5777. ast_json_object_iter_value(iter),
  5778. ast_ari_validate_string);
  5779. if (!prop_is_valid) {
  5780. ast_log(LOG_ERROR, "ARI StasisStart field args failed validation\n");
  5781. res = 0;
  5782. }
  5783. } else
  5784. if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
  5785. int prop_is_valid;
  5786. has_channel = 1;
  5787. prop_is_valid = ast_ari_validate_channel(
  5788. ast_json_object_iter_value(iter));
  5789. if (!prop_is_valid) {
  5790. ast_log(LOG_ERROR, "ARI StasisStart field channel failed validation\n");
  5791. res = 0;
  5792. }
  5793. } else
  5794. if (strcmp("replace_channel", ast_json_object_iter_key(iter)) == 0) {
  5795. int prop_is_valid;
  5796. prop_is_valid = ast_ari_validate_channel(
  5797. ast_json_object_iter_value(iter));
  5798. if (!prop_is_valid) {
  5799. ast_log(LOG_ERROR, "ARI StasisStart field replace_channel failed validation\n");
  5800. res = 0;
  5801. }
  5802. } else
  5803. {
  5804. ast_log(LOG_ERROR,
  5805. "ARI StasisStart has undocumented field %s\n",
  5806. ast_json_object_iter_key(iter));
  5807. res = 0;
  5808. }
  5809. }
  5810. if (!has_type) {
  5811. ast_log(LOG_ERROR, "ARI StasisStart missing required field type\n");
  5812. res = 0;
  5813. }
  5814. if (!has_application) {
  5815. ast_log(LOG_ERROR, "ARI StasisStart missing required field application\n");
  5816. res = 0;
  5817. }
  5818. if (!has_args) {
  5819. ast_log(LOG_ERROR, "ARI StasisStart missing required field args\n");
  5820. res = 0;
  5821. }
  5822. if (!has_channel) {
  5823. ast_log(LOG_ERROR, "ARI StasisStart missing required field channel\n");
  5824. res = 0;
  5825. }
  5826. return res;
  5827. }
  5828. ari_validator ast_ari_validate_stasis_start_fn(void)
  5829. {
  5830. return ast_ari_validate_stasis_start;
  5831. }
  5832. int ast_ari_validate_text_message_received(struct ast_json *json)
  5833. {
  5834. int res = 1;
  5835. struct ast_json_iter *iter;
  5836. int has_type = 0;
  5837. int has_application = 0;
  5838. int has_message = 0;
  5839. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5840. if (strcmp("asterisk_id", ast_json_object_iter_key(iter)) == 0) {
  5841. int prop_is_valid;
  5842. prop_is_valid = ast_ari_validate_string(
  5843. ast_json_object_iter_value(iter));
  5844. if (!prop_is_valid) {
  5845. ast_log(LOG_ERROR, "ARI TextMessageReceived field asterisk_id failed validation\n");
  5846. res = 0;
  5847. }
  5848. } else
  5849. if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
  5850. int prop_is_valid;
  5851. has_type = 1;
  5852. prop_is_valid = ast_ari_validate_string(
  5853. ast_json_object_iter_value(iter));
  5854. if (!prop_is_valid) {
  5855. ast_log(LOG_ERROR, "ARI TextMessageReceived field type failed validation\n");
  5856. res = 0;
  5857. }
  5858. } else
  5859. if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
  5860. int prop_is_valid;
  5861. has_application = 1;
  5862. prop_is_valid = ast_ari_validate_string(
  5863. ast_json_object_iter_value(iter));
  5864. if (!prop_is_valid) {
  5865. ast_log(LOG_ERROR, "ARI TextMessageReceived field application failed validation\n");
  5866. res = 0;
  5867. }
  5868. } else
  5869. if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
  5870. int prop_is_valid;
  5871. prop_is_valid = ast_ari_validate_date(
  5872. ast_json_object_iter_value(iter));
  5873. if (!prop_is_valid) {
  5874. ast_log(LOG_ERROR, "ARI TextMessageReceived field timestamp failed validation\n");
  5875. res = 0;
  5876. }
  5877. } else
  5878. if (strcmp("endpoint", ast_json_object_iter_key(iter)) == 0) {
  5879. int prop_is_valid;
  5880. prop_is_valid = ast_ari_validate_endpoint(
  5881. ast_json_object_iter_value(iter));
  5882. if (!prop_is_valid) {
  5883. ast_log(LOG_ERROR, "ARI TextMessageReceived field endpoint failed validation\n");
  5884. res = 0;
  5885. }
  5886. } else
  5887. if (strcmp("message", ast_json_object_iter_key(iter)) == 0) {
  5888. int prop_is_valid;
  5889. has_message = 1;
  5890. prop_is_valid = ast_ari_validate_text_message(
  5891. ast_json_object_iter_value(iter));
  5892. if (!prop_is_valid) {
  5893. ast_log(LOG_ERROR, "ARI TextMessageReceived field message failed validation\n");
  5894. res = 0;
  5895. }
  5896. } else
  5897. {
  5898. ast_log(LOG_ERROR,
  5899. "ARI TextMessageReceived has undocumented field %s\n",
  5900. ast_json_object_iter_key(iter));
  5901. res = 0;
  5902. }
  5903. }
  5904. if (!has_type) {
  5905. ast_log(LOG_ERROR, "ARI TextMessageReceived missing required field type\n");
  5906. res = 0;
  5907. }
  5908. if (!has_application) {
  5909. ast_log(LOG_ERROR, "ARI TextMessageReceived missing required field application\n");
  5910. res = 0;
  5911. }
  5912. if (!has_message) {
  5913. ast_log(LOG_ERROR, "ARI TextMessageReceived missing required field message\n");
  5914. res = 0;
  5915. }
  5916. return res;
  5917. }
  5918. ari_validator ast_ari_validate_text_message_received_fn(void)
  5919. {
  5920. return ast_ari_validate_text_message_received;
  5921. }
  5922. int ast_ari_validate_application(struct ast_json *json)
  5923. {
  5924. int res = 1;
  5925. struct ast_json_iter *iter;
  5926. int has_bridge_ids = 0;
  5927. int has_channel_ids = 0;
  5928. int has_device_names = 0;
  5929. int has_endpoint_ids = 0;
  5930. int has_name = 0;
  5931. for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
  5932. if (strcmp("bridge_ids", ast_json_object_iter_key(iter)) == 0) {
  5933. int prop_is_valid;
  5934. has_bridge_ids = 1;
  5935. prop_is_valid = ast_ari_validate_list(
  5936. ast_json_object_iter_value(iter),
  5937. ast_ari_validate_string);
  5938. if (!prop_is_valid) {
  5939. ast_log(LOG_ERROR, "ARI Application field bridge_ids failed validation\n");
  5940. res = 0;
  5941. }
  5942. } else
  5943. if (strcmp("channel_ids", ast_json_object_iter_key(iter)) == 0) {
  5944. int prop_is_valid;
  5945. has_channel_ids = 1;
  5946. prop_is_valid = ast_ari_validate_list(
  5947. ast_json_object_iter_value(iter),
  5948. ast_ari_validate_string);
  5949. if (!prop_is_valid) {
  5950. ast_log(LOG_ERROR, "ARI Application field channel_ids failed validation\n");
  5951. res = 0;
  5952. }
  5953. } else
  5954. if (strcmp("device_names", ast_json_object_iter_key(iter)) == 0) {
  5955. int prop_is_valid;
  5956. has_device_names = 1;
  5957. prop_is_valid = ast_ari_validate_list(
  5958. ast_json_object_iter_value(iter),
  5959. ast_ari_validate_string);
  5960. if (!prop_is_valid) {
  5961. ast_log(LOG_ERROR, "ARI Application field device_names failed validation\n");
  5962. res = 0;
  5963. }
  5964. } else
  5965. if (strcmp("endpoint_ids", ast_json_object_iter_key(iter)) == 0) {
  5966. int prop_is_valid;
  5967. has_endpoint_ids = 1;
  5968. prop_is_valid = ast_ari_validate_list(
  5969. ast_json_object_iter_value(iter),
  5970. ast_ari_validate_string);
  5971. if (!prop_is_valid) {
  5972. ast_log(LOG_ERROR, "ARI Application field endpoint_ids failed validation\n");
  5973. res = 0;
  5974. }
  5975. } else
  5976. if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
  5977. int prop_is_valid;
  5978. has_name = 1;
  5979. prop_is_valid = ast_ari_validate_string(
  5980. ast_json_object_iter_value(iter));
  5981. if (!prop_is_valid) {
  5982. ast_log(LOG_ERROR, "ARI Application field name failed validation\n");
  5983. res = 0;
  5984. }
  5985. } else
  5986. {
  5987. ast_log(LOG_ERROR,
  5988. "ARI Application has undocumented field %s\n",
  5989. ast_json_object_iter_key(iter));
  5990. res = 0;
  5991. }
  5992. }
  5993. if (!has_bridge_ids) {
  5994. ast_log(LOG_ERROR, "ARI Application missing required field bridge_ids\n");
  5995. res = 0;
  5996. }
  5997. if (!has_channel_ids) {
  5998. ast_log(LOG_ERROR, "ARI Application missing required field channel_ids\n");
  5999. res = 0;
  6000. }
  6001. if (!has_device_names) {
  6002. ast_log(LOG_ERROR, "ARI Application missing required field device_names\n");
  6003. res = 0;
  6004. }
  6005. if (!has_endpoint_ids) {
  6006. ast_log(LOG_ERROR, "ARI Application missing required field endpoint_ids\n");
  6007. res = 0;
  6008. }
  6009. if (!has_name) {
  6010. ast_log(LOG_ERROR, "ARI Application missing required field name\n");
  6011. res = 0;
  6012. }
  6013. return res;
  6014. }
  6015. ari_validator ast_ari_validate_application_fn(void)
  6016. {
  6017. return ast_ari_validate_application;
  6018. }