override suspend fun upload()

in src/main/kotlin/space/SpaceUploader.kt [39:88]


    override suspend fun upload(
        server: String,
        token: String,
        issues: List<IssueTemplate>,
        projectIdentifier: ProjectIdentifier,
        importSource: ImportSource,
        assigneeMissingPolicy: ImportMissingPolicy,
        statusMissingPolicy: ImportMissingPolicy,
        onExistsPolicy: ImportExistsPolicy,
        dryRun: Boolean,
        batchSize: Int,
        debug: Boolean,
        tagPropertyMappingType: ProjectPropertyType?
    ): List<IssueImportResult> {
        val httpClient = ktorClientForSpace()
            .let {
                if (debug) {
                    it.config {
                        install(Logging) {
                            logger = SpaceUploaderImpl.logger.createHttpClientLogger()
                            level = LogLevel.ALL
                        }
                    }
                } else {
                    it
                }
            }

        val spaceClient = SpaceClient(httpClient, serverUrl = server, token = token)

        if (dryRun) logger.info("[DRY RUN]")

        val result = issues.chunked(batchSize).map { issuesBatched ->
            spaceClient.projects.planning.issues.importIssues(
                project = projectIdentifier,
                metadata = ImportMetadata(importSource.name),
                issues = issuesBatched.map { it.externalIssue },
                assigneeMissingPolicy = assigneeMissingPolicy,
                statusMissingPolicy = statusMissingPolicy,
                onExistsPolicy = onExistsPolicy,
                dryRun = dryRun
            ).also { response -> logger.info(response.message) }
        }

        if (!dryRun) {
            tagPropertyMappingType?.let { spaceClient.addTags(projectIdentifier, issues, tagPropertyMappingType, result) }
        }

        return result
    }