commonMain.com.xebia.functional.openai.generated.api.Users.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xef-openai-client-jvm Show documentation
Show all versions of xef-openai-client-jvm Show documentation
Building applications with LLMs through composability in Kotlin
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)
package com.xebia.functional.openai.generated.api
import com.xebia.functional.openai.generated.model.User
import com.xebia.functional.openai.generated.model.UserDeleteResponse
import com.xebia.functional.openai.generated.model.UserListResponse
import com.xebia.functional.openai.generated.model.UserRoleUpdateRequest
import com.xebia.functional.openai.Config
import com.xebia.functional.openai.UploadFile
import com.xebia.functional.openai.appendGen
import com.xebia.functional.openai.generated.api.Users.*
import com.xebia.functional.openai.streamEvents
import com.xebia.functional.openai.errors.serializeOrThrowWithResponseInfo
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.plugins.timeout
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.accept
import io.ktor.client.request.header
import io.ktor.client.request.forms.formData
import io.ktor.client.request.parameter
import io.ktor.client.request.prepareRequest
import io.ktor.client.request.request
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.HttpStatement
import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod
import io.ktor.http.contentType
import io.ktor.http.path
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlin.time.Duration.Companion.seconds
import kotlin.time.DurationUnit
/**
*
*/
interface Users {
/**
* Deletes a user from the organization.
*
* @param userId The ID of the user.
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return UserDeleteResponse
*/
suspend fun deleteUser(userId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): UserDeleteResponse
/**
* Lists all of the users in the organization.
*
* @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. (optional, default to 20)
* @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. (optional)
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return UserListResponse
*/
suspend fun listUsers(limit: kotlin.Int? = 20, after: kotlin.String? = null, configure: HttpRequestBuilder.() -> Unit = {}): UserListResponse
/**
* Modifies a user's role in the organization.
*
* @param userRoleUpdateRequest The new user role to modify. This must be one of `owner` or `member`.
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return User
*/
suspend fun modifyUser(userRoleUpdateRequest: UserRoleUpdateRequest, configure: HttpRequestBuilder.() -> Unit = {}): User
/**
* Retrieves a user by their identifier.
*
* @param userId The ID of the user.
* @param configure optional configuration for the request, allows overriding the default configuration.
* @return User
*/
suspend fun retrieveUser(userId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): User
}
fun Users(client: HttpClient, config: Config): com.xebia.functional.openai.generated.api.Users = object : com.xebia.functional.openai.generated.api.Users {
override suspend fun deleteUser(userId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): UserDeleteResponse =
client.request {
configure()
method = HttpMethod.Delete
contentType(ContentType.Application.Json)
url { path("organization/users/{user_id}".replace("{" + "user_id" + "}", "$userId")) }
setBody(
io.ktor.client.utils.EmptyContent
)
}.serializeOrThrowWithResponseInfo()
override suspend fun listUsers(limit: kotlin.Int?,after: kotlin.String?, configure: HttpRequestBuilder.() -> Unit): UserListResponse =
client.request {
configure()
method = HttpMethod.Get
contentType(ContentType.Application.Json)
parameter("limit", limit)
parameter("after", after)
url { path("organization/users") }
setBody(
io.ktor.client.utils.EmptyContent
)
}.serializeOrThrowWithResponseInfo()
override suspend fun modifyUser(userRoleUpdateRequest: UserRoleUpdateRequest, configure: HttpRequestBuilder.() -> Unit): User =
client.request {
configure()
method = HttpMethod.Post
contentType(ContentType.Application.Json)
url { path("organization/users/{user_id}") }
setBody(userRoleUpdateRequest
)
}.serializeOrThrowWithResponseInfo()
override suspend fun retrieveUser(userId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): User =
client.request {
configure()
method = HttpMethod.Get
contentType(ContentType.Application.Json)
url { path("organization/users/{user_id}".replace("{" + "user_id" + "}", "$userId")) }
setBody(
io.ktor.client.utils.EmptyContent
)
}.serializeOrThrowWithResponseInfo()
}