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

chore(internal): codegen related update #18

Merged
merged 1 commit into from
Jul 22, 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
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 9
configured_endpoints: 10
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ interface OpenlayerClient {
fun commits(): CommitService

fun inferencePipelines(): InferencePipelineService

fun storage(): StorageService
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ interface OpenlayerClientAsync {
fun commits(): CommitServiceAsync

fun inferencePipelines(): InferencePipelineServiceAsync

fun storage(): StorageServiceAsync
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ constructor(
InferencePipelineServiceAsyncImpl(clientOptions)
}

private val storage: StorageServiceAsync by lazy { StorageServiceAsyncImpl(clientOptions) }

override fun sync(): OpenlayerClient = sync

override fun projects(): ProjectServiceAsync = projects

override fun commits(): CommitServiceAsync = commits

override fun inferencePipelines(): InferencePipelineServiceAsync = inferencePipelines

override fun storage(): StorageServiceAsync = storage
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ constructor(
InferencePipelineServiceImpl(clientOptions)
}

private val storage: StorageService by lazy { StorageServiceImpl(clientOptions) }

override fun async(): OpenlayerClientAsync = async

override fun projects(): ProjectService = projects

override fun commits(): CommitService = commits

override fun inferencePipelines(): InferencePipelineService = inferencePipelines

override fun storage(): StorageService = storage
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// File generated from our OpenAPI spec by Stainless.

package com.openlayer.api.models

import com.openlayer.api.core.JsonValue
import com.openlayer.api.core.NoAutoDetect
import com.openlayer.api.core.toUnmodifiable
import com.openlayer.api.models.*
import java.util.Objects
import java.util.Optional

class StoragePresignedUrlCreateParams
constructor(
private val objectName: String,
private val additionalQueryParams: Map<String, List<String>>,
private val additionalHeaders: Map<String, List<String>>,
private val additionalBodyProperties: Map<String, JsonValue>,
) {

fun objectName(): String = objectName

@JvmSynthetic
internal fun getBody(): Optional<Map<String, JsonValue>> {
return Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
}

@JvmSynthetic
internal fun getQueryParams(): Map<String, List<String>> {
val params = mutableMapOf<String, List<String>>()
this.objectName.let { params.put("objectName", listOf(it.toString())) }
params.putAll(additionalQueryParams)
return params.toUnmodifiable()
}

@JvmSynthetic internal fun getHeaders(): Map<String, List<String>> = additionalHeaders

fun _additionalQueryParams(): Map<String, List<String>> = additionalQueryParams

fun _additionalHeaders(): Map<String, List<String>> = additionalHeaders

fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return other is StoragePresignedUrlCreateParams &&
this.objectName == other.objectName &&
this.additionalQueryParams == other.additionalQueryParams &&
this.additionalHeaders == other.additionalHeaders &&
this.additionalBodyProperties == other.additionalBodyProperties
}

override fun hashCode(): Int {
return Objects.hash(
objectName,
additionalQueryParams,
additionalHeaders,
additionalBodyProperties,
)
}

override fun toString() =
"StoragePresignedUrlCreateParams{objectName=$objectName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"

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

companion object {

@JvmStatic fun builder() = Builder()
}

@NoAutoDetect
class Builder {

private var objectName: String? = null
private var additionalQueryParams: MutableMap<String, MutableList<String>> = mutableMapOf()
private var additionalHeaders: MutableMap<String, MutableList<String>> = mutableMapOf()
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(storagePresignedUrlCreateParams: StoragePresignedUrlCreateParams) =
apply {
this.objectName = storagePresignedUrlCreateParams.objectName
additionalQueryParams(storagePresignedUrlCreateParams.additionalQueryParams)
additionalHeaders(storagePresignedUrlCreateParams.additionalHeaders)
additionalBodyProperties(storagePresignedUrlCreateParams.additionalBodyProperties)
}

/** The name of the object. */
fun objectName(objectName: String) = apply { this.objectName = objectName }

fun additionalQueryParams(additionalQueryParams: Map<String, List<String>>) = apply {
this.additionalQueryParams.clear()
putAllQueryParams(additionalQueryParams)
}

fun putQueryParam(name: String, value: String) = apply {
this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value)
}

fun putQueryParams(name: String, values: Iterable<String>) = apply {
this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values)
}

fun putAllQueryParams(additionalQueryParams: Map<String, Iterable<String>>) = apply {
additionalQueryParams.forEach(this::putQueryParams)
}

fun removeQueryParam(name: String) = apply {
this.additionalQueryParams.put(name, mutableListOf())
}

fun additionalHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply {
this.additionalHeaders.clear()
putAllHeaders(additionalHeaders)
}

fun putHeader(name: String, value: String) = apply {
this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value)
}

fun putHeaders(name: String, values: Iterable<String>) = apply {
this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values)
}

fun putAllHeaders(additionalHeaders: Map<String, Iterable<String>>) = apply {
additionalHeaders.forEach(this::putHeaders)
}

fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) }

fun additionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) = apply {
this.additionalBodyProperties.clear()
this.additionalBodyProperties.putAll(additionalBodyProperties)
}

fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
this.additionalBodyProperties.put(key, value)
}

fun putAllAdditionalBodyProperties(additionalBodyProperties: Map<String, JsonValue>) =
apply {
this.additionalBodyProperties.putAll(additionalBodyProperties)
}

fun build(): StoragePresignedUrlCreateParams =
StoragePresignedUrlCreateParams(
checkNotNull(objectName) { "`objectName` is required but was not set" },
additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
additionalBodyProperties.toUnmodifiable(),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// File generated from our OpenAPI spec by Stainless.

package com.openlayer.api.models

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.openlayer.api.core.ExcludeMissing
import com.openlayer.api.core.JsonField
import com.openlayer.api.core.JsonMissing
import com.openlayer.api.core.JsonValue
import com.openlayer.api.core.NoAutoDetect
import com.openlayer.api.core.toUnmodifiable
import java.util.Objects

@JsonDeserialize(builder = StoragePresignedUrlCreateResponse.Builder::class)
@NoAutoDetect
class StoragePresignedUrlCreateResponse
private constructor(
private val url: JsonField<String>,
private val fields: JsonValue,
private val storageUri: JsonField<String>,
private val additionalProperties: Map<String, JsonValue>,
) {

private var validated: Boolean = false

private var hashCode: Int = 0

/** The presigned url. */
fun url(): String = url.getRequired("url")

/** The storage URI to send back to the backend after the upload was completed. */
fun storageUri(): String = storageUri.getRequired("storageUri")

/** The presigned url. */
@JsonProperty("url") @ExcludeMissing fun _url() = url

/** Fields to include in the body of the upload. Only needed by s3. */
@JsonProperty("fields") @ExcludeMissing fun _fields() = fields

/** The storage URI to send back to the backend after the upload was completed. */
@JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties

fun validate(): StoragePresignedUrlCreateResponse = apply {
if (!validated) {
url()
storageUri()
validated = true
}
}

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

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return other is StoragePresignedUrlCreateResponse &&
this.url == other.url &&
this.fields == other.fields &&
this.storageUri == other.storageUri &&
this.additionalProperties == other.additionalProperties
}

override fun hashCode(): Int {
if (hashCode == 0) {
hashCode =
Objects.hash(
url,
fields,
storageUri,
additionalProperties,
)
}
return hashCode
}

override fun toString() =
"StoragePresignedUrlCreateResponse{url=$url, fields=$fields, storageUri=$storageUri, additionalProperties=$additionalProperties}"

companion object {

@JvmStatic fun builder() = Builder()
}

class Builder {

private var url: JsonField<String> = JsonMissing.of()
private var fields: JsonValue = JsonMissing.of()
private var storageUri: JsonField<String> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(storagePresignedUrlCreateResponse: StoragePresignedUrlCreateResponse) =
apply {
this.url = storagePresignedUrlCreateResponse.url
this.fields = storagePresignedUrlCreateResponse.fields
this.storageUri = storagePresignedUrlCreateResponse.storageUri
additionalProperties(storagePresignedUrlCreateResponse.additionalProperties)
}

/** The presigned url. */
fun url(url: String) = url(JsonField.of(url))

/** The presigned url. */
@JsonProperty("url")
@ExcludeMissing
fun url(url: JsonField<String>) = apply { this.url = url }

/** Fields to include in the body of the upload. Only needed by s3. */
@JsonProperty("fields")
@ExcludeMissing
fun fields(fields: JsonValue) = apply { this.fields = fields }

/** The storage URI to send back to the backend after the upload was completed. */
fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri))

/** The storage URI to send back to the backend after the upload was completed. */
@JsonProperty("storageUri")
@ExcludeMissing
fun storageUri(storageUri: JsonField<String>) = apply { this.storageUri = storageUri }

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
this.additionalProperties.putAll(additionalProperties)
}

@JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}

fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.putAll(additionalProperties)
}

fun build(): StoragePresignedUrlCreateResponse =
StoragePresignedUrlCreateResponse(
url,
fields,
storageUri,
additionalProperties.toUnmodifiable(),
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// File generated from our OpenAPI spec by Stainless.

@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102

package com.openlayer.api.services.async

import com.openlayer.api.services.async.storage.PresignedUrlServiceAsync

interface StorageServiceAsync {

fun presignedUrl(): PresignedUrlServiceAsync
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// File generated from our OpenAPI spec by Stainless.

package com.openlayer.api.services.async

import com.openlayer.api.core.ClientOptions
import com.openlayer.api.core.http.HttpResponse.Handler
import com.openlayer.api.errors.OpenlayerError
import com.openlayer.api.services.async.storage.PresignedUrlServiceAsync
import com.openlayer.api.services.async.storage.PresignedUrlServiceAsyncImpl
import com.openlayer.api.services.errorHandler

class StorageServiceAsyncImpl
constructor(
private val clientOptions: ClientOptions,
) : StorageServiceAsync {

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

private val presignedUrl: PresignedUrlServiceAsync by lazy {
PresignedUrlServiceAsyncImpl(clientOptions)
}

override fun presignedUrl(): PresignedUrlServiceAsync = presignedUrl
}
Loading