Skip to content

Commit da3f817

Browse files
Stainless Botstainless-app[bot]
Stainless Bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API
1 parent 2d1902c commit da3f817

File tree

8 files changed

+81
-97
lines changed

8 files changed

+81
-97
lines changed

.github/workflows/create-releases.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create releases
2+
on:
3+
schedule:
4+
- cron: '0 5 * * *' # every day at 5am UTC
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
name: release
12+
if: github.ref == 'refs/heads/main' && github.repository == 'openlayer-ai/openlayer-java'
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: stainless-api/trigger-release-please@v1
19+
id: release
20+
with:
21+
repo: ${{ github.event.repository.full_name }}
22+
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}
23+
24+
- name: Set up Java
25+
if: ${{ steps.release.outputs.releases_created }}
26+
uses: actions/setup-java@v3
27+
with:
28+
distribution: temurin
29+
java-version: |
30+
8
31+
17
32+
cache: gradle
33+
34+
- name: Set up Gradle
35+
if: ${{ steps.release.outputs.releases_created }}
36+
uses: gradle/gradle-build-action@v2
37+
38+
- name: Publish to Sonatype
39+
if: ${{ steps.release.outputs.releases_created }}
40+
run: |
41+
./gradlew --parallel --no-daemon publish
42+
env:
43+
SONATYPE_USERNAME: ${{ secrets.OPENLAYER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
44+
SONATYPE_PASSWORD: ${{ secrets.OPENLAYER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
45+
GPG_SIGNING_KEY_ID: ${{ secrets.OPENLAYER_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }}
46+
GPG_SIGNING_KEY: ${{ secrets.OPENLAYER_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }}
47+
GPG_SIGNING_PASSWORD: ${{ secrets.OPENLAYER_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Handle release PR title edits
2+
on:
3+
pull_request:
4+
types:
5+
- edited
6+
- unlabeled
7+
8+
jobs:
9+
update_pr_content:
10+
name: Update pull request content
11+
if: |
12+
((github.event.action == 'edited' && github.event.changes.title.from != github.event.pull_request.title) ||
13+
(github.event.action == 'unlabeled' && github.event.label.name == 'autorelease: custom version')) &&
14+
startsWith(github.event.pull_request.head.ref, 'release-please--') &&
15+
github.event.pull_request.state == 'open' &&
16+
github.event.sender.login != 'stainless-bot' &&
17+
github.event.sender.login != 'stainless-app' &&
18+
github.repository == 'openlayer-ai/openlayer-java'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: stainless-api/trigger-release-please@v1
23+
with:
24+
repo: ${{ github.event.repository.full_name }}
25+
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}

.github/workflows/publish-sonatype.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
# This workflow is triggered when a GitHub release is created.
2-
# It can also be run manually to re-publish to Sonatype in case it failed for some reason.
3-
# You can run this workflow by navigating to https://www.github.com/openlayer-ai/openlayer-java/actions/workflows/publish-sonatype.yml
1+
# workflow for re-running publishing to Sonatype in case it fails for some reason
2+
# you can run this workflow by navigating to https://www.github.com/openlayer-ai/openlayer-java/actions/workflows/publish-sonatype.yml
43
name: Publish Sonatype
54
on:
65
workflow_dispatch:
76

8-
release:
9-
types: [published]
10-
117
jobs:
128
publish:
139
name: publish

.github/workflows/release-doctor.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
run: |
1717
bash ./bin/check-release-environment
1818
env:
19+
STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }}
1920
SONATYPE_USERNAME: ${{ secrets.OPENLAYER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
2021
SONATYPE_PASSWORD: ${{ secrets.OPENLAYER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
2122
GPG_SIGNING_KEY_ID: ${{ secrets.OPENLAYER_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }}

bin/check-release-environment

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
warnings=()
44
errors=()
55

6+
if [ -z "${STAINLESS_API_KEY}" ]; then
7+
errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.")
8+
fi
9+
610
if [ -z "${SONATYPE_USERNAME}" ]; then
711
warnings+=("The OPENLAYER_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets")
812
fi

openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCreateParams.kt

+2-24
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ constructor(
2424
private val name: String,
2525
private val taskType: TaskType,
2626
private val description: String?,
27-
private val gitRepo: GitRepo?,
2827
private val additionalQueryParams: Map<String, List<String>>,
2928
private val additionalHeaders: Map<String, List<String>>,
3029
private val additionalBodyProperties: Map<String, JsonValue>,
@@ -36,15 +35,12 @@ constructor(
3635

3736
fun description(): Optional<String> = Optional.ofNullable(description)
3837

39-
fun gitRepo(): Optional<GitRepo> = Optional.ofNullable(gitRepo)
40-
4138
@JvmSynthetic
4239
internal fun getBody(): ProjectCreateBody {
4340
return ProjectCreateBody(
4441
name,
4542
taskType,
4643
description,
47-
gitRepo,
4844
additionalBodyProperties,
4945
)
5046
}
@@ -60,7 +56,6 @@ constructor(
6056
private val name: String?,
6157
private val taskType: TaskType?,
6258
private val description: String?,
63-
private val gitRepo: GitRepo?,
6459
private val additionalProperties: Map<String, JsonValue>,
6560
) {
6661

@@ -75,8 +70,6 @@ constructor(
7570
/** The project description. */
7671
@JsonProperty("description") fun description(): String? = description
7772

78-
@JsonProperty("gitRepo") fun gitRepo(): GitRepo? = gitRepo
79-
8073
@JsonAnyGetter
8174
@ExcludeMissing
8275
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
@@ -92,7 +85,6 @@ constructor(
9285
this.name == other.name &&
9386
this.taskType == other.taskType &&
9487
this.description == other.description &&
95-
this.gitRepo == other.gitRepo &&
9688
this.additionalProperties == other.additionalProperties
9789
}
9890

@@ -103,15 +95,14 @@ constructor(
10395
name,
10496
taskType,
10597
description,
106-
gitRepo,
10798
additionalProperties,
10899
)
109100
}
110101
return hashCode
111102
}
112103

113104
override fun toString() =
114-
"ProjectCreateBody{name=$name, taskType=$taskType, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}"
105+
"ProjectCreateBody{name=$name, taskType=$taskType, description=$description, additionalProperties=$additionalProperties}"
115106

116107
companion object {
117108

@@ -123,15 +114,13 @@ constructor(
123114
private var name: String? = null
124115
private var taskType: TaskType? = null
125116
private var description: String? = null
126-
private var gitRepo: GitRepo? = null
127117
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
128118

129119
@JvmSynthetic
130120
internal fun from(projectCreateBody: ProjectCreateBody) = apply {
131121
this.name = projectCreateBody.name
132122
this.taskType = projectCreateBody.taskType
133123
this.description = projectCreateBody.description
134-
this.gitRepo = projectCreateBody.gitRepo
135124
additionalProperties(projectCreateBody.additionalProperties)
136125
}
137126

@@ -146,9 +135,6 @@ constructor(
146135
@JsonProperty("description")
147136
fun description(description: String) = apply { this.description = description }
148137

149-
@JsonProperty("gitRepo")
150-
fun gitRepo(gitRepo: GitRepo) = apply { this.gitRepo = gitRepo }
151-
152138
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
153139
this.additionalProperties.clear()
154140
this.additionalProperties.putAll(additionalProperties)
@@ -168,7 +154,6 @@ constructor(
168154
checkNotNull(name) { "`name` is required but was not set" },
169155
checkNotNull(taskType) { "`taskType` is required but was not set" },
170156
description,
171-
gitRepo,
172157
additionalProperties.toUnmodifiable(),
173158
)
174159
}
@@ -189,7 +174,6 @@ constructor(
189174
this.name == other.name &&
190175
this.taskType == other.taskType &&
191176
this.description == other.description &&
192-
this.gitRepo == other.gitRepo &&
193177
this.additionalQueryParams == other.additionalQueryParams &&
194178
this.additionalHeaders == other.additionalHeaders &&
195179
this.additionalBodyProperties == other.additionalBodyProperties
@@ -200,15 +184,14 @@ constructor(
200184
name,
201185
taskType,
202186
description,
203-
gitRepo,
204187
additionalQueryParams,
205188
additionalHeaders,
206189
additionalBodyProperties,
207190
)
208191
}
209192

210193
override fun toString() =
211-
"ProjectCreateParams{name=$name, taskType=$taskType, description=$description, gitRepo=$gitRepo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"
194+
"ProjectCreateParams{name=$name, taskType=$taskType, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"
212195

213196
fun toBuilder() = Builder().from(this)
214197

@@ -223,7 +206,6 @@ constructor(
223206
private var name: String? = null
224207
private var taskType: TaskType? = null
225208
private var description: String? = null
226-
private var gitRepo: GitRepo? = null
227209
private var additionalQueryParams: MutableMap<String, MutableList<String>> = mutableMapOf()
228210
private var additionalHeaders: MutableMap<String, MutableList<String>> = mutableMapOf()
229211
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()
@@ -233,7 +215,6 @@ constructor(
233215
this.name = projectCreateParams.name
234216
this.taskType = projectCreateParams.taskType
235217
this.description = projectCreateParams.description
236-
this.gitRepo = projectCreateParams.gitRepo
237218
additionalQueryParams(projectCreateParams.additionalQueryParams)
238219
additionalHeaders(projectCreateParams.additionalHeaders)
239220
additionalBodyProperties(projectCreateParams.additionalBodyProperties)
@@ -248,8 +229,6 @@ constructor(
248229
/** The project description. */
249230
fun description(description: String) = apply { this.description = description }
250231

251-
fun gitRepo(gitRepo: GitRepo) = apply { this.gitRepo = gitRepo }
252-
253232
fun additionalQueryParams(additionalQueryParams: Map<String, List<String>>) = apply {
254233
this.additionalQueryParams.clear()
255234
putAllQueryParams(additionalQueryParams)
@@ -309,7 +288,6 @@ constructor(
309288
checkNotNull(name) { "`name` is required but was not set" },
310289
checkNotNull(taskType) { "`taskType` is required but was not set" },
311290
description,
312-
gitRepo,
313291
additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
314292
additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
315293
additionalBodyProperties.toUnmodifiable(),

openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCreateParamsTest.kt

-50
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package com.openlayer.api.models
44

55
import com.openlayer.api.models.*
6-
import java.time.OffsetDateTime
76
import org.assertj.core.api.Assertions.assertThat
87
import org.junit.jupiter.api.Test
98

@@ -15,22 +14,6 @@ class ProjectCreateParamsTest {
1514
.name("My Project")
1615
.taskType(ProjectCreateParams.TaskType.LLM_BASE)
1716
.description("My project description.")
18-
.gitRepo(
19-
ProjectCreateParams.GitRepo.builder()
20-
.id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
21-
.dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
22-
.dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
23-
.gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
24-
.gitId(123L)
25-
.name("string")
26-
.private_(true)
27-
.projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
28-
.slug("string")
29-
.url("string")
30-
.branch("string")
31-
.rootDir("string")
32-
.build()
33-
)
3417
.build()
3518
}
3619

@@ -41,45 +24,12 @@ class ProjectCreateParamsTest {
4124
.name("My Project")
4225
.taskType(ProjectCreateParams.TaskType.LLM_BASE)
4326
.description("My project description.")
44-
.gitRepo(
45-
ProjectCreateParams.GitRepo.builder()
46-
.id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
47-
.dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
48-
.dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
49-
.gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
50-
.gitId(123L)
51-
.name("string")
52-
.private_(true)
53-
.projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
54-
.slug("string")
55-
.url("string")
56-
.branch("string")
57-
.rootDir("string")
58-
.build()
59-
)
6027
.build()
6128
val body = params.getBody()
6229
assertThat(body).isNotNull
6330
assertThat(body.name()).isEqualTo("My Project")
6431
assertThat(body.taskType()).isEqualTo(ProjectCreateParams.TaskType.LLM_BASE)
6532
assertThat(body.description()).isEqualTo("My project description.")
66-
assertThat(body.gitRepo())
67-
.isEqualTo(
68-
ProjectCreateParams.GitRepo.builder()
69-
.id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
70-
.dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
71-
.dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
72-
.gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
73-
.gitId(123L)
74-
.name("string")
75-
.private_(true)
76-
.projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
77-
.slug("string")
78-
.url("string")
79-
.branch("string")
80-
.rootDir("string")
81-
.build()
82-
)
8333
}
8434

8535
@Test

openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/ProjectServiceTest.kt

-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package com.openlayer.api.services.blocking
55
import com.openlayer.api.TestServerExtension
66
import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient
77
import com.openlayer.api.models.*
8-
import java.time.OffsetDateTime
98
import org.junit.jupiter.api.Test
109
import org.junit.jupiter.api.extension.ExtendWith
1110

@@ -26,22 +25,6 @@ class ProjectServiceTest {
2625
.name("My Project")
2726
.taskType(ProjectCreateParams.TaskType.LLM_BASE)
2827
.description("My project description.")
29-
.gitRepo(
30-
ProjectCreateParams.GitRepo.builder()
31-
.id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
32-
.dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
33-
.dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
34-
.gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
35-
.gitId(123L)
36-
.name("string")
37-
.private_(true)
38-
.projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
39-
.slug("string")
40-
.url("string")
41-
.branch("string")
42-
.rootDir("string")
43-
.build()
44-
)
4528
.build()
4629
)
4730
println(projectCreateResponse)

0 commit comments

Comments
 (0)