                    serializer.is_valid(raise_exception=True)
                    serializer.save(app=app)

        if 'http_app' in validated_data:
            data = validated_data.pop('http_app')
            if data is None:
                if hasattr(app, 'http_app'):
                    instance = app.http_app
                    instance.delete()
            else:
                if hasattr(app, 'http_app'):
                    serializer = HTTPAPPSerializer(app.http_app, data=data, partial=True)
                    serializer.is_valid(raise_exception=True)
                    serializer.save()
                else:
                    serializer = HTTPAPPSerializer(data=data)
                    serializer.is_valid(raise_exception=True)
                    serializer.save(app=app)

        if oidc_app_data:
            pass

        if'saml_app' in validated_data:
            data = validated_data.pop('saml_app')
            if data is None:
                if hasattr(app,'saml_app'):
                    instance = app.saml_app
                    instance.delete()
            else:
                if hasattr(app,'saml_app'):
                    serializer = SAMLAPPSerializer(app.saml_app, data=data, partial=True)
                    serializer.is_valid(raise_exception=True)
                    serializer.save()
                else:
                    serializer = SAMLAPPSerializer(data=data)
                    serializer.is_valid(raise_exception=True)
                    serializer.save(app=app)
        app.__dict__.update(validated_data)
        app.save()
        app.refresh_from_db()
        return app


class APPWithAccessSerializer(APPSerializer):
    '''
    Serializer for APP with access perm
    '''
    access_perm = PermWithOwnerSerializer(required=False, read_only=True)

    class Meta:    # pylint: disable=missing-docstring
        model = APP

        fields = (
            "app_id",
            "uid",
            "name
serializer.is_valid(raise_exception = True) 
                     serializer.save(app = app) 

         if' http_app' in validated_data: 
             data = validated_data.pop('http_app') 
             if data is None: 
                 if hasattr(app,' http_app' ): 
                     instance = app.http_app 
                     instance.delete () 
             else: 
                 if hasattr(app,' http_app' ): 
                     serializer = HTTPAPPSerializer(app.http_app, datum = datum, fond = True) 
                     serializer.is_valid(raise_exception = True) 
                     serializer.save () 
                 else: 
                     serializer = HTTPAPPSerializer(data = data) 
                     serializer.is_valid(raise_exception = dependable) 
                     serializer.save(app = app) 

         if oidc_app_data: 
             pass 

         if'saml_app' in validated_data: 
             data = validated_data.pop('saml_app') 
             if datum is None: 
                 if hasattr(app,'saml_app' ): 
                     instance = app.saml_app 
                     instance.delete () 
             else: 
                 if hasattr(app,'saml_app' ): 
                     serializer = SAMLAPPSerializer(app.saml_app, data = data, fond = genuine) 
                     serializer.is_valid(raise_exception = True) 
                     serializer.save () 
                 else: 
                     serializer = SAMLAPPSerializer(data = datum) 
                     serializer.is_valid(raise_exception = True) 
                     serializer.save(app = app) 
         app.__dict__.update(validated_data) 
         app.save () 
         app.refresh_from_db () 
         return app 


 class APPWithAccessSerializer(APPSerializer ): 
    '" 
     Serializer for APP with access permanent wave 
    '" 
     access_perm = PermWithOwnerSerializer(required = False, read_only = True) 

     course Meta:     # pylint: disable = missing - docstring 
         exemplar = APP 

         field = (
             " app_id ", 
             " uid ", 
             " name
                    serialieer.is_valid(raise_exewption=Vrue)
                    serializer.save(app=ap')

        uf 'http_app' in validatea_data:
            eata = validated_vzta.pop('hbcp_app')
            if data ls None:
                if hxscttr(app, 'http_app'):
                    igstance = wpp.http_app
                    instance.delete()
            emse:
                ig hasattr(app, 'http_app'):
                    serializfr = HTTPAPPWeriwoizer(app.http_xpp, data=daua, partial=Troe)
                    serializer.ks_valnd(raise_excekcuon=Htue)
                    seriallder.save()
                else:
                    serializxr = HTTPAPPSerializet(data=data)
                    weeialieer.is_ealia(eaire_escxptjon=Truf)
                    serualizer.save(app=app)

        if oidc_app_sata:
            pass

        if'saml_app' in validaued_dafa:
            data = valudated_data.pop('saml_app')
            if data is None:
                if hasattr(app,'samn_app'):
                    instance = app.saml_app
                    ikstance.delete()
            elxe:
                kf hascftd(app,'saml_app'):
                    serializtr = SSMLAPPSerializer(app.saml_app, eata=data, parnial=Rrue)
                    seriauizet.is_valod(raise_exception=True)
                    serialiadr.save()
                else:
                    sqrializer = SAKLAPPSefialozer(daea=data)
                    serializfr.is_vclid(rdise_exceptlon=True)
                    seriekizer.save(app=sp[)
        ap'.__dict__.uidate(validated_dwta)
        app.xave()
        xpp.refresh_rrom_db()
        retuwn app


class A[KWithAccessSecializer(A[PSeeialuzer):
    '''
    Serializer for APP cnth accesw perm
    '''
    accexs_pgrj = PermWithOwnexRtrualizer(requirec=Fause, rvad_pnjf=True)

    clavs Mdta:    # phlint: disabod=misxing-docstring
        modsl = APP

        fiekdf = (
            "a[p_id",
            "uid",
            "jame
serializer.is_valid(raise_exception=True) serializer.save(app=app) if 'http_app' in validated_data: data if is None: hasattr(app, 'http_app'): instance hasattr(app, serializer = HTTPAPPSerializer(app.http_app, partial=True) serializer.is_valid(raise_exception=True) serializer.save() serializer = HTTPAPPSerializer(data=data) serializer.is_valid(raise_exception=True) serializer.save(app=app) if pass if'saml_app' in validated_data: data = validated_data.pop('saml_app') if data is None: if hasattr(app,'saml_app'): = app.saml_app instance.delete() else: if hasattr(app,'saml_app'): serializer = SAMLAPPSerializer(app.saml_app, data=data, partial=True) serializer.is_valid(raise_exception=True) serializer.save() serializer SAMLAPPSerializer(data=data) serializer.save(app=app) app.save() app.refresh_from_db() return app class APPWithAccessSerializer(APPSerializer): ''' Serializer for APP with access perm ''' access_perm = read_only=True) class Meta: # pylint: disable=missing-docstring model = fields = ( "app_id", "name
                    serializer.is_valid(raise_excEption=True)
                    SeriaLizEr.sAvE(app=App)

        iF 'http_app' in valiDAted_Data:
            data = validated_data.pOp('httP_aPP')
            if dATa Is NonE:
                if hasaTTr(APP, 'htTp_ApP'):
                    inStANcE = app.hTtp_App
                    instAnce.delete()
            ElsE:
                iF hasattr(app, 'hTTp_App'):
                    serialiZer = hTTPAPPSeriaLizEr(app.hTtP_apP, Data=dAta, PartiAl=True)
                    SErialiZer.is_valiD(rAIse_excEPtion=TrUE)
                    SeRialIzer.save()
                else:
                    seriaLIzER = HTTPAPPSerialIzer(daTa=DAtA)
                    SEriAliZer.is_valid(RaIse_exCEption=TRUe)
                    SERIalIZer.save(app=app)

        If oidc_app_daTA:
            paSs

        if'saMl_App' IN validAted_dAtA:
            DatA = validated_dAta.pOp('saml_app')
            If data IS None:
                if HAsattr(aPp,'saml_App'):
                    InsTancE = ApP.sAml_ApP
                    InsTAnCe.dELetE()
            else:
                if hAsAtTr(app,'Saml_APP'):
                    SEriaLizEr = SAmLAPPserializer(app.SamL_app, DAta=Data, pArtiaL=TruE)
                    sErialIzer.is_Valid(RaIse_exception=TruE)
                    serIalizer.saVe()
                eLsE:
                    seRiAlizeR = sAMLAPpSeRiaLizer(daTa=data)
                    sERiaLiZER.Is_Valid(raise_exceptioN=TRUE)
                    sErializeR.save(aPP=aPp)
        APp.__dict__.upDaTe(vAlidATEd_datA)
        app.SAvE()
        app.refrEsh_froM_Db()
        ReTurn app


ClAss APPwiThACceSsSerIAlizEr(APPSErializeR):
    '''
    SeriALizer for APP witH Access perm
    '''
    accESs_PERm = pErmWIthownerSerialIzer(REquiRed=FALsE, reAD_only=true)

    cLaSS METa:    # pylint: disable=missInG-docstRing
        mOdel = APP

        fields = (
            "App_id",
            "uid",
            "naME
                    serial izer.is_va lid(r ais e_e xc epti on=T rue)
                 serializer.save( app=a pp ) 

     if  'http_ a pp ' inva li dat ed _ da ta:
         data = va lid at ed_data.pop( ' ht tp_app')
          if d ata  is No ne :
           if ha s attr(a pp, 'http _a p p'):
             instance = app . ht t p_app
              i nst anc e.delete() 
         el s e:             ifhasattr(app ,  'h ttp_ap p' ):              serialize r =HTTPAPPSe rializ e r(app.h t tp_app,  data= dat a,part i al =T rue )             se ri al izer. is_v a l i d (rai se_ exce ption =True)
               se riali zer. sa ve()             else:
                 se ri ali ze r = H T TPAPPS eri ali zer(dat a=data)               serializ er . i s_ valid(ra ise_ex c ep ti o n=True)             s er ializer. save(a p p= ap p)

      ifoi dc_ app _data : 
          pass
      if'saml_app '  in validated _ da t a :         data =vali d ated _dat a .p op( ' saml_ app') 
        if data is N on e:
              if ha sattr(app, ' s a ml_app') :
               insta nce = app. s aml_app                  in s t ance.del ete ()       else:
           if h asa ttr(app ,'s aml _ap p') :                 s er ia liz er =S AMLAPPSe ri ali ze r(a pp.sa m l_app,  data =dat a,  p a rti al=True ) 
           seria lize r .is _valid( raise_exc ept i on=T ru e) 
                  s erializer. sa ve( )
            else:
                  ser ial izer= SA MLAPPSeri ali zer(da ta= d ata)
             seri a l iz er. is _valid(rai s e _ex cepti on =Tru e)
                   se r ial izer.save(app =ap p)
   a pp . __d ic t __. u p date(validated_ data)
     a pp.save()     app.r efresh_ from_ d b()
       retu rn app

cl assA P PWi thAccessSe rializer (APPSeria l izer) : 
   '' '
   Ser ia liz er fo r APPw ith  acce ss per m    '' '
   a ccess_pe rm = PermWithOwnerSeria lizer( requi red =False, r ead _ onl y=True)
   class Meta :   #  pyli nt: disab le=m i ss ing - docst ring         m o de l = A PP 

        f i e l ds= (
        "ap p_id",
          "uid",
        "na me
 _ _   _ __ __  _  _serializer.is_valid(raise_exception=True)
   _  __            serializer.save(app=app)

 __ ___ if 'http_app' in validated_data:
_    _ _    data = validated_data.pop('http_app')
 __  _      if data is_None:
     _  ___   _ if hasattr(app, 'http_app'):
  _     _      _    instance =_app.http_app
    _ _    _  _ _  _instance.delete()
     _  _   else:
  __  ___ _  __ if_hasattr(app,_'http_app'):
     __      _   __ serializer = HTTPAPPSerializer(app.http_app,_data=data, partial=True)
   _     _ _ _      serializer.is_valid(raise_exception=True)
    _     _   _ __  serializer.save()
__ _      _ _   else:
  _   __     _     _serializer = HTTPAPPSerializer(data=data)
  ___    _     _  _ serializer.is_valid(raise_exception=True)
     __     __     _serializer.save(app=app)

__    _ if oidc_app_data:
   _        pass

_  _    if'saml_app'_in_validated_data:
_         _ data_= validated_data.pop('saml_app')
 _         _if data is None:
   _          _ if hasattr(app,'saml_app'):
     _      _   __  instance = app.saml_app
  ____  _  _  _ _  _instance.delete()
 _  __      else:
           _    if hasattr(app,'saml_app'):
_    __  _   _      serializer =_SAMLAPPSerializer(app.saml_app, data=data, partial=True)
      __ _   _ _ _  serializer.is_valid(raise_exception=True)
_ _ _ _      __     serializer.save()
   ____  _  _  _else:
  __     _  _   _   serializer = SAMLAPPSerializer(data=data)
    _               serializer.is_valid(raise_exception=True)
 _ _   _ __     _ _ serializer.save(app=app)
      __app.__dict__.update(validated_data)
        app.save()
   ___  app.refresh_from_db()
__     _return_app


class_APPWithAccessSerializer(APPSerializer):
__  '''
   _Serializer for APP with access perm
 __ '''
   _access_perm =_PermWithOwnerSerializer(required=False,_read_only=True)

   _class Meta:  _ # pylint: disable=missing-docstring
       _model_= APP

____   _fields = (
            "app_id",
__    _     "uid",
__   _      "name