All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.xebia.functional.openai.generated.api.Projects.kt Maven / Gradle / Ivy

The newest version!
/**
 *
 * 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.ErrorResponse
import com.xebia.functional.openai.generated.model.Project
import com.xebia.functional.openai.generated.model.ProjectApiKey
import com.xebia.functional.openai.generated.model.ProjectApiKeyDeleteResponse
import com.xebia.functional.openai.generated.model.ProjectApiKeyListResponse
import com.xebia.functional.openai.generated.model.ProjectCreateRequest
import com.xebia.functional.openai.generated.model.ProjectListResponse
import com.xebia.functional.openai.generated.model.ProjectServiceAccount
import com.xebia.functional.openai.generated.model.ProjectServiceAccountCreateRequest
import com.xebia.functional.openai.generated.model.ProjectServiceAccountCreateResponse
import com.xebia.functional.openai.generated.model.ProjectServiceAccountDeleteResponse
import com.xebia.functional.openai.generated.model.ProjectServiceAccountListResponse
import com.xebia.functional.openai.generated.model.ProjectUpdateRequest
import com.xebia.functional.openai.generated.model.ProjectUser
import com.xebia.functional.openai.generated.model.ProjectUserCreateRequest
import com.xebia.functional.openai.generated.model.ProjectUserDeleteResponse
import com.xebia.functional.openai.generated.model.ProjectUserListResponse
import com.xebia.functional.openai.generated.model.ProjectUserUpdateRequest
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.Projects.*
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 Projects {

    /**
    * Archives a project in the organization. Archived projects cannot be used or updated.
    * 
     * @param projectId The ID of the project.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return Project
    */
    suspend fun archiveProject(projectId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): Project


    /**
    * Create a new project in the organization. Projects can be created and archived, but cannot be deleted.
    * 
     * @param projectCreateRequest The project create request payload.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return Project
    */
    suspend fun createProject(projectCreateRequest: ProjectCreateRequest, configure: HttpRequestBuilder.() -> Unit = {}): Project


    /**
    * Creates a new service account in the project. This also returns an unredacted API key for the service account.
    * 
     * @param projectId The ID of the project.
     * @param projectServiceAccountCreateRequest The project service account create request payload.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectServiceAccountCreateResponse
    */
    suspend fun createProjectServiceAccount(projectId: kotlin.String, projectServiceAccountCreateRequest: ProjectServiceAccountCreateRequest, configure: HttpRequestBuilder.() -> Unit = {}): ProjectServiceAccountCreateResponse


    /**
    * Adds a user to the project. Users must already be members of the organization to be added to a project.
    * 
     * @param projectId The ID of the project.
     * @param projectUserCreateRequest The project user create request payload.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectUser
    */
    suspend fun createProjectUser(projectId: kotlin.String, projectUserCreateRequest: ProjectUserCreateRequest, configure: HttpRequestBuilder.() -> Unit = {}): ProjectUser


    /**
    * Deletes an API key from the project.
    * 
     * @param projectId The ID of the project.
     * @param keyId The ID of the API key.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectApiKeyDeleteResponse
    */
    suspend fun deleteProjectApiKey(projectId: kotlin.String, keyId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): ProjectApiKeyDeleteResponse


    /**
    * Deletes a service account from the project.
    * 
     * @param projectId The ID of the project.
     * @param serviceAccountId The ID of the service account.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectServiceAccountDeleteResponse
    */
    suspend fun deleteProjectServiceAccount(projectId: kotlin.String, serviceAccountId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): ProjectServiceAccountDeleteResponse


    /**
    * Deletes a user from the project.
    * 
     * @param projectId The ID of the project.
     * @param userId The ID of the user.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectUserDeleteResponse
    */
    suspend fun deleteProjectUser(projectId: kotlin.String, userId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): ProjectUserDeleteResponse


    /**
    * Returns a list of API keys in the project.
    * 
     * @param projectId The ID of the project.
     * @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 ProjectApiKeyListResponse
    */
    suspend fun listProjectApiKeys(projectId: kotlin.String, limit: kotlin.Int? = 20, after: kotlin.String? = null, configure: HttpRequestBuilder.() -> Unit = {}): ProjectApiKeyListResponse


    /**
    * Returns a list of service accounts in the project.
    * 
     * @param projectId The ID of the project.
     * @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 ProjectServiceAccountListResponse
    */
    suspend fun listProjectServiceAccounts(projectId: kotlin.String, limit: kotlin.Int? = 20, after: kotlin.String? = null, configure: HttpRequestBuilder.() -> Unit = {}): ProjectServiceAccountListResponse


    /**
    * Returns a list of users in the project.
    * 
     * @param projectId The ID of the project.
     * @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 ProjectUserListResponse
    */
    suspend fun listProjectUsers(projectId: kotlin.String, limit: kotlin.Int? = 20, after: kotlin.String? = null, configure: HttpRequestBuilder.() -> Unit = {}): ProjectUserListResponse


    /**
    * Returns a list of projects.
    * 
     * @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 includeArchived If `true` returns all projects including those that have been `archived`. Archived projects are not included by default. (optional, default to false)
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectListResponse
    */
    suspend fun listProjects(limit: kotlin.Int? = 20, after: kotlin.String? = null, includeArchived: kotlin.Boolean? = false, configure: HttpRequestBuilder.() -> Unit = {}): ProjectListResponse


    /**
    * Modifies a project in the organization.
    * 
     * @param projectUpdateRequest The project update request payload.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return Project
    */
    suspend fun modifyProject(projectUpdateRequest: ProjectUpdateRequest, configure: HttpRequestBuilder.() -> Unit = {}): Project


    /**
    * Modifies a user's role in the project.
    * 
     * @param projectUserUpdateRequest The project user update request payload.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectUser
    */
    suspend fun modifyProjectUser(projectUserUpdateRequest: ProjectUserUpdateRequest, configure: HttpRequestBuilder.() -> Unit = {}): ProjectUser


    /**
    * Retrieves a project.
    * 
     * @param projectId The ID of the project.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return Project
    */
    suspend fun retrieveProject(projectId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): Project


    /**
    * Retrieves an API key in the project.
    * 
     * @param projectId The ID of the project.
     * @param keyId The ID of the API key.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectApiKey
    */
    suspend fun retrieveProjectApiKey(projectId: kotlin.String, keyId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): ProjectApiKey


    /**
    * Retrieves a service account in the project.
    * 
     * @param projectId The ID of the project.
     * @param serviceAccountId The ID of the service account.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectServiceAccount
    */
    suspend fun retrieveProjectServiceAccount(projectId: kotlin.String, serviceAccountId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): ProjectServiceAccount


    /**
    * Retrieves a user in the project.
    * 
     * @param projectId The ID of the project.
     * @param userId The ID of the user.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return ProjectUser
    */
    suspend fun retrieveProjectUser(projectId: kotlin.String, userId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): ProjectUser

}

fun Projects(client: HttpClient, config: Config): com.xebia.functional.openai.generated.api.Projects = object : com.xebia.functional.openai.generated.api.Projects {
    override suspend fun archiveProject(projectId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): Project =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/archive".replace("{" + "project_id" + "}", "$projectId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun createProject(projectCreateRequest: ProjectCreateRequest, configure: HttpRequestBuilder.() -> Unit): Project =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("organization/projects") }
        setBody(projectCreateRequest
)
      }.serializeOrThrowWithResponseInfo()

    override suspend fun createProjectServiceAccount(projectId: kotlin.String,projectServiceAccountCreateRequest: ProjectServiceAccountCreateRequest, configure: HttpRequestBuilder.() -> Unit): ProjectServiceAccountCreateResponse =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/service_accounts".replace("{" + "project_id" + "}", "$projectId")) }
        setBody(projectServiceAccountCreateRequest
)
      }.serializeOrThrowWithResponseInfo()

    override suspend fun createProjectUser(projectId: kotlin.String,projectUserCreateRequest: ProjectUserCreateRequest, configure: HttpRequestBuilder.() -> Unit): ProjectUser =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/users".replace("{" + "project_id" + "}", "$projectId")) }
        setBody(projectUserCreateRequest
)
      }.serializeOrThrowWithResponseInfo()

    override suspend fun deleteProjectApiKey(projectId: kotlin.String,keyId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): ProjectApiKeyDeleteResponse =
      client.request {
        configure()
        method = HttpMethod.Delete
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/api_keys/{key_id}".replace("{" + "project_id" + "}", "$projectId").replace("{" + "key_id" + "}", "$keyId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun deleteProjectServiceAccount(projectId: kotlin.String,serviceAccountId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): ProjectServiceAccountDeleteResponse =
      client.request {
        configure()
        method = HttpMethod.Delete
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/service_accounts/{service_account_id}".replace("{" + "project_id" + "}", "$projectId").replace("{" + "service_account_id" + "}", "$serviceAccountId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun deleteProjectUser(projectId: kotlin.String,userId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): ProjectUserDeleteResponse =
      client.request {
        configure()
        method = HttpMethod.Delete
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/users/{user_id}".replace("{" + "project_id" + "}", "$projectId").replace("{" + "user_id" + "}", "$userId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun listProjectApiKeys(projectId: kotlin.String,limit: kotlin.Int?,after: kotlin.String?, configure: HttpRequestBuilder.() -> Unit): ProjectApiKeyListResponse =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
            parameter("limit", limit)
            parameter("after", after)
        url { path("organization/projects/{project_id}/api_keys".replace("{" + "project_id" + "}", "$projectId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun listProjectServiceAccounts(projectId: kotlin.String,limit: kotlin.Int?,after: kotlin.String?, configure: HttpRequestBuilder.() -> Unit): ProjectServiceAccountListResponse =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
            parameter("limit", limit)
            parameter("after", after)
        url { path("organization/projects/{project_id}/service_accounts".replace("{" + "project_id" + "}", "$projectId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun listProjectUsers(projectId: kotlin.String,limit: kotlin.Int?,after: kotlin.String?, configure: HttpRequestBuilder.() -> Unit): ProjectUserListResponse =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
            parameter("limit", limit)
            parameter("after", after)
        url { path("organization/projects/{project_id}/users".replace("{" + "project_id" + "}", "$projectId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun listProjects(limit: kotlin.Int?,after: kotlin.String?,includeArchived: kotlin.Boolean?, configure: HttpRequestBuilder.() -> Unit): ProjectListResponse =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
            parameter("limit", limit)
            parameter("after", after)
            parameter("include_archived", includeArchived)
        url { path("organization/projects") }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun modifyProject(projectUpdateRequest: ProjectUpdateRequest, configure: HttpRequestBuilder.() -> Unit): Project =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}") }
        setBody(projectUpdateRequest
)
      }.serializeOrThrowWithResponseInfo()

    override suspend fun modifyProjectUser(projectUserUpdateRequest: ProjectUserUpdateRequest, configure: HttpRequestBuilder.() -> Unit): ProjectUser =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/users/{user_id}") }
        setBody(projectUserUpdateRequest
)
      }.serializeOrThrowWithResponseInfo()

    override suspend fun retrieveProject(projectId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): Project =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}".replace("{" + "project_id" + "}", "$projectId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun retrieveProjectApiKey(projectId: kotlin.String,keyId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): ProjectApiKey =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/api_keys/{key_id}".replace("{" + "project_id" + "}", "$projectId").replace("{" + "key_id" + "}", "$keyId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun retrieveProjectServiceAccount(projectId: kotlin.String,serviceAccountId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): ProjectServiceAccount =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/service_accounts/{service_account_id}".replace("{" + "project_id" + "}", "$projectId").replace("{" + "service_account_id" + "}", "$serviceAccountId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun retrieveProjectUser(projectId: kotlin.String,userId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): ProjectUser =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
        url { path("organization/projects/{project_id}/users/{user_id}".replace("{" + "project_id" + "}", "$projectId").replace("{" + "user_id" + "}", "$userId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy