public int importPlaylists(final UUID jobId,
            IdempotentImportExecutor idempotentImportExecutor,
            Collection<MusicPlaylist> musicPlaylists) throws Exception {

        UnmodifiableIterator<List<MusicPlaylist>> batches = Iterators.partition(musicPlaylists.iterator(), AppleMusicConstants.MAX_NEW_PLAYLIST_REQUESTS);
        AtomicInteger successPlaylistsCount = new AtomicInteger(0);


        while (batches.hasNext()) {
            MusicProtocol.ImportMusicPlaylistsResponse importMusicPlaylistsResponse = importPlaylistsBatch(jobId.toString(), batches.next());

            for (MusicProtocol.MusicPlaylistResponse playlistResponse : importMusicPlaylistsResponse.getMusicPlaylistResponseList()) {
                String playlistId = playlistResponse.getId();
                String playlistName = playlistResponse.getName();
                if (playlistResponse.hasStatus() && playlistResponse.getStatus().getCode() == SC_OK) {
                    successPlaylistsCount.getAndIncrement();
                    idempotentImportExecutor.executeAndSwallowIOExceptions(
                            playlistId,
                            playlistName,
                            () -> {
                                monitor.debug(
                                        () -> "Apple importing music playlist",
                                        AuditKeys.jobId, jobId,
                                        AuditKeys.playlistId, playlistResponse.getId());
                                return playlistResponse.getId();
                            });
                } else {
                    idempotentImportExecutor.executeAndSwallowIOExceptions(
                            playlistId,
                            playlistName,
                            () -> {
                                monitor.severe(
                                        () -> "Error importing playlist to Apple Music: ",
                                        AuditKeys.jobId, jobId,
                                        AuditKeys.playlistId, playlistResponse.getId());

                                throw new IOException(
                                        String.format(
                                                "Failed to create playlist in Apple Music, server's error code: %d, error message: %s",
                                                playlistResponse.getStatus().getCode(),
                                                playlistResponse.getStatus().getMessage()));
                            });
                }
            }
        }
        return successPlaylistsCount.get();
    }
@return the total number of playlists acknowledged by the Apple Music Library Service in this page
extensions/data-transfer/portability-data-transfer-apple/src/main/java/org/datatransferproject/datatransfer/apple/music/AppleMusicInterface.java