Skip to content

Commit 058226c

Browse files
* Reformat code
* Merge code with IngestV2 branch * Reorganize code and remove DTO's
1 parent e24365e commit 058226c

23 files changed

+778
-1185
lines changed

ingest-v2/pom.xml

Lines changed: 20 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
<groupId>com.microsoft.azure.kusto</groupId>
65
<artifactId>ingest-v2</artifactId>
76
<version>${revision}</version>
87
<name>ingest-v2</name>
@@ -53,7 +52,7 @@
5352
<dependency>
5453
<groupId>io.ktor</groupId>
5554
<artifactId>ktor-serialization-jackson</artifactId>
56-
<version>${ktor_version}</version>
55+
<version>${ktor.version}</version>
5756
</dependency>
5857
<dependency>
5958
<groupId>org.slf4j</groupId>
@@ -76,12 +75,6 @@
7675
<version>${kotlinx.coroutines.debug.version}</version>
7776
<scope>test</scope>
7877
</dependency>
79-
<dependency>
80-
<groupId>io.mockk</groupId>
81-
<artifactId>mockk-jvm</artifactId>
82-
<version>1.14.5</version>
83-
<scope>test</scope>
84-
</dependency>
8578
<dependency>
8679
<groupId>org.junit.jupiter</groupId>
8780
<artifactId>junit-jupiter-params</artifactId>
@@ -94,6 +87,12 @@
9487
<version>1.14.5</version>
9588
<scope>test</scope>
9689
</dependency>
90+
<dependency>
91+
<groupId>${project.groupId}</groupId>
92+
<artifactId>kusto-data</artifactId>
93+
<version>${project.parent.version}</version>
94+
<scope>test</scope>
95+
</dependency>
9796
</dependencies>
9897
<build>
9998
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
@@ -108,7 +107,6 @@
108107
<plugin>
109108
<artifactId>kotlin-maven-plugin</artifactId>
110109
<groupId>org.jetbrains.kotlin</groupId>
111-
<artifactId>kotlin-maven-plugin</artifactId>
112110
<version>${kotlin.version}</version>
113111
<executions>
114112
<execution>
@@ -132,6 +130,18 @@
132130
</goals>
133131
</execution>
134132
</executions>
133+
<configuration>
134+
<compilerPlugins>
135+
<plugin>kotlinx-serialization</plugin>
136+
</compilerPlugins>
137+
</configuration>
138+
<dependencies>
139+
<dependency>
140+
<groupId>org.jetbrains.kotlin</groupId>
141+
<artifactId>kotlin-maven-serialization</artifactId>
142+
<version>${kotlin.version}</version>
143+
</dependency>
144+
</dependencies>
135145
</plugin>
136146
<plugin>
137147
<groupId>org.codehaus.mojo</groupId>
@@ -144,12 +154,6 @@
144154
</goals>
145155
</execution>
146156
</executions>
147-
<configuration>
148-
<compilerPlugins>
149-
<plugin>kotlinx-serialization</plugin>
150-
</compilerPlugins>
151-
<jvmTarget>1.8</jvmTarget>
152-
</configuration>
153157
<dependencies>
154158
<dependency>
155159
<groupId>org.jetbrains.kotlin</groupId>
@@ -196,45 +200,6 @@
196200
</execution>
197201
</executions>
198202
</plugin>
199-
<plugin>
200-
<groupId>com.diffplug.spotless</groupId>
201-
<artifactId>spotless-maven-plugin</artifactId>
202-
<version>${spotless.version}</version>
203-
<configuration>
204-
<kotlin>
205-
<!-- These are the defaults, you can override if you want -->
206-
<includes>
207-
<include>src/main/kotlin/**/*.kt</include>
208-
<include>src/test/kotlin/**/*.kt</include>
209-
</includes>
210-
211-
<ktfmt>
212-
<version>0.51</version> <!-- optional -->
213-
<style>KOTLINLANG</style> <!-- optional, options are META (default), GOOGLE and KOTLINLANG -->
214-
<maxWidth>120</maxWidth> <!-- optional -->
215-
<blockIndent>4</blockIndent> <!-- optional -->
216-
<continuationIndent>8</continuationIndent> <!-- optional -->
217-
<removeUnusedImports>false</removeUnusedImports> <!-- optional -->
218-
<manageTrailingCommas>true</manageTrailingCommas> <!-- optional -->
219-
</ktfmt>
220-
<ktlint>
221-
<version>1.0.0</version> <!-- optional -->
222-
<editorConfigOverride> <!-- optional -->
223-
<ij_kotlin_allow_trailing_comma>true</ij_kotlin_allow_trailing_comma>
224-
<ij_kotlin_allow_trailing_comma_on_call_site>true</ij_kotlin_allow_trailing_comma_on_call_site>
225-
<!-- intellij_idea is the default style we preset in Spotless, you can override it referring to https://pinterest.github.io/ktlint/latest/rules/code-styles. -->
226-
<ktlint_code_style>intellij_idea</ktlint_code_style>
227-
</editorConfigOverride>
228-
<customRuleSets> <!-- optional -->
229-
<value>io.nlopez.compose.rules:ktlint:0.4.25</value>
230-
</customRuleSets>
231-
</ktlint>
232-
<licenseHeader>
233-
<content>/* (C)$YEAR */</content> <!-- or <file>${project.basedir}/license-header</file> -->
234-
</licenseHeader>
235-
</kotlin>
236-
</configuration>
237-
</plugin>
238203
<plugin>
239204
<groupId>org.codehaus.mojo</groupId>
240205
<artifactId>build-helper-maven-plugin</artifactId>
@@ -299,7 +264,7 @@
299264
<dependency>
300265
<groupId>org.jetbrains.kotlin</groupId>
301266
<artifactId>kotlin-maven-serialization</artifactId>
302-
<version>${kotlin_version}</version>
267+
<version>${kotlin.version}</version>
303268
</dependency>
304269
</dependencies>
305270
</plugin>

ingest-v2/src/main/kotlin/Application.kt

Lines changed: 0 additions & 13 deletions
This file was deleted.

ingest-v2/src/main/kotlin/HTTP.kt

Lines changed: 0 additions & 20 deletions
This file was deleted.

ingest-v2/src/main/kotlin/Routing.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.

ingest-v2/src/main/kotlin/Serialization.kt

Lines changed: 0 additions & 20 deletions
This file was deleted.

ingest-v2/src/main/kotlin/com/microsoft/azure/kusto/ingest/v2/ConfigurationApiWrapper.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
package com.microsoft.azure.kusto.ingest.v2
44

55
import com.azure.core.credential.TokenCredential
6-
import com.microsoft.azure.kusto.ingest.v2.apis.DefaultApi
7-
import com.microsoft.azure.kusto.ingest.v2.common.auth.TokenCredentialsProvider
86
import com.microsoft.azure.kusto.ingest.v2.common.exceptions.IngestException
97
import com.microsoft.azure.kusto.ingest.v2.infrastructure.HttpResponse
108
import com.microsoft.azure.kusto.ingest.v2.models.ConfigurationResponse
@@ -18,8 +16,6 @@ class ConfigurationApiWrapper(
1816
private val logger =
1917
LoggerFactory.getLogger(ConfigurationApiWrapper::class.java)
2018
private val baseUrl = "$dmUrl/v1/rest/ingestion/configuration"
21-
private val api: DefaultApi =
22-
DefaultApi(baseUrl = dmUrl, httpClientConfig = setupConfig)
2319

2420
suspend fun getConfigurationDetails(): ConfigurationResponse {
2521
val configurationHttpResponse: HttpResponse<ConfigurationResponse> =
@@ -32,7 +28,6 @@ class ConfigurationApiWrapper(
3228
"Configuration details: {}",
3329
configurationHttpResponse.body(),
3430
)
35-
logger.debug("Configuration details: {}", configurationHttpResponse.body())
3631
return configurationHttpResponse.body()
3732
} else {
3833
logger.error(

ingest-v2/src/main/kotlin/com/microsoft/azure/kusto/ingest/v2/KustoBaseApiClient.kt

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package com.microsoft.azure.kusto.ingest.v2
44

55
import com.azure.core.credential.TokenCredential
66
import com.azure.core.credential.TokenRequestContext
7+
import com.microsoft.azure.kusto.ingest.v2.apis.DefaultApi
8+
import com.microsoft.azure.kusto.ingest.v2.common.serialization.OffsetDateTimeSerializer
79
import io.ktor.client.HttpClientConfig
810
import io.ktor.client.plugins.DefaultRequest
911
import io.ktor.client.plugins.auth.Auth
@@ -12,8 +14,10 @@ import io.ktor.client.plugins.auth.providers.bearer
1214
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
1315
import io.ktor.client.request.header
1416
import io.ktor.serialization.kotlinx.json.json
15-
import kotlinx.serialization.json.Json
1617
import kotlinx.coroutines.suspendCancellableCoroutine
18+
import kotlinx.serialization.json.Json
19+
import kotlinx.serialization.modules.SerializersModule
20+
import java.time.OffsetDateTime
1721
import kotlin.coroutines.resume
1822
import kotlin.coroutines.resumeWithException
1923

@@ -22,20 +26,15 @@ open class KustoBaseApiClient(
2226
open val tokenCredential: TokenCredential,
2327
open val skipSecurityChecks: Boolean = false,
2428
) {
25-
init {
26-
if (!skipSecurityChecks) {
27-
val uri = URI(clusterUrl)
28-
val scheme = uri.scheme?.lowercase()
29-
if (scheme != "https") {
30-
throw IllegalArgumentException("The provided endpoint is not a valid endpoint")
31-
}
32-
}
33-
}
3429

3530
protected val setupConfig: (HttpClientConfig<*>) -> Unit = { config ->
3631
getClientConfig(config)
3732
}
3833

34+
protected val api: DefaultApi by lazy {
35+
DefaultApi(baseUrl = dmUrl, httpClientConfig = setupConfig)
36+
}
37+
3938
private fun getClientConfig(config: HttpClientConfig<*>) {
4039
config.install(DefaultRequest) {
4140
header("Content-Type", "application/json")
@@ -55,15 +54,24 @@ open class KustoBaseApiClient(
5554
.getToken(trc)
5655
.subscribe(
5756
{ accessToken ->
58-
val bearerTokens = BearerTokens(
59-
accessToken = accessToken.token,
60-
refreshToken = null,
57+
val bearerTokens =
58+
BearerTokens(
59+
accessToken =
60+
accessToken
61+
.token,
62+
refreshToken =
63+
null,
64+
)
65+
continuation.resume(
66+
bearerTokens,
6167
)
62-
continuation.resume(bearerTokens)
6368
},
6469
{ error ->
65-
continuation.resumeWithException(error)
66-
}
70+
continuation
71+
.resumeWithException(
72+
error,
73+
)
74+
},
6775
)
6876
}
6977
} catch (e: Exception) {
@@ -78,10 +86,13 @@ open class KustoBaseApiClient(
7886
Json {
7987
ignoreUnknownKeys = true
8088
serializersModule = SerializersModule {
81-
contextual(OffsetDateTime::class, OffsetDateTimeSerializer)
89+
contextual(
90+
OffsetDateTime::class,
91+
OffsetDateTimeSerializer,
92+
)
8293
}
8394
// Optionally add other settings if needed:
84-
// isLenient = true
95+
isLenient = true
8596
// allowSpecialFloatingPointValues = true
8697
// useArrayPolymorphism = true
8798
},

0 commit comments

Comments
 (0)