// File generated from our OpenAPI spec by Stainless.

package com.openai.services.async.admin.organization.projects

import com.openai.TestServerExtension
import com.openai.client.okhttp.OpenAIOkHttpClientAsync
import com.openai.models.admin.organization.projects.hostedtoolpermissions.HostedToolPermissionUpdateParams
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

@ExtendWith(TestServerExtension::class)
internal class HostedToolPermissionServiceAsyncTest {

    @Test
    fun retrieve() {
        val client =
            OpenAIOkHttpClientAsync.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .adminApiKey("My Admin API Key")
                .build()
        val hostedToolPermissionServiceAsync =
            client.admin().organization().projects().hostedToolPermissions()

        val projectHostedToolPermissionsFuture =
            hostedToolPermissionServiceAsync.retrieve("project_id")

        val projectHostedToolPermissions = projectHostedToolPermissionsFuture.get()
        projectHostedToolPermissions.validate()
    }

    @Test
    fun update() {
        val client =
            OpenAIOkHttpClientAsync.builder()
                .baseUrl(TestServerExtension.BASE_URL)
                .apiKey("My API Key")
                .adminApiKey("My Admin API Key")
                .build()
        val hostedToolPermissionServiceAsync =
            client.admin().organization().projects().hostedToolPermissions()

        val projectHostedToolPermissionsFuture =
            hostedToolPermissionServiceAsync.update(
                HostedToolPermissionUpdateParams.builder()
                    .projectId("project_id")
                    .codeInterpreter(
                        HostedToolPermissionUpdateParams.CodeInterpreter.builder()
                            .enabled(true)
                            .build()
                    )
                    .fileSearch(
                        HostedToolPermissionUpdateParams.FileSearch.builder().enabled(true).build()
                    )
                    .imageGeneration(
                        HostedToolPermissionUpdateParams.ImageGeneration.builder()
                            .enabled(true)
                            .build()
                    )
                    .mcp(HostedToolPermissionUpdateParams.Mcp.builder().enabled(true).build())
                    .webSearch(
                        HostedToolPermissionUpdateParams.WebSearch.builder().enabled(true).build()
                    )
                    .build()
            )

        val projectHostedToolPermissions = projectHostedToolPermissionsFuture.get()
        projectHostedToolPermissions.validate()
    }
}
