(self, baymodel_ident, patch)
return BayModel.convert_with_links(baymodel)
Update an existing Baymodel.

        :param baymodel_ident: UUID or logic name of a Baymodel.
        :param patch: a json PATCH document to apply to this Baymodel.
Update an existing Baymodel.
Update an existing Baymodel .
def patch(self, baymodel_ident, patch):
        """Update an existing Baymodel.

        :param baymodel_ident: UUID or logic name of a Baymodel.
        :param patch: a json PATCH document to apply to this Baymodel.
        """
        context = pecan.request.context
        baymodel = api_utils.get_resource('ClusterTemplate', baymodel_ident)
        policy.enforce(context, 'baymodel:update', baymodel.as_dict(),
                       action='baymodel:update')
        try:
            baymodel_dict = baymodel.as_dict()
            new_baymodel = BayModel(**api_utils.apply_jsonpatch(
                baymodel_dict,
                patch))
        except api_utils.JSONPATCH_EXCEPTIONS as e:
            raise exception.PatchError(patch=patch, reason=e)

        new_baymodel_dict = new_baymodel.as_dict()
        attr_validator.validate_os_resources(context, new_baymodel_dict)
        # check permissions when updating baymodel public flag
        if baymodel.public != new_baymodel.public:
            if not policy.enforce(context, "baymodel:publish", None,
                                  do_raise=False):
                raise exception.ClusterTemplatePublishDenied()

        # Update only the fields that have changed
        for field in objects.ClusterTemplate.fields:
            try:
                patch_val = getattr(new_baymodel, field)
            except AttributeError:
                # Ignore fields that aren't exposed in the API
                continue
            if patch_val == wtypes.Unset:
                patch_val = None
            if baymodel[field] != patch_val:
                baymodel[field] = patch_val

        baymodel.save()
        return BayModel.convert_with_links(baymodel)
def patch ( self , baymodel_ident , patch ) : context = pecan . request . context baymodel = api_utils . get_resource ( 'ClusterTemplate' , baymodel_ident ) policy . enforce ( context , 'baymodel:update' , baymodel . as_dict ( ) , action = 'baymodel:update' ) try : baymodel_dict = baymodel . as_dict ( ) new_baymodel = BayModel ( * * api_utils . apply_jsonpatch ( baymodel_dict , patch ) ) except api_utils . JSONPATCH_EXCEPTIONS as e : raise exception . PatchError ( patch = patch , reason = e ) new_baymodel_dict = new_baymodel . as_dict ( ) attr_validator . validate_os_resources ( context , new_baymodel_dict ) # check permissions when updating baymodel public flag if baymodel . public != new_baymodel . public : if not policy . enforce ( context , "baymodel:publish" , None , do_raise = False ) : raise exception . ClusterTemplatePublishDenied ( ) # Update only the fields that have changed for field in objects . ClusterTemplate . fields : try : patch_val = getattr ( new_baymodel , field ) except AttributeError : # Ignore fields that aren't exposed in the API continue if patch_val == wtypes . Unset : patch_val = None if baymodel [ field ] != patch_val : baymodel [ field ] = patch_val baymodel . save ( ) return BayModel . convert_with_links ( baymodel )