Skip to content

Commit 1f340ba

Browse files
chore: Publish v5.1.0 (#196)
Co-authored-by: mohnoor94 <[email protected]> Co-authored-by: mohnoor94 <[email protected]>
1 parent b839970 commit 1f340ba

File tree

348 files changed

+8806
-6343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

348 files changed

+8806
-6343
lines changed

code/LICENSE-HEADER.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2024 Expedia, Inc.
1+
Copyright (C) 2022 Expedia, Inc.
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
@@ -10,4 +10,4 @@ Unless required by applicable law or agreed to in writing, software
1010
distributed under the License is distributed on an "AS IS" BASIS,
1111
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
13-
limitations under the License.
13+
limitations under the License.

code/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<dependency>
66
<groupId>com.expediagroup</groupId>
77
<artifactId>rapid-sdk</artifactId>
8-
<version>5.0.0</version>
8+
<version>5.1.0</version>
99
</dependency>
1010
```
1111

code/pom.xml

Lines changed: 159 additions & 171 deletions
Large diffs are not rendered by default.

code/src/main/kotlin/com/expediagroup/sdk/core/client/BaseRapidClient.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ import io.ktor.client.engine.HttpClientEngine
3232
abstract class BaseRapidClient(
3333
namespace: String,
3434
clientConfiguration: RapidClientConfiguration,
35-
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE
35+
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE,
3636
) : Client(namespace) {
3737
private val _configurationProvider: ConfigurationProvider =
3838
ConfigurationCollector.create(
3939
clientConfiguration.toProvider(),
40-
RapidConfigurationProvider
40+
RapidConfigurationProvider,
4141
)
42-
private val _httpClient: HttpClient = buildHttpClient(_configurationProvider, AuthenticationStrategy.AuthenticationType.SIGNATURE, httpClientEngine)
42+
private val _httpClient: HttpClient =
43+
buildHttpClient(_configurationProvider, AuthenticationStrategy.AuthenticationType.SIGNATURE, httpClientEngine)
4344

4445
init {
4546
finalize()
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (C) 2022 Expedia, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.expediagroup.sdk.core.client
17+
18+
import com.expediagroup.sdk.core.configuration.XapClientConfiguration
19+
import com.expediagroup.sdk.core.configuration.collector.ConfigurationCollector
20+
import com.expediagroup.sdk.core.configuration.provider.ConfigurationProvider
21+
import com.expediagroup.sdk.core.configuration.provider.XapConfigurationProvider
22+
import com.expediagroup.sdk.core.plugin.authentication.strategy.AuthenticationStrategy
23+
import io.ktor.client.HttpClient
24+
import io.ktor.client.engine.HttpClientEngine
25+
26+
/**
27+
* The integration point between the SDK Core and the product SDKs.
28+
*
29+
* @param httpClientEngine The HTTP client engine to use.
30+
* @param clientConfiguration The configuration for the client.
31+
*/
32+
abstract class BaseXapClient(
33+
namespace: String,
34+
clientConfiguration: XapClientConfiguration,
35+
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE,
36+
) : Client(namespace) {
37+
private val _configurationProvider: ConfigurationProvider =
38+
ConfigurationCollector.create(
39+
clientConfiguration.toProvider(),
40+
XapConfigurationProvider,
41+
)
42+
private val _httpClient: HttpClient =
43+
buildHttpClient(_configurationProvider, AuthenticationStrategy.AuthenticationType.BASIC, httpClientEngine)
44+
45+
init {
46+
finalize()
47+
}
48+
49+
override val configurationProvider: ConfigurationProvider
50+
get() = _configurationProvider
51+
52+
override val httpClient: HttpClient
53+
get() = _httpClient
54+
55+
/** A [BaseXapClient] builder. */
56+
@Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients.
57+
abstract class Builder<SELF : Builder<SELF>> : Client.Builder<SELF>()
58+
}

code/src/main/kotlin/com/expediagroup/sdk/core/client/Client.kt

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ val DEFAULT_HTTP_CLIENT_ENGINE: HttpClientEngine =
7272
*/
7373
abstract class Client(
7474
namespace: String,
75-
environmentProvider: EnvironmentProvider = DefaultEnvironmentProvider(namespace)
75+
environmentProvider: EnvironmentProvider = DefaultEnvironmentProvider(namespace),
7676
) : EnvironmentProvider by environmentProvider {
7777
private val httpHandler = DefaultHttpHandler(environmentProvider)
7878

@@ -89,7 +89,7 @@ abstract class Client(
8989
internal fun buildHttpClient(
9090
configurationProvider: ConfigurationProvider,
9191
authenticationType: AuthenticationStrategy.AuthenticationType,
92-
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE
92+
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE,
9393
): HttpClient =
9494
HttpClient(httpClientEngine) {
9595
val httpClientConfig = this
@@ -98,9 +98,18 @@ abstract class Client(
9898
val secret: String = configurationProvider.secret ?: fireMissingConfigurationIssue(ConfigurationName.SECRET)
9999
val endpoint: String = configurationProvider.endpoint ?: fireMissingConfigurationIssue(ConfigurationName.ENDPOINT)
100100
val authEndpoint: String = configurationProvider.authEndpoint ?: fireMissingConfigurationIssue(ConfigurationName.AUTH_ENDPOINT)
101-
val requestTimeout: Long = configurationProvider.requestTimeout ?: fireMissingConfigurationIssue(ConfigurationName.REQUEST_TIMEOUT_MILLIS)
102-
val connectionTimeout: Long = configurationProvider.connectionTimeout ?: fireMissingConfigurationIssue(ConfigurationName.CONNECTION_TIMEOUT_MILLIS)
103-
val socketTimeout: Long = configurationProvider.socketTimeout ?: fireMissingConfigurationIssue(ConfigurationName.SOCKET_TIMEOUT_MILLIS)
101+
val requestTimeout: Long =
102+
configurationProvider.requestTimeout ?: fireMissingConfigurationIssue(
103+
ConfigurationName.REQUEST_TIMEOUT_MILLIS,
104+
)
105+
val connectionTimeout: Long =
106+
configurationProvider.connectionTimeout ?: fireMissingConfigurationIssue(
107+
ConfigurationName.CONNECTION_TIMEOUT_MILLIS,
108+
)
109+
val socketTimeout: Long =
110+
configurationProvider.socketTimeout ?: fireMissingConfigurationIssue(
111+
ConfigurationName.SOCKET_TIMEOUT_MILLIS,
112+
)
104113
val maskedLoggingHeaders: Set<String> = configurationProvider.maskedLoggingHeaders ?: setOf()
105114
val maskedLoggingBodyFields: Set<String> = configurationProvider.maskedLoggingBodyFields ?: setOf()
106115

@@ -109,7 +118,7 @@ abstract class Client(
109118
httpClientConfig,
110119
Credentials.from(key, secret),
111120
authEndpoint,
112-
authenticationType
121+
authenticationType,
113122
)
114123

115124
plugins {
@@ -118,7 +127,9 @@ abstract class Client(
118127
use(AuthenticationPlugin).with(authenticationConfiguration)
119128
use(DefaultRequestPlugin).with(DefaultRequestConfiguration.from(httpClientConfig, endpoint))
120129
use(EncodingPlugin).with(EncodingConfiguration.from(httpClientConfig))
121-
use(HttpTimeoutPlugin).with(HttpTimeoutConfiguration.from(httpClientConfig, requestTimeout, connectionTimeout, socketTimeout))
130+
use(
131+
HttpTimeoutPlugin,
132+
).with(HttpTimeoutConfiguration.from(httpClientConfig, requestTimeout, connectionTimeout, socketTimeout))
122133
use(ExceptionHandlingPlugin).with(ExceptionHandlingConfiguration.from(httpClientConfig))
123134
}
124135

@@ -128,7 +139,8 @@ abstract class Client(
128139
}
129140

130141
/** Throw an exception if the configuration is missing. */
131-
private fun fireMissingConfigurationIssue(configurationKey: String): Nothing = throw ExpediaGroupConfigurationException(getMissingRequiredConfigurationMessage(configurationKey))
142+
private fun fireMissingConfigurationIssue(configurationKey: String): Nothing =
143+
throw ExpediaGroupConfigurationException(getMissingRequiredConfigurationMessage(configurationKey))
132144

133145
private fun isNotSuccessfulResponse(response: HttpResponse) = response.status.value !in Constant.SUCCESSFUL_STATUS_CODES_RANGE
134146

@@ -142,7 +154,7 @@ abstract class Client(
142154

143155
abstract suspend fun throwServiceException(
144156
response: HttpResponse,
145-
operationId: String
157+
operationId: String,
146158
)
147159

148160
suspend fun performGet(url: String): HttpResponse = httpHandler.performGet(httpClient, url)
@@ -234,7 +246,12 @@ abstract class Client(
234246
*/
235247
fun requestTimeout(milliseconds: Long): SELF {
236248
this.requestTimeout = milliseconds
237-
log.info(LoggingMessageProvider.getRuntimeConfigurationProviderMessage(ConfigurationName.REQUEST_TIMEOUT_MILLIS, milliseconds.toString()))
249+
log.info(
250+
LoggingMessageProvider.getRuntimeConfigurationProviderMessage(
251+
ConfigurationName.REQUEST_TIMEOUT_MILLIS,
252+
milliseconds.toString(),
253+
),
254+
)
238255
return self()
239256
}
240257

@@ -248,7 +265,12 @@ abstract class Client(
248265
*/
249266
fun connectionTimeout(milliseconds: Long): SELF {
250267
this.connectionTimeout = milliseconds
251-
log.info(LoggingMessageProvider.getRuntimeConfigurationProviderMessage(ConfigurationName.CONNECTION_TIMEOUT_MILLIS, milliseconds.toString()))
268+
log.info(
269+
LoggingMessageProvider.getRuntimeConfigurationProviderMessage(
270+
ConfigurationName.CONNECTION_TIMEOUT_MILLIS,
271+
milliseconds.toString(),
272+
),
273+
)
252274
return self()
253275
}
254276

@@ -262,7 +284,12 @@ abstract class Client(
262284
*/
263285
fun socketTimeout(milliseconds: Long): SELF {
264286
this.socketTimeout = milliseconds
265-
log.info(LoggingMessageProvider.getRuntimeConfigurationProviderMessage(ConfigurationName.SOCKET_TIMEOUT_MILLIS, milliseconds.toString()))
287+
log.info(
288+
LoggingMessageProvider.getRuntimeConfigurationProviderMessage(
289+
ConfigurationName.SOCKET_TIMEOUT_MILLIS,
290+
milliseconds.toString(),
291+
),
292+
)
266293
return self()
267294
}
268295

@@ -274,7 +301,12 @@ abstract class Client(
274301
*/
275302
fun maskedLoggingHeaders(vararg headers: String): SELF {
276303
this.maskedLoggingHeaders = headers.toSet()
277-
log.info(LoggingMessageProvider.getRuntimeConfigurationProviderMessage(ConfigurationName.MASKED_LOGGING_HEADERS, headers.joinToString()))
304+
log.info(
305+
LoggingMessageProvider.getRuntimeConfigurationProviderMessage(
306+
ConfigurationName.MASKED_LOGGING_HEADERS,
307+
headers.joinToString(),
308+
),
309+
)
278310
return self()
279311
}
280312

@@ -286,7 +318,12 @@ abstract class Client(
286318
*/
287319
fun maskedLoggingBodyFields(vararg fields: String): SELF {
288320
this.maskedLoggingBodyFields = fields.toSet()
289-
log.info(LoggingMessageProvider.getRuntimeConfigurationProviderMessage(ConfigurationName.MASKED_LOGGING_BODY_FIELDS, fields.joinToString()))
321+
log.info(
322+
LoggingMessageProvider.getRuntimeConfigurationProviderMessage(
323+
ConfigurationName.MASKED_LOGGING_BODY_FIELDS,
324+
fields.joinToString(),
325+
),
326+
)
290327
return self()
291328
}
292329

code/src/main/kotlin/com/expediagroup/sdk/core/client/ClientHelpers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ package com.expediagroup.sdk.core.client
1717

1818
/** Handy utils and helpers for a client. */
1919
abstract class ClientHelpers(
20-
val client: Client
20+
val client: Client,
2121
)

code/src/main/kotlin/com/expediagroup/sdk/core/client/Environment.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ import io.ktor.client.request.HttpRequestBuilder
2222
import io.ktor.http.HttpHeaders
2323

2424
interface EnvironmentProvider {
25-
fun HttpRequestBuilder.appendHeaders(extraHeaders: Map<String, String> = mapOf(HeaderKey.TRANSACTION_ID to TransactionId().dequeue().toString()))
25+
fun HttpRequestBuilder.appendHeaders(
26+
extraHeaders: Map<String, String> = mapOf(HeaderKey.TRANSACTION_ID to TransactionId().dequeue().toString()),
27+
)
2628
}
2729

2830
class DefaultEnvironmentProvider(
29-
namespace: String
31+
namespace: String,
3032
) : EnvironmentProvider {
3133
private val properties = Properties.from(javaClass.classLoader.getResource("sdk.properties")!!)
3234
private val javaVersion = System.getProperty("java.version")

code/src/main/kotlin/com/expediagroup/sdk/core/client/ExpediaGroupClient.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ import io.ktor.client.engine.HttpClientEngine
3232
abstract class ExpediaGroupClient(
3333
namespace: String,
3434
clientConfiguration: ExpediaGroupClientConfiguration,
35-
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE
35+
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE,
3636
) : Client(namespace) {
3737
private val _configurationProvider: ConfigurationProvider =
3838
ConfigurationCollector.create(
3939
clientConfiguration.toProvider(),
40-
ExpediaGroupConfigurationProvider
40+
ExpediaGroupConfigurationProvider,
4141
)
42-
private val _httpClient: HttpClient = buildHttpClient(_configurationProvider, AuthenticationStrategy.AuthenticationType.BEARER, httpClientEngine)
42+
private val _httpClient: HttpClient =
43+
buildHttpClient(_configurationProvider, AuthenticationStrategy.AuthenticationType.BEARER, httpClientEngine)
4344

4445
init {
4546
finalize()

code/src/main/kotlin/com/expediagroup/sdk/core/client/HttpHandler.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ import io.ktor.http.HttpMethod
2424
internal interface HttpHandler {
2525
suspend fun performGet(
2626
httpClient: HttpClient,
27-
link: String
27+
link: String,
2828
): HttpResponse
2929
}
3030

3131
internal class DefaultHttpHandler(
32-
private val environmentProvider: EnvironmentProvider
32+
private val environmentProvider: EnvironmentProvider,
3333
) : HttpHandler, EnvironmentProvider by environmentProvider {
3434
override suspend fun performGet(
3535
httpClient: HttpClient,
36-
link: String
36+
link: String,
3737
): HttpResponse {
3838
return httpClient.request {
3939
method = HttpMethod.Get

0 commit comments

Comments
 (0)