Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #15

Merged
merged 1 commit into from
Jul 17, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.openlayer.api.models.*
import java.util.Objects
import java.util.Optional

class InferencePipelineRowStreamParams
class InferencePipelineRowUpdateParams
constructor(
private val inferencePipelineId: String,
private val inferenceId: String,
Expand All @@ -34,8 +34,8 @@ constructor(
fun config(): Optional<Config> = Optional.ofNullable(config)

@JvmSynthetic
internal fun getBody(): InferencePipelineRowStreamBody {
return InferencePipelineRowStreamBody(
internal fun getBody(): InferencePipelineRowUpdateBody {
return InferencePipelineRowUpdateBody(
row,
config,
additionalBodyProperties,
Expand All @@ -59,9 +59,9 @@ constructor(
}
}

@JsonDeserialize(builder = InferencePipelineRowStreamBody.Builder::class)
@JsonDeserialize(builder = InferencePipelineRowUpdateBody.Builder::class)
@NoAutoDetect
class InferencePipelineRowStreamBody
class InferencePipelineRowUpdateBody
internal constructor(
private val row: JsonValue?,
private val config: Config?,
Expand All @@ -85,7 +85,7 @@ constructor(
return true
}

return other is InferencePipelineRowStreamBody &&
return other is InferencePipelineRowUpdateBody &&
this.row == other.row &&
this.config == other.config &&
this.additionalProperties == other.additionalProperties
Expand All @@ -104,7 +104,7 @@ constructor(
}

override fun toString() =
"InferencePipelineRowStreamBody{row=$row, config=$config, additionalProperties=$additionalProperties}"
"InferencePipelineRowUpdateBody{row=$row, config=$config, additionalProperties=$additionalProperties}"

companion object {

Expand All @@ -118,11 +118,11 @@ constructor(
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(inferencePipelineRowStreamBody: InferencePipelineRowStreamBody) =
internal fun from(inferencePipelineRowUpdateBody: InferencePipelineRowUpdateBody) =
apply {
this.row = inferencePipelineRowStreamBody.row
this.config = inferencePipelineRowStreamBody.config
additionalProperties(inferencePipelineRowStreamBody.additionalProperties)
this.row = inferencePipelineRowUpdateBody.row
this.config = inferencePipelineRowUpdateBody.config
additionalProperties(inferencePipelineRowUpdateBody.additionalProperties)
}

@JsonProperty("row") fun row(row: JsonValue) = apply { this.row = row }
Expand All @@ -143,8 +143,8 @@ constructor(
this.additionalProperties.putAll(additionalProperties)
}

fun build(): InferencePipelineRowStreamBody =
InferencePipelineRowStreamBody(
fun build(): InferencePipelineRowUpdateBody =
InferencePipelineRowUpdateBody(
checkNotNull(row) { "`row` is required but was not set" },
config,
additionalProperties.toUnmodifiable(),
Expand All @@ -163,7 +163,7 @@ constructor(
return true
}

return other is InferencePipelineRowStreamParams &&
return other is InferencePipelineRowUpdateParams &&
this.inferencePipelineId == other.inferencePipelineId &&
this.row == other.row &&
this.config == other.config &&
Expand All @@ -186,7 +186,7 @@ constructor(
}

override fun toString() =
"InferencePipelineRowStreamParams{inferencePipelineId=$inferencePipelineId, row=$row, config=$config, inferenceId=$inferenceId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"
"InferencePipelineRowUpdateParams{inferencePipelineId=$inferencePipelineId, row=$row, config=$config, inferenceId=$inferenceId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"

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

Expand All @@ -207,15 +207,15 @@ constructor(
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(inferencePipelineRowStreamParams: InferencePipelineRowStreamParams) =
internal fun from(inferencePipelineRowUpdateParams: InferencePipelineRowUpdateParams) =
apply {
this.inferencePipelineId = inferencePipelineRowStreamParams.inferencePipelineId
this.inferenceId = inferencePipelineRowStreamParams.inferenceId
this.row = inferencePipelineRowStreamParams.row
this.config = inferencePipelineRowStreamParams.config
additionalQueryParams(inferencePipelineRowStreamParams.additionalQueryParams)
additionalHeaders(inferencePipelineRowStreamParams.additionalHeaders)
additionalBodyProperties(inferencePipelineRowStreamParams.additionalBodyProperties)
this.inferencePipelineId = inferencePipelineRowUpdateParams.inferencePipelineId
this.inferenceId = inferencePipelineRowUpdateParams.inferenceId
this.row = inferencePipelineRowUpdateParams.row
this.config = inferencePipelineRowUpdateParams.config
additionalQueryParams(inferencePipelineRowUpdateParams.additionalQueryParams)
additionalHeaders(inferencePipelineRowUpdateParams.additionalHeaders)
additionalBodyProperties(inferencePipelineRowUpdateParams.additionalBodyProperties)
}

fun inferencePipelineId(inferencePipelineId: String) = apply {
Expand Down Expand Up @@ -283,8 +283,8 @@ constructor(
this.additionalBodyProperties.putAll(additionalBodyProperties)
}

fun build(): InferencePipelineRowStreamParams =
InferencePipelineRowStreamParams(
fun build(): InferencePipelineRowUpdateParams =
InferencePipelineRowUpdateParams(
checkNotNull(inferencePipelineId) {
"`inferencePipelineId` is required but was not set"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import com.openlayer.api.core.toUnmodifiable
import com.openlayer.api.errors.OpenlayerInvalidDataException
import java.util.Objects

@JsonDeserialize(builder = InferencePipelineRowStreamResponse.Builder::class)
@JsonDeserialize(builder = InferencePipelineRowUpdateResponse.Builder::class)
@NoAutoDetect
class InferencePipelineRowStreamResponse
class InferencePipelineRowUpdateResponse
private constructor(
private val success: JsonField<Success>,
private val additionalProperties: Map<String, JsonValue>,
Expand All @@ -37,7 +37,7 @@ private constructor(
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

fun validate(): InferencePipelineRowStreamResponse = apply {
fun validate(): InferencePipelineRowUpdateResponse = apply {
if (!validated) {
success()
validated = true
Expand All @@ -51,7 +51,7 @@ private constructor(
return true
}

return other is InferencePipelineRowStreamResponse &&
return other is InferencePipelineRowUpdateResponse &&
this.success == other.success &&
this.additionalProperties == other.additionalProperties
}
Expand All @@ -64,7 +64,7 @@ private constructor(
}

override fun toString() =
"InferencePipelineRowStreamResponse{success=$success, additionalProperties=$additionalProperties}"
"InferencePipelineRowUpdateResponse{success=$success, additionalProperties=$additionalProperties}"

companion object {

Expand All @@ -77,10 +77,10 @@ private constructor(
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(inferencePipelineRowStreamResponse: InferencePipelineRowStreamResponse) =
internal fun from(inferencePipelineRowUpdateResponse: InferencePipelineRowUpdateResponse) =
apply {
this.success = inferencePipelineRowStreamResponse.success
additionalProperties(inferencePipelineRowStreamResponse.additionalProperties)
this.success = inferencePipelineRowUpdateResponse.success
additionalProperties(inferencePipelineRowUpdateResponse.additionalProperties)
}

fun success(success: Success) = success(JsonField.of(success))
Expand All @@ -103,8 +103,8 @@ private constructor(
this.additionalProperties.putAll(additionalProperties)
}

fun build(): InferencePipelineRowStreamResponse =
InferencePipelineRowStreamResponse(success, additionalProperties.toUnmodifiable())
fun build(): InferencePipelineRowUpdateResponse =
InferencePipelineRowUpdateResponse(success, additionalProperties.toUnmodifiable())
}

class Success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
package com.openlayer.api.services.async.inferencePipelines

import com.openlayer.api.core.RequestOptions
import com.openlayer.api.models.InferencePipelineRowStreamParams
import com.openlayer.api.models.InferencePipelineRowStreamResponse
import com.openlayer.api.models.InferencePipelineRowUpdateParams
import com.openlayer.api.models.InferencePipelineRowUpdateResponse
import java.util.concurrent.CompletableFuture

interface RowServiceAsync {

/** Update an inference data point in an inference pipeline. */
@JvmOverloads
fun stream(
params: InferencePipelineRowStreamParams,
fun update(
params: InferencePipelineRowUpdateParams,
requestOptions: RequestOptions = RequestOptions.none()
): CompletableFuture<InferencePipelineRowStreamResponse>
): CompletableFuture<InferencePipelineRowUpdateResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import com.openlayer.api.core.http.HttpMethod
import com.openlayer.api.core.http.HttpRequest
import com.openlayer.api.core.http.HttpResponse.Handler
import com.openlayer.api.errors.OpenlayerError
import com.openlayer.api.models.InferencePipelineRowStreamParams
import com.openlayer.api.models.InferencePipelineRowStreamResponse
import com.openlayer.api.models.InferencePipelineRowUpdateParams
import com.openlayer.api.models.InferencePipelineRowUpdateResponse
import com.openlayer.api.services.errorHandler
import com.openlayer.api.services.json
import com.openlayer.api.services.jsonHandler
Expand All @@ -23,15 +23,15 @@ constructor(

private val errorHandler: Handler<OpenlayerError> = errorHandler(clientOptions.jsonMapper)

private val streamHandler: Handler<InferencePipelineRowStreamResponse> =
jsonHandler<InferencePipelineRowStreamResponse>(clientOptions.jsonMapper)
private val updateHandler: Handler<InferencePipelineRowUpdateResponse> =
jsonHandler<InferencePipelineRowUpdateResponse>(clientOptions.jsonMapper)
.withErrorHandler(errorHandler)

/** Update an inference data point in an inference pipeline. */
override fun stream(
params: InferencePipelineRowStreamParams,
override fun update(
params: InferencePipelineRowUpdateParams,
requestOptions: RequestOptions
): CompletableFuture<InferencePipelineRowStreamResponse> {
): CompletableFuture<InferencePipelineRowUpdateResponse> {
val request =
HttpRequest.builder()
.method(HttpMethod.PUT)
Expand All @@ -45,7 +45,7 @@ constructor(
return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response
->
response
.use { streamHandler.handle(it) }
.use { updateHandler.handle(it) }
.apply {
if (requestOptions.responseValidation ?: clientOptions.responseValidation) {
validate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
package com.openlayer.api.services.blocking.inferencePipelines

import com.openlayer.api.core.RequestOptions
import com.openlayer.api.models.InferencePipelineRowStreamParams
import com.openlayer.api.models.InferencePipelineRowStreamResponse
import com.openlayer.api.models.InferencePipelineRowUpdateParams
import com.openlayer.api.models.InferencePipelineRowUpdateResponse

interface RowService {

/** Update an inference data point in an inference pipeline. */
@JvmOverloads
fun stream(
params: InferencePipelineRowStreamParams,
fun update(
params: InferencePipelineRowUpdateParams,
requestOptions: RequestOptions = RequestOptions.none()
): InferencePipelineRowStreamResponse
): InferencePipelineRowUpdateResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import com.openlayer.api.core.http.HttpMethod
import com.openlayer.api.core.http.HttpRequest
import com.openlayer.api.core.http.HttpResponse.Handler
import com.openlayer.api.errors.OpenlayerError
import com.openlayer.api.models.InferencePipelineRowStreamParams
import com.openlayer.api.models.InferencePipelineRowStreamResponse
import com.openlayer.api.models.InferencePipelineRowUpdateParams
import com.openlayer.api.models.InferencePipelineRowUpdateResponse
import com.openlayer.api.services.errorHandler
import com.openlayer.api.services.json
import com.openlayer.api.services.jsonHandler
Expand All @@ -22,15 +22,15 @@ constructor(

private val errorHandler: Handler<OpenlayerError> = errorHandler(clientOptions.jsonMapper)

private val streamHandler: Handler<InferencePipelineRowStreamResponse> =
jsonHandler<InferencePipelineRowStreamResponse>(clientOptions.jsonMapper)
private val updateHandler: Handler<InferencePipelineRowUpdateResponse> =
jsonHandler<InferencePipelineRowUpdateResponse>(clientOptions.jsonMapper)
.withErrorHandler(errorHandler)

/** Update an inference data point in an inference pipeline. */
override fun stream(
params: InferencePipelineRowStreamParams,
override fun update(
params: InferencePipelineRowUpdateParams,
requestOptions: RequestOptions
): InferencePipelineRowStreamResponse {
): InferencePipelineRowUpdateResponse {
val request =
HttpRequest.builder()
.method(HttpMethod.PUT)
Expand All @@ -43,7 +43,7 @@ constructor(
.build()
return clientOptions.httpClient.execute(request, requestOptions).let { response ->
response
.use { streamHandler.handle(it) }
.use { updateHandler.handle(it) }
.apply {
if (requestOptions.responseValidation ?: clientOptions.responseValidation) {
validate()
Expand Down

This file was deleted.

Loading