Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/publish-sonatype.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to Sonatype in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/OmniStack-sh/omnistack-kotlin/actions/workflows/publish-sonatype.yml
name: Publish Sonatype
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: |
8
17
cache: gradle

- name: Set up Gradle
uses: gradle/gradle-build-action@v2

- name: Publish to Sonatype
run: |
./gradlew --parallel --no-daemon publish
env:
SONATYPE_USERNAME: ${{ secrets.OMNISTACK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.OMNISTACK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
GPG_SIGNING_KEY_ID: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }}
GPG_SIGNING_KEY: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_PASSWORD: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }}
25 changes: 25 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'OmniStack-sh/omnistack-kotlin' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v4

- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
SONATYPE_USERNAME: ${{ secrets.OMNISTACK_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.OMNISTACK_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
GPG_SIGNING_KEY_ID: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }}
GPG_SIGNING_KEY: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_PASSWORD: ${{ secrets.OMNISTACK_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0-alpha.1"
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

## 0.1.0-alpha.1 (2024-11-12)

Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/OmniStack-sh/omnistack-kotlin/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)

### Features

* **api:** api update ([60c35dc](https://github.com/OmniStack-sh/omnistack-kotlin/commit/60c35dcb8e1f6cbf7535d086678752e086d843b5))
* **api:** api update ([#1](https://github.com/OmniStack-sh/omnistack-kotlin/issues/1)) ([3df1f83](https://github.com/OmniStack-sh/omnistack-kotlin/commit/3df1f836b96e209484104a2722f6ee47d5f28686))


### Chores

* rebuild project due to codegen change ([#10](https://github.com/OmniStack-sh/omnistack-kotlin/issues/10)) ([fa93e56](https://github.com/OmniStack-sh/omnistack-kotlin/commit/fa93e56380e178d78c59907f58634aa6b05d57d9))
* rebuild project due to codegen change ([#3](https://github.com/OmniStack-sh/omnistack-kotlin/issues/3)) ([aa6fca3](https://github.com/OmniStack-sh/omnistack-kotlin/commit/aa6fca3c9f263f10db2919c13ce7fb009b7a9687))
* rebuild project due to codegen change ([#4](https://github.com/OmniStack-sh/omnistack-kotlin/issues/4)) ([c60d81b](https://github.com/OmniStack-sh/omnistack-kotlin/commit/c60d81b1c42f8b05166ae0cc92c33709ac6563c8))
* rebuild project due to codegen change ([#5](https://github.com/OmniStack-sh/omnistack-kotlin/issues/5)) ([265f2f1](https://github.com/OmniStack-sh/omnistack-kotlin/commit/265f2f14899c5c2a4a41e67dd3cf5a287eff5661))
* rebuild project due to codegen change ([#6](https://github.com/OmniStack-sh/omnistack-kotlin/issues/6)) ([d36ecb0](https://github.com/OmniStack-sh/omnistack-kotlin/commit/d36ecb0ebc4ab5642a3075e546cd9d725f05e4dc))
* rebuild project due to codegen change ([#7](https://github.com/OmniStack-sh/omnistack-kotlin/issues/7)) ([440588a](https://github.com/OmniStack-sh/omnistack-kotlin/commit/440588a390cdab04358b59a54a4bc6a9d1a8a7a4))
* rebuild project due to codegen change ([#8](https://github.com/OmniStack-sh/omnistack-kotlin/issues/8)) ([3f862cb](https://github.com/OmniStack-sh/omnistack-kotlin/commit/3f862cbf289344d7d624d98f364ac079ccf81a79))
* rebuild project due to codegen change ([#9](https://github.com/OmniStack-sh/omnistack-kotlin/issues/9)) ([1d0d7aa](https://github.com/OmniStack-sh/omnistack-kotlin/commit/1d0d7aa95fa103c409dfaf0bc935b0bd22948cf9))
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ The REST API documentation can be found on [docs.omnistack.sh](https://docs.omn

#### Gradle

<!-- x-release-please-start-version -->

```kotlin
implementation("com.omnistack.api:omnistack-kotlin:0.0.1-alpha.0")
implementation("com.omnistack.api:omnistack-kotlin:0.1.0-alpha.1")
```

#### Maven
Expand All @@ -28,10 +30,12 @@ implementation("com.omnistack.api:omnistack-kotlin:0.0.1-alpha.0")
<dependency>
<groupId>com.omnistack.api</groupId>
<artifactId>omnistack-kotlin</artifactId>
<version>0.0.1-alpha.0</version>
<version>0.1.0-alpha.1</version>
</dependency>
```

<!-- x-release-please-end -->

### Configure the client

Use `OmnistackOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`:
Expand Down Expand Up @@ -75,7 +79,7 @@ import com.omnistack.api.models.CompletionCreateParams
import com.omnistack.api.models.CompletionCreateResponse

val params = CompletionCreateParams.builder()
.model(CompletionCreateParams.Model.ofString("string"))
.model("string")
.prompt(CompletionCreateParams.Prompt.ofString("This is a test."))
.build()
val completion = client.completions().create(params)
Expand Down Expand Up @@ -218,7 +222,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/omnistack-kotlin/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/OmniStack-sh/omnistack-kotlin/issues) with questions, bugs, or suggestions.

## Requirements

Expand Down
33 changes: 33 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

errors=()

if [ -z "${SONATYPE_USERNAME}" ]; then
errors+=("The OMNISTACK_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

if [ -z "${SONATYPE_PASSWORD}" ]; then
errors+=("The OMNISTACK_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

if [ -z "${GPG_SIGNING_KEY}" ]; then
errors+=("The OMNISTACK_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

if [ -z "${GPG_SIGNING_PASSWORD}" ]; then
errors+=("The OMNISTACK_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
echo -e "Found the following errors in the release environment:\n"

for error in "${errors[@]}"; do
echo -e "- $error\n"
done

exit 1
fi

echo "The environment is ready to push releases!"
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

allprojects {
group = "com.omnistack.api"
version = "0.0.1-alpha.0"
version = "0.1.0-alpha.1" // x-release-please-version
}

nexusPublishing {
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/omnistack.publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ configure<PublishingExtension> {
}

scm {
connection.set("scm:git:git://github.com/stainless-sdks/omnistack-kotlin.git")
developerConnection.set("scm:git:git://github.com/stainless-sdks/omnistack-kotlin.git")
url.set("https://github.com/stainless-sdks/omnistack-kotlin")
connection.set("scm:git:git://github.com/OmniStack-sh/omnistack-kotlin.git")
developerConnection.set("scm:git:git://github.com/OmniStack-sh/omnistack-kotlin.git")
url.set("https://github.com/OmniStack-sh/omnistack-kotlin")
}

versionMapping {
Expand Down
2 changes: 0 additions & 2 deletions omnistack-kotlin-client-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ plugins {
dependencies {
api(project(":omnistack-kotlin-core"))

implementation("com.google.guava:guava:33.0.0-jre")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")

testImplementation(kotlin("test"))
testImplementation("org.assertj:assertj-core:3.25.3")
testImplementation("org.slf4j:slf4j-simple:2.0.12")
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.omnistack.api.client.okhttp

import com.google.common.collect.ListMultimap
import com.google.common.collect.MultimapBuilder
import com.omnistack.api.core.RequestOptions
import com.omnistack.api.core.http.Headers
import com.omnistack.api.core.http.HttpClient
import com.omnistack.api.core.http.HttpMethod
import com.omnistack.api.core.http.HttpRequest
Expand All @@ -16,7 +15,6 @@ import java.time.Duration
import kotlinx.coroutines.suspendCancellableCoroutine
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Headers
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
Expand Down Expand Up @@ -80,13 +78,15 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

private fun HttpRequest.toRequest(): Request {
var body: RequestBody? = body?.toRequestBody()
// OkHttpClient always requires a request body for PUT and POST methods
// OkHttpClient always requires a request body for PUT and POST methods.
if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) {
body = "".toRequestBody()
}

val builder = Request.Builder().url(toUrl()).method(method.name, body)
headers.forEach(builder::header)
headers.names().forEach { name ->
headers.values(name).forEach { builder.header(name, it) }
}

return builder.build()
}
Expand All @@ -98,7 +98,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

val builder = baseUrl.newBuilder()
pathSegments.forEach(builder::addPathSegment)
queryParams.forEach(builder::addQueryParameter)
queryParams.keys().forEach { key ->
queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
}

return builder.toString()
}
Expand All @@ -108,55 +110,34 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
val length = contentLength()

return object : RequestBody() {
override fun contentType(): MediaType? {
return mediaType
}
override fun contentType(): MediaType? = mediaType

override fun contentLength(): Long {
return length
}
override fun contentLength(): Long = length

override fun isOneShot(): Boolean {
return !repeatable()
}
override fun isOneShot(): Boolean = !repeatable()

override fun writeTo(sink: BufferedSink) {
writeTo(sink.outputStream())
}
override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream())
}
}

private fun Response.toResponse(): HttpResponse {
val headers = headers.toHeaders()

return object : HttpResponse {
override fun statusCode(): Int {
return code
}
override fun statusCode(): Int = code

override fun headers(): ListMultimap<String, String> {
return headers
}
override fun headers(): Headers = headers

override fun body(): InputStream {
return body!!.byteStream()
}
override fun body(): InputStream = body!!.byteStream()

override fun close() {
body!!.close()
}
override fun close() = body!!.close()
}
}

private fun Headers.toHeaders(): ListMultimap<String, String> {
val headers =
MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER)
.arrayListValues()
.build<String, String>()

forEach { pair -> headers.put(pair.first, pair.second) }

return headers
private fun okhttp3.Headers.toHeaders(): Headers {
val headersBuilder = Headers.builder()
forEach { (name, value) -> headersBuilder.put(name, value) }
return headersBuilder.build()
}

companion object {
Expand All @@ -166,7 +147,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
class Builder {

private var baseUrl: HttpUrl? = null
// default timeout is 1 minute
// The default timeout is 1 minute.
private var timeout: Duration = Duration.ofSeconds(60)
private var proxy: Proxy? = null

Expand All @@ -176,8 +157,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }

fun build(): OkHttpClient {
return OkHttpClient(
fun build(): OkHttpClient =
OkHttpClient(
okhttp3.OkHttpClient.Builder()
.connectTimeout(timeout)
.readTimeout(timeout)
Expand All @@ -187,7 +168,6 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
.build(),
checkNotNull(baseUrl) { "`baseUrl` is required but was not set" },
)
}
}

private suspend fun Call.executeAsync(): Response =
Expand Down
Loading
Loading