(self, federation_ident, patch)
return patch
Intercept PATCH JSON documents for join operations.

        Take a PATCH JSON document with `add` operation::
            {
                'op': 'add',
                'value': 'new_member_id',
                'path': '/member_ids'
            }
        and transform it into a document with `replace` operation::
            {
                'op': 'replace',
                'value': ['current_member_id1', ..., 'new_member_id'],
                'path': '/member_ids'
            }
Intercept PATCH JSON documents for join operations.
Intercept PATCH JSON documents for join operations .
def _join_wrapper(self, federation_ident, patch):
        """Intercept PATCH JSON documents for join operations.

        Take a PATCH JSON document with `add` operation::
            {
                'op': 'add',
                'value': 'new_member_id',
                'path': '/member_ids'
            }
        and transform it into a document with `replace` operation::
            {
                'op': 'replace',
                'value': ['current_member_id1', ..., 'new_member_id'],
                'path': '/member_ids'
            }
        """
        federation = api_utils.get_resource('Federation', federation_ident)
        new_member_uuid = patch[0]['value']

        # Check if the cluster exists
        c = objects.Cluster.get_by_uuid(pecan.request.context, new_member_uuid)

        # Check if the cluster is already a member of the federation
        if new_member_uuid not in federation.member_ids and c is not None:
            # Retrieve all current members
            members = federation.member_ids
            # Add the new member
            members.append(c.uuid)
        else:
            kw = {'uuid': new_member_uuid, 'federation_name': federation.name}
            raise exception.MemberAlreadyExists(**kw)

        # Set `value` to the updated member list. Change `op` to `replace`
        patch[0]['value'] = members
        patch[0]['op'] = 'replace'

        return patch
def _join_wrapper ( self , federation_ident , patch ) : federation = api_utils . get_resource ( 'Federation' , federation_ident ) new_member_uuid = patch [ 0 ] [ 'value' ] # Check if the cluster exists c = objects . Cluster . get_by_uuid ( pecan . request . context , new_member_uuid ) # Check if the cluster is already a member of the federation if new_member_uuid not in federation . member_ids and c is not None : # Retrieve all current members members = federation . member_ids # Add the new member members . append ( c . uuid ) else : kw = { 'uuid' : new_member_uuid , 'federation_name' : federation . name } raise exception . MemberAlreadyExists ( * * kw ) # Set `value` to the updated member list. Change `op` to `replace` patch [ 0 ] [ 'value' ] = members patch [ 0 ] [ 'op' ] = 'replace' return patch