public int importAlbums(
      final UUID jobId,
      IdempotentImportExecutor idempotentImportExecutor,
      Collection<MediaAlbum> mediaAlbums,
      @NotNull final String dataClass)
      throws Exception {
    AtomicInteger successAlbumsCount = new AtomicInteger(0);
    final Map<String, MediaAlbum> dataIdToMediaAlbum =
        mediaAlbums.stream().collect(Collectors.toMap(MediaAlbum::getId, mediaAlbum -> mediaAlbum));

    UnmodifiableIterator<List<MediaAlbum>> batches =
        Iterators.partition(mediaAlbums.iterator(), ApplePhotosConstants.maxNewAlbumRequests);
    while (batches.hasNext()) {
      final PhotosProtocol.CreateAlbumsResponse createAlbumsResponse =
          createAlbums(jobId.toString(), dataClass, batches.next());
      for (PhotosProtocol.NewPhotoAlbumResponse newPhotoAlbumResponse :
          createAlbumsResponse.getNewPhotoAlbumResponsesList()) {
        final String dataId = newPhotoAlbumResponse.getDataId();
        final MediaAlbum mediaAlbum = dataIdToMediaAlbum.get(dataId);
        if (newPhotoAlbumResponse.hasStatus()
            && newPhotoAlbumResponse.getStatus().getCode() == SC_OK) {
          successAlbumsCount.getAndIncrement();
          idempotentImportExecutor.executeAndSwallowIOExceptions(
            mediaAlbum.getId(),
            mediaAlbum.getName(),
            () -> {
              monitor.debug(
                () -> "Apple importing album",
                AuditKeys.jobId, jobId,
                AuditKeys.albumId, dataId,
                AuditKeys.recordId, newPhotoAlbumResponse.getRecordId());
              return newPhotoAlbumResponse.getRecordId();
            });
        } else {
          idempotentImportExecutor.executeAndSwallowIOExceptions(
            mediaAlbum.getId(),
            mediaAlbum.getName(),
            () -> {
              throw new IOException(getApplePhotosImportThrowingMessage("Fail to create album",
                      ImmutableMap.of(
                              AuditKeys.errorCode, Optional.of(String.valueOf(newPhotoAlbumResponse.getStatus().getCode())),
                              AuditKeys.jobId, Optional.of(jobId.toString()),
                              AuditKeys.albumId, Optional.of(mediaAlbum.getId()))));
            });
        }
      }
    }
    return successAlbumsCount.get();
  }
An interface that is synonymous to HTTP client to interact with the Apple Photos APIs.
extensions/data-transfer/portability-data-transfer-apple/src/main/java/org/datatransferproject/datatransfer/apple/photos/AppleMediaInterface.java