diff --git a/.castiron.stats.yml b/.castiron.stats.yml index 2061a7294..a0b791ab1 100644 --- a/.castiron.stats.yml +++ b/.castiron.stats.yml @@ -1,7 +1,7 @@ schema_version: 1 -generation_id: d3732c59-427f-42ed-b0e7-16dd57cdb7a4 -openapi_spec_hash: 11f466b784d962b4fea3ebfc456d34d6 -openapi_transformed_spec_hash: 261b64a48d73529dd8f0b83a6fc08002 -config_hash: 3a5d490bd74541b3de242f261148388e -codegen_sha: 0ed78a4a11581dfb7e24dac0d06315478513124e -codegen_hash: 9220d40724b8e9981083957597f4a91aa79959ed57326b8d052c75e28dc4077f +generation_id: d21791a8-b3e7-41d2-abdc-232aada7b32d +openapi_spec_hash: dc67b858448bc4409d6ef706e01e67ac +openapi_transformed_spec_hash: 36be70d35d74cab52f58f7b138b416da +config_hash: ade9fd21e52129aa7bab6c409e1f2901 +codegen_sha: 1a18b55ce1552e1e54d85127af498ca2e9321da1 +codegen_hash: 6a39d8117431cc7b3d11dd33e93f20ba61a8c64adf5d5cf42597c69e0b3a029f diff --git a/api_reference/openapi.transformed.yml b/api_reference/openapi.transformed.yml index d64501432..3898aa44b 100644 --- a/api_reference/openapi.transformed.yml +++ b/api_reference/openapi.transformed.yml @@ -50,6 +50,123 @@ tags: - name: Audit Logs description: List user actions and configuration changes within this organization. paths: + /organization: + get: + summary: Get organization + description: Retrieve the organization bound to the Admin API key. Requires organization.read. + operationId: GetOrganizationProfile + parameters: [] + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/TypedOrganizationResource' + x-oaiMeta: + group: administration + security: + - AdminApiKeyAuth: [] + post: + summary: Update organization + description: Update the organization bound to the Admin API key. Requires organization.write. + operationId: UpdateOrganizationProfile + parameters: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateOrganizationProfileBody' + required: true + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/TypedOrganizationResource' + x-oaiMeta: + group: administration + security: + - AdminApiKeyAuth: [] + /organization/service_tier_settings: + get: + summary: Retrieve organization service tier settings + description: Retrieve the enabled tiers for the organization bound to the Admin API key. + operationId: Retrieveorganizationservicetiersettings + parameters: [] + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationServiceTierSettingsResource' + x-oaiMeta: + group: administration + security: + - AdminApiKeyAuth: [] + post: + summary: Update organization service tier settings + description: Choose which service tiers requests in this organization can use. Requires organization.read and organization.write. See [`service_tier` in the Responses API](https://developers.openai.com/api/reference/resources/responses/methods/create). + operationId: Updateorganizationservicetiersettings + parameters: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateOrganizationServiceTierSettingsBody' + required: true + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationServiceTierSettingsResource' + x-oaiMeta: + group: administration + security: + - AdminApiKeyAuth: [] + /organization/api_key_settings: + get: + summary: Retrieve organization API key settings + description: Retrieve the organization policy for creating new project-attached keys. + operationId: RetrieveorganizationAPIkeysettings + parameters: [] + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationApiKeySettingsResource' + x-oaiMeta: + group: administration + security: + - AdminApiKeyAuth: [] + post: + summary: Update organization API key settings + description: Update which project-attached keys can be created. Requires organization.read and organization.write. Omitted key types retain their current policy. + operationId: UpdateorganizationAPIkeysettings + parameters: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateOrganizationApiKeySettingsBody' + required: true + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationApiKeySettingsResource' + x-oaiMeta: + group: administration + security: + - AdminApiKeyAuth: [] /assistants: get: operationId: listAssistants @@ -39911,6 +40028,180 @@ webhooks: status codes will be retried. components: schemas: + ApiKeyCreationAllowance: + properties: + allowed: + type: boolean + description: Whether new keys of this type can be created. + type: object + required: + - allowed + ApiKeyCreationAllowanceInputParam: + properties: + allowed: + type: boolean + description: Whether new keys of this type can be created. + type: object + required: + - allowed + ApiKeyCreationSettings: + properties: + user_owned_project_keys: + $ref: '#/components/schemas/ApiKeyCreationAllowance' + service_account_keys: + $ref: '#/components/schemas/ApiKeyCreationAllowance' + type: object + required: + - user_owned_project_keys + - service_account_keys + ApiKeyCreationSettingsInputParam: + anyOf: + - required: + - user_owned_project_keys + - required: + - service_account_keys + properties: + user_owned_project_keys: + $ref: '#/components/schemas/ApiKeyCreationAllowanceInputParam' + service_account_keys: + $ref: '#/components/schemas/ApiKeyCreationAllowanceInputParam' + type: object + required: [] + x-openai-client-required-alternatives: non-null + OrganizationApiKeySettingsResource: + properties: + object: + type: string + enum: + - organization.api_key_settings + default: organization.api_key_settings + x-stainless-const: true + creation: + anyOf: + - $ref: '#/components/schemas/ApiKeyCreationSettings' + description: Null when governance is unavailable. + - type: 'null' + type: object + required: + - object + - creation + OrganizationServiceTierSettingsResource: + properties: + object: + type: string + enum: + - organization.service_tier_settings + default: organization.service_tier_settings + x-stainless-const: true + enabled_tiers: + description: Additional service tiers that requests in this organization can use. Use `"all"` to allow current and future tiers, or `[]` to allow only Standard. Project settings and tier eligibility still apply. + anyOf: + - type: string + enum: + - all + default: all + x-stainless-const: true + - items: + $ref: '#/components/schemas/ProjectOptionalServiceTier' + type: array + type: object + required: + - object + - enabled_tiers + TypedOrganizationResource: + properties: + object: + type: string + enum: + - organization + default: organization + x-stainless-const: true + id: + type: string + description: The public organization ID. + created_at: + type: integer + format: unixtime + title: + anyOf: + - type: string + description: The organization display name. + - type: 'null' + name: + anyOf: + - type: string + description: The organization slug. + - type: 'null' + description: + anyOf: + - type: string + - type: 'null' + personal: + type: boolean + type: object + required: + - object + - id + - created_at + - title + - name + - description + - personal + UpdateOrganizationApiKeySettingsBody: + properties: + creation: + $ref: '#/components/schemas/ApiKeyCreationSettingsInputParam' + type: object + required: + - creation + UpdateOrganizationProfileBody: + anyOf: + - required: + - title + properties: + title: + type: string + maxLength: 96 + minLength: 1 + pattern: ^\s*\S + description: Organization display name, with at least one non-whitespace character. + description: + type: string + description: Organization description. Send an empty string to clear it. + type: object + title: TitleUpdate + - required: + - description + properties: + title: + type: string + maxLength: 96 + minLength: 1 + pattern: ^\s*\S + description: Organization display name, with at least one non-whitespace character. + description: + type: string + description: Organization description. Send an empty string to clear it. + type: object + title: DescriptionUpdate + x-openai-client-required-alternatives: non-null + type: object + UpdateOrganizationServiceTierSettingsBody: + properties: + enabled_tiers: + description: Additional service tiers that requests in this organization can use. Use `"all"` to allow current and future tiers, or `[]` to allow only Standard. Project settings and tier eligibility still apply. + anyOf: + - type: string + enum: + - all + default: all + x-stainless-const: true + - items: + $ref: '#/components/schemas/ProjectOptionalServiceTier' + type: array + type: object + required: + - enabled_tiers AddUploadPartRequest: type: object additionalProperties: false diff --git a/openai-java-client-okhttp/src/test/kotlin/com/openai/client/okhttp/OrganizationSettingsResponseTest.kt b/openai-java-client-okhttp/src/test/kotlin/com/openai/client/okhttp/OrganizationSettingsResponseTest.kt new file mode 100644 index 000000000..fae56557a --- /dev/null +++ b/openai-java-client-okhttp/src/test/kotlin/com/openai/client/okhttp/OrganizationSettingsResponseTest.kt @@ -0,0 +1,233 @@ +package com.openai.client.okhttp + +import com.openai.core.JsonNull +import com.openai.core.JsonValue +import com.openai.core.RequestOptions +import com.openai.core.jsonMapper +import com.openai.models.admin.organization.OrganizationRetrieveParams +import com.openai.models.admin.organization.OrganizationUpdateParams +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingUpdateParams +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingUpdateParams.Creation +import com.openai.services.async.admin.OrganizationServiceAsync +import com.openai.services.blocking.admin.OrganizationService +import java.util.concurrent.TimeUnit +import okhttp3.mockwebserver.MockResponse +import okhttp3.mockwebserver.MockWebServer +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatIllegalStateException +import org.junit.jupiter.api.Test + +internal class OrganizationSettingsResponseTest { + @Test + fun preservesNullableOrganizationSettingsValues() { + MockWebServer().use { server -> + val client = + OpenAIOkHttpClient.builder() + .adminApiKey("synthetic-admin-key") + .baseUrl(server.url("/v1/").toString()) + .maxRetries(0) + .build() + try { + val organization = client.admin().organization() + for (hasValues in listOf(true, false)) { + val title = "Synthetic organization".takeIf { hasValues } + val name = "synthetic-organization".takeIf { hasValues } + val description = "Synthetic description".takeIf { hasValues } + val profile = + if (hasValues) { + """"title":"$title","name":"$name","description":"$description"""" + } else { + """"title":null,"name":null,"description":null""" + } + server.enqueue( + json( + """{"object":"organization","id":"org_synthetic","created_at":123,"personal":false,$profile}""" + ) + ) + val response = organization.retrieve() + assertThat(response.title().orElse(null)).isEqualTo(title) + assertThat(response.name().orElse(null)).isEqualTo(name) + assertThat(response.description().orElse(null)).isEqualTo(description) + assertThat(server.takeRequest(1, TimeUnit.SECONDS)?.path) + .isEqualTo("/v1/organization") + + val creation = + if (hasValues) { + """{"service_account_keys":{"allowed":true},"user_owned_project_keys":{"allowed":false}}""" + } else { + "null" + } + server.enqueue( + json("""{"object":"organization.api_key_settings","creation":$creation}""") + ) + val settings = organization.apiKeySettings().retrieve().creation().orElse(null) + if (hasValues) { + assertThat(settings?.serviceAccountKeys()?.allowed()).isEqualTo(true) + assertThat(settings?.userOwnedProjectKeys()?.allowed()).isEqualTo(false) + } else { + assertThat(settings).isNull() + } + assertThat(server.takeRequest(1, TimeUnit.SECONDS)?.path) + .isEqualTo("/v1/organization/api_key_settings") + } + } finally { + client.close() + } + } + } + + @Test + fun keepsProfileMethodsCompatibleWithExistingImplementations() { + val services = + listOf( + OrganizationService::class.java, + OrganizationService.WithRawResponse::class.java, + OrganizationServiceAsync::class.java, + OrganizationServiceAsync.WithRawResponse::class.java, + ) + for (service in services) { + assertThat( + service + .getMethod( + "retrieve", + OrganizationRetrieveParams::class.java, + RequestOptions::class.java, + ) + .isDefault + ) + .isTrue() + assertThat( + service + .getMethod( + "update", + OrganizationUpdateParams::class.java, + RequestOptions::class.java, + ) + .isDefault + ) + .isTrue() + val updates = service.methods.filter { it.name == "update" } + assertThat(updates).isNotEmpty() + assertThat(updates).allMatch { method -> + method.parameterTypes.any { + it == OrganizationUpdateParams::class.java || + it == OrganizationUpdateParams.Body::class.java + } + } + } + } + + @Test + fun writesEitherProfileFieldIncludingAnEmptyDescription() { + MockWebServer().use { server -> + val client = + OpenAIOkHttpClient.builder() + .adminApiKey("synthetic-admin-key") + .baseUrl(server.url("/v1/").toString()) + .maxRetries(0) + .build() + try { + val updates = + listOf( + OrganizationUpdateParams.builder() + .body( + OrganizationUpdateParams.Body.TitleUpdate.builder() + .title("New title") + .build() + ) + .build() to """{"title":"New title"}""", + OrganizationUpdateParams.builder() + .body( + OrganizationUpdateParams.Body.DescriptionUpdate.builder() + .description("") + .build() + ) + .build() to """{"description":""}""", + ) + for ((params, body) in updates) { + server.enqueue( + json( + """{"object":"organization","id":"org_synthetic","created_at":123,"personal":false,"title":"New title","name":"synthetic-organization","description":""}""" + ) + ) + client.admin().organization().update(params) + val request = server.takeRequest(1, TimeUnit.SECONDS) + assertThat(request?.method).isEqualTo("POST") + assertThat(request?.path).isEqualTo("/v1/organization") + assertThat(request?.body?.readUtf8()).isEqualTo(body) + } + } finally { + client.close() + } + } + } + + @Test + fun keyPolicyRequiresAtLeastOneKeyType() { + assertThatIllegalStateException().isThrownBy { Creation.builder().build() } + assertThatIllegalStateException().isThrownBy { + Creation.builder().putAdditionalProperty("service_account_keys", JsonNull.of()).build() + } + assertThatIllegalStateException().isThrownBy { + Creation.builder() + .serviceAccountKeys(JsonNull.of()) + .userOwnedProjectKeys(JsonNull.of()) + .build() + } + } + + @Test + fun writesEitherOrBothKeyPoliciesIncludingFalse() { + MockWebServer().use { server -> + val client = + OpenAIOkHttpClient.builder() + .adminApiKey("synthetic-admin-key") + .baseUrl(server.url("/v1/").toString()) + .maxRetries(0) + .build() + try { + val owned = Creation.UserOwnedProjectKeys.builder().allowed(false).build() + val service = Creation.ServiceAccountKeys.builder().allowed(true).build() + val updates = + listOf( + Creation.builder().userOwnedProjectKeys(owned).build() to + """{"creation":{"user_owned_project_keys":{"allowed":false}}}""", + Creation.builder().serviceAccountKeys(service).build() to + """{"creation":{"service_account_keys":{"allowed":true}}}""", + Creation.builder() + .putAdditionalProperty( + "service_account_keys", + JsonValue.from(mapOf("allowed" to false)), + ) + .build() to + """{"creation":{"service_account_keys":{"allowed":false}}}""", + Creation.builder() + .userOwnedProjectKeys(owned) + .serviceAccountKeys(service) + .build() to + """{"creation":{"user_owned_project_keys":{"allowed":false},"service_account_keys":{"allowed":true}}}""", + ) + for ((creation, expected) in updates) { + server.enqueue( + json("""{"object":"organization.api_key_settings","creation":null}""") + ) + client + .admin() + .organization() + .apiKeySettings() + .update(ApiKeySettingUpdateParams.builder().creation(creation).build()) + val request = server.takeRequest(1, TimeUnit.SECONDS) + assertThat(request?.method).isEqualTo("POST") + assertThat(request?.path).isEqualTo("/v1/organization/api_key_settings") + assertThat(jsonMapper().readTree(checkNotNull(request).body.readUtf8())) + .isEqualTo(jsonMapper().readTree(expected)) + } + } finally { + client.close() + } + } + } + + private fun json(body: String) = + MockResponse().setHeader("Content-Type", "application/json").setBody(body) +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationProfile.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationProfile.kt new file mode 100644 index 000000000..1e985ae0c --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationProfile.kt @@ -0,0 +1,440 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonNull +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.core.collectAllProperties +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class OrganizationProfile +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val description: JsonField, + private val name: JsonField, + private val object_: JsonValue, + private val personal: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("object") @ExcludeMissing object_: JsonValue = JsonMissing.of(), + @JsonProperty("personal") @ExcludeMissing personal: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(id, createdAt, description, name, object_, personal, title, mutableMapOf()) + + /** + * The public organization ID. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): Long = createdAt.getRequired("created_at") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The organization slug. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("organization") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_ + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun personal(): Boolean = personal.getRequired("personal") + + /** + * The organization display name. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun title(): Optional = title.getOptional("title") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [personal]. + * + * Unlike [personal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("personal") @ExcludeMissing fun _personal(): JsonField = personal + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional properties + * with the same name. Missing properties are omitted, while explicit nulls and unrecognized + * values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties( + additionalProperties, + "id" to this.id, + "created_at" to this.createdAt, + "description" to this.description, + "name" to this.name, + "object" to this.object_, + "personal" to this.personal, + "title" to this.title, + ) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON properties. This + * accessor retains its legacy additional-properties behavior. + */ + @Deprecated("Use _allProperties() to access both declared and additional JSON properties.") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrganizationProfile]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .personal() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationProfile]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var description: JsonField? = JsonNull.of() + private var name: JsonField? = JsonNull.of() + private var object_: JsonValue = JsonValue.from("organization") + private var personal: JsonField? = null + private var title: JsonField? = JsonNull.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationProfile: OrganizationProfile) = apply { + id = organizationProfile.id + createdAt = organizationProfile.createdAt + description = organizationProfile.description + name = organizationProfile.name + object_ = organizationProfile.object_ + personal = organizationProfile.personal + title = organizationProfile.title + additionalProperties = organizationProfile.additionalProperties.toMutableMap() + } + + /** The public organization ID. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun createdAt(createdAt: Long) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** The organization slug. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("organization") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun object_(object_: JsonValue) = apply { this.object_ = object_ } + + fun personal(personal: Boolean) = personal(JsonField.of(personal)) + + /** + * Sets [Builder.personal] to an arbitrary JSON value. + * + * You should usually call [Builder.personal] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun personal(personal: JsonField) = apply { this.personal = personal } + + /** The organization display name. */ + fun title(title: String?) = title(JsonField.ofNullable(title)) + + /** Alias for calling [Builder.title] with `title.orElse(null)`. */ + fun title(title: Optional) = title(title.getOrNull()) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrganizationProfile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .personal() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrganizationProfile = + OrganizationProfile( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("description", description), + checkRequired("name", name), + object_, + checkRequired("personal", personal), + checkRequired("title", title), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): OrganizationProfile = apply { + if (validated) { + return@apply + } + + id() + createdAt() + description() + name() + _object_().let { + if (it != JsonValue.from("organization")) { + throw OpenAIInvalidDataException("'object_' is invalid, received $it") + } + } + personal() + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + object_.let { if (it == JsonValue.from("organization")) 1 else 0 } + + (if (personal.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationProfile && + id == other.id && + createdAt == other.createdAt && + description == other.description && + name == other.name && + object_ == other.object_ && + personal == other.personal && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + description, + name, + object_, + personal, + title, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrganizationProfile{id=$id, createdAt=$createdAt, description=$description, name=$name, object_=$object_, personal=$personal, title=$title, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationRetrieveParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationRetrieveParams.kt new file mode 100644 index 000000000..390b9d6b3 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationRetrieveParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization + +import com.openai.core.Params +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import java.util.Objects + +/** Retrieve the organization bound to the Admin API key. Requires organization.read. */ +class OrganizationRetrieveParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): OrganizationRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [OrganizationRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationRetrieveParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = apply { + additionalHeaders = organizationRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationRetrieveParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrganizationRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OrganizationRetrieveParams = + OrganizationRetrieveParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationRetrieveParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrganizationRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationUpdateParams.kt new file mode 100644 index 000000000..cdf887952 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationUpdateParams.kt @@ -0,0 +1,932 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.Params +import com.openai.core.allMaxBy +import com.openai.core.checkRequired +import com.openai.core.collectAllProperties +import com.openai.core.getOrThrow +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** Update the organization bound to the Admin API key. Requires organization.write. */ +class OrganizationUpdateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun body(): Body = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrganizationUpdateParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationUpdateParams]. */ + class Builder internal constructor() { + + private var body: Body? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(organizationUpdateParams: OrganizationUpdateParams) = apply { + body = organizationUpdateParams.body + additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() + } + + fun body(body: Body) = apply { this.body = body } + + /** Alias for calling [body] with `Body.ofTitleUpdate(titleUpdate)`. */ + fun body(titleUpdate: Body.TitleUpdate) = body(Body.ofTitleUpdate(titleUpdate)) + + /** Alias for calling [body] with `Body.ofDescriptionUpdate(descriptionUpdate)`. */ + fun body(descriptionUpdate: Body.DescriptionUpdate) = + body(Body.ofDescriptionUpdate(descriptionUpdate)) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [OrganizationUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrganizationUpdateParams = + OrganizationUpdateParams( + checkRequired("body", body), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + private constructor( + private val titleUpdate: TitleUpdate? = null, + private val descriptionUpdate: DescriptionUpdate? = null, + private val _json: JsonValue? = null, + ) { + + fun titleUpdate(): Optional = Optional.ofNullable(titleUpdate) + + fun descriptionUpdate(): Optional = + Optional.ofNullable(descriptionUpdate) + + fun isTitleUpdate(): Boolean = titleUpdate != null + + fun isDescriptionUpdate(): Boolean = descriptionUpdate != null + + fun asTitleUpdate(): TitleUpdate = titleUpdate.getOrThrow("titleUpdate") + + fun asDescriptionUpdate(): DescriptionUpdate = + descriptionUpdate.getOrThrow("descriptionUpdate") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = body.accept(new Body.Visitor>() { + * @Override + * public Optional visitTitleUpdate(TitleUpdate titleUpdate) { + * return Optional.of(titleUpdate.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + titleUpdate != null -> visitor.visitTitleUpdate(titleUpdate) + descriptionUpdate != null -> visitor.visitDescriptionUpdate(descriptionUpdate) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTitleUpdate(titleUpdate: TitleUpdate) { + titleUpdate.validate() + } + + override fun visitDescriptionUpdate(descriptionUpdate: DescriptionUpdate) { + descriptionUpdate.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTitleUpdate(titleUpdate: TitleUpdate) = titleUpdate.validity() + + override fun visitDescriptionUpdate(descriptionUpdate: DescriptionUpdate) = + descriptionUpdate.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + titleUpdate == other.titleUpdate && + descriptionUpdate == other.descriptionUpdate && + (titleUpdate != null || descriptionUpdate != null || _json == other._json) + } + + override fun hashCode(): Int = + if (titleUpdate == null && descriptionUpdate == null) Objects.hash(_json) + else Objects.hash(titleUpdate, descriptionUpdate) + + override fun toString(): String = + when { + titleUpdate != null -> "Body{titleUpdate=$titleUpdate}" + descriptionUpdate != null -> "Body{descriptionUpdate=$descriptionUpdate}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } + + companion object { + + @JvmStatic fun ofTitleUpdate(titleUpdate: TitleUpdate) = Body(titleUpdate = titleUpdate) + + @JvmStatic + fun ofDescriptionUpdate(descriptionUpdate: DescriptionUpdate) = + Body(descriptionUpdate = descriptionUpdate) + } + + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + interface Visitor { + + fun visitTitleUpdate(titleUpdate: TitleUpdate): T + + fun visitDescriptionUpdate(descriptionUpdate: DescriptionUpdate): T + + /** + * Maps an unknown variant of [Body] to a value of type [T]. + * + * An instance of [Body] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown Body") + } + } + + internal class Deserializer : BaseDeserializer(Body::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Body { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Body(titleUpdate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(descriptionUpdate = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Body(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Body::class) { + + override fun serialize( + value: Body, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.titleUpdate != null -> generator.writeObject(value.titleUpdate) + value.descriptionUpdate != null -> + generator.writeObject(value.descriptionUpdate) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } + } + + class TitleUpdate + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val title: JsonField, + private val description: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + ) : this(title, description, mutableMapOf()) + + /** + * Organization display name, with at least one non-whitespace character. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun title(): String = title.getRequired("title") + + /** + * Organization description. Send an empty string to clear it. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional + * properties with the same name. Missing properties are omitted, while explicit nulls + * and unrecognized values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties( + additionalProperties, + "title" to this.title, + "description" to this.description, + ) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON + * properties. This accessor retains its legacy additional-properties behavior. + */ + @Deprecated( + "Use _allProperties() to access both declared and additional JSON properties." + ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TitleUpdate]. + * + * The following fields are required: + * ```java + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TitleUpdate]. */ + class Builder internal constructor() { + + private var title: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(titleUpdate: TitleUpdate) = apply { + title = titleUpdate.title + description = titleUpdate.description + additionalProperties = titleUpdate.additionalProperties.toMutableMap() + } + + /** Organization display name, with at least one non-whitespace character. */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + /** Organization description. Send an empty string to clear it. */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TitleUpdate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TitleUpdate = + TitleUpdate( + checkRequired("title", title), + description, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TitleUpdate = apply { + if (validated) { + return@apply + } + + title() + description() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (title.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TitleUpdate && + title == other.title && + description == other.description && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(title, description, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TitleUpdate{title=$title, description=$description, additionalProperties=$additionalProperties}" + } + + class DescriptionUpdate + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(description, title, mutableMapOf()) + + /** + * Organization description. Send an empty string to clear it. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun description(): String = description.getRequired("description") + + /** + * Organization display name, with at least one non-whitespace character. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun title(): Optional = title.getOptional("title") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional + * properties with the same name. Missing properties are omitted, while explicit nulls + * and unrecognized values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties( + additionalProperties, + "description" to this.description, + "title" to this.title, + ) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON + * properties. This accessor retains its legacy additional-properties behavior. + */ + @Deprecated( + "Use _allProperties() to access both declared and additional JSON properties." + ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DescriptionUpdate]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DescriptionUpdate]. */ + class Builder internal constructor() { + + private var description: JsonField? = null + private var title: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(descriptionUpdate: DescriptionUpdate) = apply { + description = descriptionUpdate.description + title = descriptionUpdate.title + additionalProperties = descriptionUpdate.additionalProperties.toMutableMap() + } + + /** Organization description. Send an empty string to clear it. */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** Organization display name, with at least one non-whitespace character. */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DescriptionUpdate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DescriptionUpdate = + DescriptionUpdate( + checkRequired("description", description), + title, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DescriptionUpdate = apply { + if (validated) { + return@apply + } + + description() + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DescriptionUpdate && + description == other.description && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, title, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DescriptionUpdate{description=$description, title=$title, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationUpdateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OrganizationUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingRetrieveParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingRetrieveParams.kt new file mode 100644 index 000000000..c64ca2905 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingRetrieveParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.apikeysettings + +import com.openai.core.Params +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import java.util.Objects + +/** Retrieve the organization policy for creating new project-attached keys. */ +class ApiKeySettingRetrieveParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ApiKeySettingRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [ApiKeySettingRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeySettingRetrieveParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(apiKeySettingRetrieveParams: ApiKeySettingRetrieveParams) = apply { + additionalHeaders = apiKeySettingRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeySettingRetrieveParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ApiKeySettingRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ApiKeySettingRetrieveParams = + ApiKeySettingRetrieveParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeySettingRetrieveParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "ApiKeySettingRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingUpdateParams.kt new file mode 100644 index 000000000..26733eac0 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingUpdateParams.kt @@ -0,0 +1,1077 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.apikeysettings + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.Params +import com.openai.core.checkRequired +import com.openai.core.collectAllProperties +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Update which project-attached keys can be created. Requires organization.read and + * organization.write. Omitted key types retain their current policy. + */ +class ApiKeySettingUpdateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creation(): Creation = body.creation() + + /** + * Returns the raw JSON value of [creation]. + * + * Unlike [creation], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _creation(): JsonField = body._creation() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ApiKeySettingUpdateParams]. + * + * The following fields are required: + * ```java + * .creation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeySettingUpdateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(apiKeySettingUpdateParams: ApiKeySettingUpdateParams) = apply { + body = apiKeySettingUpdateParams.body.toBuilder() + additionalHeaders = apiKeySettingUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeySettingUpdateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [creation] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun creation(creation: Creation) = apply { body.creation(creation) } + + /** + * Sets [Builder.creation] to an arbitrary JSON value. + * + * You should usually call [Builder.creation] with a well-typed [Creation] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creation(creation: JsonField) = apply { body.creation(creation) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ApiKeySettingUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApiKeySettingUpdateParams = + ApiKeySettingUpdateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("creation") + @ExcludeMissing + creation: JsonField = JsonMissing.of() + ) : this(creation, mutableMapOf()) + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creation(): Creation = creation.getRequired("creation") + + /** + * Returns the raw JSON value of [creation]. + * + * Unlike [creation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creation") @ExcludeMissing fun _creation(): JsonField = creation + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional properties + * with the same name. Missing properties are omitted, while explicit nulls and unrecognized + * values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties(additionalProperties, "creation" to this.creation) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON properties. + * This accessor retains its legacy additional-properties behavior. + */ + @Deprecated("Use _allProperties() to access both declared and additional JSON properties.") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .creation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var creation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + creation = body.creation + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun creation(creation: Creation) = creation(JsonField.of(creation)) + + /** + * Sets [Builder.creation] to an arbitrary JSON value. + * + * You should usually call [Builder.creation] with a well-typed [Creation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creation(creation: JsonField) = apply { this.creation = creation } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("creation", creation), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + creation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (creation.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + creation == other.creation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(creation, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{creation=$creation, additionalProperties=$additionalProperties}" + } + + class Creation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceAccountKeys: JsonField, + private val userOwnedProjectKeys: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_account_keys") + @ExcludeMissing + serviceAccountKeys: JsonField = JsonMissing.of(), + @JsonProperty("user_owned_project_keys") + @ExcludeMissing + userOwnedProjectKeys: JsonField = JsonMissing.of(), + ) : this(serviceAccountKeys, userOwnedProjectKeys, mutableMapOf()) + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceAccountKeys(): Optional = + serviceAccountKeys.getOptional("service_account_keys") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userOwnedProjectKeys(): Optional = + userOwnedProjectKeys.getOptional("user_owned_project_keys") + + /** + * Returns the raw JSON value of [serviceAccountKeys]. + * + * Unlike [serviceAccountKeys], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_account_keys") + @ExcludeMissing + fun _serviceAccountKeys(): JsonField = serviceAccountKeys + + /** + * Returns the raw JSON value of [userOwnedProjectKeys]. + * + * Unlike [userOwnedProjectKeys], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("user_owned_project_keys") + @ExcludeMissing + fun _userOwnedProjectKeys(): JsonField = userOwnedProjectKeys + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional properties + * with the same name. Missing properties are omitted, while explicit nulls and unrecognized + * values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties( + additionalProperties, + "service_account_keys" to this.serviceAccountKeys, + "user_owned_project_keys" to this.userOwnedProjectKeys, + ) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON properties. + * This accessor retains its legacy additional-properties behavior. + */ + @Deprecated("Use _allProperties() to access both declared and additional JSON properties.") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Creation]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Creation]. */ + class Builder internal constructor() { + + private var serviceAccountKeys: JsonField = JsonMissing.of() + private var userOwnedProjectKeys: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creation: Creation) = apply { + serviceAccountKeys = creation.serviceAccountKeys + userOwnedProjectKeys = creation.userOwnedProjectKeys + additionalProperties = creation.additionalProperties.toMutableMap() + } + + fun serviceAccountKeys(serviceAccountKeys: ServiceAccountKeys) = + serviceAccountKeys(JsonField.of(serviceAccountKeys)) + + /** + * Sets [Builder.serviceAccountKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceAccountKeys] with a well-typed + * [ServiceAccountKeys] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun serviceAccountKeys(serviceAccountKeys: JsonField) = apply { + this.serviceAccountKeys = serviceAccountKeys + } + + fun userOwnedProjectKeys(userOwnedProjectKeys: UserOwnedProjectKeys) = + userOwnedProjectKeys(JsonField.of(userOwnedProjectKeys)) + + /** + * Sets [Builder.userOwnedProjectKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.userOwnedProjectKeys] with a well-typed + * [UserOwnedProjectKeys] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun userOwnedProjectKeys(userOwnedProjectKeys: JsonField) = + apply { + this.userOwnedProjectKeys = userOwnedProjectKeys + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Creation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Creation = + Creation( + serviceAccountKeys, + userOwnedProjectKeys, + additionalProperties.toMutableMap(), + ) + .also { + val properties = it._allProperties() + check( + (properties["user_owned_project_keys"]?.let { + !it.isMissing() && !it.isNull() + } == true) || + (properties["service_account_keys"]?.let { + !it.isMissing() && !it.isNull() + } == true) + ) { + "The request body requires user_owned_project_keys or service_account_keys" + } + } + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Creation = apply { + if (validated) { + return@apply + } + + serviceAccountKeys().ifPresent { it.validate() } + userOwnedProjectKeys().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (serviceAccountKeys.asKnown().getOrNull()?.validity() ?: 0) + + (userOwnedProjectKeys.asKnown().getOrNull()?.validity() ?: 0) + + class ServiceAccountKeys + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField = JsonMissing.of() + ) : this(allowed, mutableMapOf()) + + /** + * Whether new keys of this type can be created. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allowed(): Boolean = allowed.getRequired("allowed") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") @ExcludeMissing fun _allowed(): JsonField = allowed + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional + * properties with the same name. Missing properties are omitted, while explicit nulls + * and unrecognized values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties(additionalProperties, "allowed" to this.allowed) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON + * properties. This accessor retains its legacy additional-properties behavior. + */ + @Deprecated( + "Use _allProperties() to access both declared and additional JSON properties." + ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ServiceAccountKeys]. + * + * The following fields are required: + * ```java + * .allowed() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceAccountKeys]. */ + class Builder internal constructor() { + + private var allowed: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serviceAccountKeys: ServiceAccountKeys) = apply { + allowed = serviceAccountKeys.allowed + additionalProperties = serviceAccountKeys.additionalProperties.toMutableMap() + } + + /** Whether new keys of this type can be created. */ + fun allowed(allowed: Boolean) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField) = apply { this.allowed = allowed } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ServiceAccountKeys]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowed() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceAccountKeys = + ServiceAccountKeys( + checkRequired("allowed", allowed), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ServiceAccountKeys = apply { + if (validated) { + return@apply + } + + allowed() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (allowed.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceAccountKeys && + allowed == other.allowed && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowed, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ServiceAccountKeys{allowed=$allowed, additionalProperties=$additionalProperties}" + } + + class UserOwnedProjectKeys + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField = JsonMissing.of() + ) : this(allowed, mutableMapOf()) + + /** + * Whether new keys of this type can be created. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allowed(): Boolean = allowed.getRequired("allowed") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") @ExcludeMissing fun _allowed(): JsonField = allowed + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional + * properties with the same name. Missing properties are omitted, while explicit nulls + * and unrecognized values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties(additionalProperties, "allowed" to this.allowed) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON + * properties. This accessor retains its legacy additional-properties behavior. + */ + @Deprecated( + "Use _allProperties() to access both declared and additional JSON properties." + ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UserOwnedProjectKeys]. + * + * The following fields are required: + * ```java + * .allowed() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserOwnedProjectKeys]. */ + class Builder internal constructor() { + + private var allowed: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userOwnedProjectKeys: UserOwnedProjectKeys) = apply { + allowed = userOwnedProjectKeys.allowed + additionalProperties = userOwnedProjectKeys.additionalProperties.toMutableMap() + } + + /** Whether new keys of this type can be created. */ + fun allowed(allowed: Boolean) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField) = apply { this.allowed = allowed } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserOwnedProjectKeys]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowed() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserOwnedProjectKeys = + UserOwnedProjectKeys( + checkRequired("allowed", allowed), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UserOwnedProjectKeys = apply { + if (validated) { + return@apply + } + + allowed() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (allowed.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserOwnedProjectKeys && + allowed == other.allowed && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowed, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserOwnedProjectKeys{allowed=$allowed, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Creation && + serviceAccountKeys == other.serviceAccountKeys && + userOwnedProjectKeys == other.userOwnedProjectKeys && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceAccountKeys, userOwnedProjectKeys, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Creation{serviceAccountKeys=$serviceAccountKeys, userOwnedProjectKeys=$userOwnedProjectKeys, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeySettingUpdateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ApiKeySettingUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/OrganizationApiKeySettings.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/OrganizationApiKeySettings.kt new file mode 100644 index 000000000..c96c91e56 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/OrganizationApiKeySettings.kt @@ -0,0 +1,873 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.apikeysettings + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonNull +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.core.collectAllProperties +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class OrganizationApiKeySettings +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val creation: JsonField, + private val object_: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("creation") @ExcludeMissing creation: JsonField = JsonMissing.of(), + @JsonProperty("object") @ExcludeMissing object_: JsonValue = JsonMissing.of(), + ) : this(creation, object_, mutableMapOf()) + + /** + * Null when governance is unavailable. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creation(): Optional = creation.getOptional("creation") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("organization.api_key_settings") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_ + + /** + * Returns the raw JSON value of [creation]. + * + * Unlike [creation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creation") @ExcludeMissing fun _creation(): JsonField = creation + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional properties + * with the same name. Missing properties are omitted, while explicit nulls and unrecognized + * values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties( + additionalProperties, + "creation" to this.creation, + "object" to this.object_, + ) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON properties. This + * accessor retains its legacy additional-properties behavior. + */ + @Deprecated("Use _allProperties() to access both declared and additional JSON properties.") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OrganizationApiKeySettings]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationApiKeySettings]. */ + class Builder internal constructor() { + + private var creation: JsonField? = JsonNull.of() + private var object_: JsonValue = JsonValue.from("organization.api_key_settings") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationApiKeySettings: OrganizationApiKeySettings) = apply { + creation = organizationApiKeySettings.creation + object_ = organizationApiKeySettings.object_ + additionalProperties = organizationApiKeySettings.additionalProperties.toMutableMap() + } + + /** Null when governance is unavailable. */ + fun creation(creation: Creation?) = creation(JsonField.ofNullable(creation)) + + /** Alias for calling [Builder.creation] with `creation.orElse(null)`. */ + fun creation(creation: Optional) = creation(creation.getOrNull()) + + /** + * Sets [Builder.creation] to an arbitrary JSON value. + * + * You should usually call [Builder.creation] with a well-typed [Creation] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creation(creation: JsonField) = apply { this.creation = creation } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("organization.api_key_settings") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun object_(object_: JsonValue) = apply { this.object_ = object_ } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrganizationApiKeySettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OrganizationApiKeySettings = + OrganizationApiKeySettings( + checkRequired("creation", creation), + object_, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): OrganizationApiKeySettings = apply { + if (validated) { + return@apply + } + + creation().ifPresent { it.validate() } + _object_().let { + if (it != JsonValue.from("organization.api_key_settings")) { + throw OpenAIInvalidDataException("'object_' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (creation.asKnown().getOrNull()?.validity() ?: 0) + + object_.let { if (it == JsonValue.from("organization.api_key_settings")) 1 else 0 } + + /** Null when governance is unavailable. */ + class Creation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceAccountKeys: JsonField, + private val userOwnedProjectKeys: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_account_keys") + @ExcludeMissing + serviceAccountKeys: JsonField = JsonMissing.of(), + @JsonProperty("user_owned_project_keys") + @ExcludeMissing + userOwnedProjectKeys: JsonField = JsonMissing.of(), + ) : this(serviceAccountKeys, userOwnedProjectKeys, mutableMapOf()) + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun serviceAccountKeys(): ServiceAccountKeys = + serviceAccountKeys.getRequired("service_account_keys") + + /** + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun userOwnedProjectKeys(): UserOwnedProjectKeys = + userOwnedProjectKeys.getRequired("user_owned_project_keys") + + /** + * Returns the raw JSON value of [serviceAccountKeys]. + * + * Unlike [serviceAccountKeys], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_account_keys") + @ExcludeMissing + fun _serviceAccountKeys(): JsonField = serviceAccountKeys + + /** + * Returns the raw JSON value of [userOwnedProjectKeys]. + * + * Unlike [userOwnedProjectKeys], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("user_owned_project_keys") + @ExcludeMissing + fun _userOwnedProjectKeys(): JsonField = userOwnedProjectKeys + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional properties + * with the same name. Missing properties are omitted, while explicit nulls and unrecognized + * values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties( + additionalProperties, + "service_account_keys" to this.serviceAccountKeys, + "user_owned_project_keys" to this.userOwnedProjectKeys, + ) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON properties. + * This accessor retains its legacy additional-properties behavior. + */ + @Deprecated("Use _allProperties() to access both declared and additional JSON properties.") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Creation]. + * + * The following fields are required: + * ```java + * .serviceAccountKeys() + * .userOwnedProjectKeys() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Creation]. */ + class Builder internal constructor() { + + private var serviceAccountKeys: JsonField? = null + private var userOwnedProjectKeys: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creation: Creation) = apply { + serviceAccountKeys = creation.serviceAccountKeys + userOwnedProjectKeys = creation.userOwnedProjectKeys + additionalProperties = creation.additionalProperties.toMutableMap() + } + + fun serviceAccountKeys(serviceAccountKeys: ServiceAccountKeys) = + serviceAccountKeys(JsonField.of(serviceAccountKeys)) + + /** + * Sets [Builder.serviceAccountKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceAccountKeys] with a well-typed + * [ServiceAccountKeys] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun serviceAccountKeys(serviceAccountKeys: JsonField) = apply { + this.serviceAccountKeys = serviceAccountKeys + } + + fun userOwnedProjectKeys(userOwnedProjectKeys: UserOwnedProjectKeys) = + userOwnedProjectKeys(JsonField.of(userOwnedProjectKeys)) + + /** + * Sets [Builder.userOwnedProjectKeys] to an arbitrary JSON value. + * + * You should usually call [Builder.userOwnedProjectKeys] with a well-typed + * [UserOwnedProjectKeys] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun userOwnedProjectKeys(userOwnedProjectKeys: JsonField) = + apply { + this.userOwnedProjectKeys = userOwnedProjectKeys + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Creation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceAccountKeys() + * .userOwnedProjectKeys() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Creation = + Creation( + checkRequired("serviceAccountKeys", serviceAccountKeys), + checkRequired("userOwnedProjectKeys", userOwnedProjectKeys), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Creation = apply { + if (validated) { + return@apply + } + + serviceAccountKeys().validate() + userOwnedProjectKeys().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (serviceAccountKeys.asKnown().getOrNull()?.validity() ?: 0) + + (userOwnedProjectKeys.asKnown().getOrNull()?.validity() ?: 0) + + class ServiceAccountKeys + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField = JsonMissing.of() + ) : this(allowed, mutableMapOf()) + + /** + * Whether new keys of this type can be created. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allowed(): Boolean = allowed.getRequired("allowed") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") @ExcludeMissing fun _allowed(): JsonField = allowed + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional + * properties with the same name. Missing properties are omitted, while explicit nulls + * and unrecognized values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties(additionalProperties, "allowed" to this.allowed) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON + * properties. This accessor retains its legacy additional-properties behavior. + */ + @Deprecated( + "Use _allProperties() to access both declared and additional JSON properties." + ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ServiceAccountKeys]. + * + * The following fields are required: + * ```java + * .allowed() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceAccountKeys]. */ + class Builder internal constructor() { + + private var allowed: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serviceAccountKeys: ServiceAccountKeys) = apply { + allowed = serviceAccountKeys.allowed + additionalProperties = serviceAccountKeys.additionalProperties.toMutableMap() + } + + /** Whether new keys of this type can be created. */ + fun allowed(allowed: Boolean) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField) = apply { this.allowed = allowed } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ServiceAccountKeys]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowed() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceAccountKeys = + ServiceAccountKeys( + checkRequired("allowed", allowed), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ServiceAccountKeys = apply { + if (validated) { + return@apply + } + + allowed() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (allowed.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceAccountKeys && + allowed == other.allowed && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowed, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ServiceAccountKeys{allowed=$allowed, additionalProperties=$additionalProperties}" + } + + class UserOwnedProjectKeys + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowed: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowed") + @ExcludeMissing + allowed: JsonField = JsonMissing.of() + ) : this(allowed, mutableMapOf()) + + /** + * Whether new keys of this type can be created. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun allowed(): Boolean = allowed.getRequired("allowed") + + /** + * Returns the raw JSON value of [allowed]. + * + * Unlike [allowed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowed") @ExcludeMissing fun _allowed(): JsonField = allowed + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional + * properties with the same name. Missing properties are omitted, while explicit nulls + * and unrecognized values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties(additionalProperties, "allowed" to this.allowed) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON + * properties. This accessor retains its legacy additional-properties behavior. + */ + @Deprecated( + "Use _allProperties() to access both declared and additional JSON properties." + ) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UserOwnedProjectKeys]. + * + * The following fields are required: + * ```java + * .allowed() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserOwnedProjectKeys]. */ + class Builder internal constructor() { + + private var allowed: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userOwnedProjectKeys: UserOwnedProjectKeys) = apply { + allowed = userOwnedProjectKeys.allowed + additionalProperties = userOwnedProjectKeys.additionalProperties.toMutableMap() + } + + /** Whether new keys of this type can be created. */ + fun allowed(allowed: Boolean) = allowed(JsonField.of(allowed)) + + /** + * Sets [Builder.allowed] to an arbitrary JSON value. + * + * You should usually call [Builder.allowed] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun allowed(allowed: JsonField) = apply { this.allowed = allowed } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserOwnedProjectKeys]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .allowed() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserOwnedProjectKeys = + UserOwnedProjectKeys( + checkRequired("allowed", allowed), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): UserOwnedProjectKeys = apply { + if (validated) { + return@apply + } + + allowed() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (allowed.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserOwnedProjectKeys && + allowed == other.allowed && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowed, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserOwnedProjectKeys{allowed=$allowed, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Creation && + serviceAccountKeys == other.serviceAccountKeys && + userOwnedProjectKeys == other.userOwnedProjectKeys && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceAccountKeys, userOwnedProjectKeys, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Creation{serviceAccountKeys=$serviceAccountKeys, userOwnedProjectKeys=$userOwnedProjectKeys, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationApiKeySettings && + creation == other.creation && + object_ == other.object_ && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(creation, object_, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrganizationApiKeySettings{creation=$creation, object_=$object_, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/OrganizationServiceTierSettings.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/OrganizationServiceTierSettings.kt new file mode 100644 index 000000000..965ebb4a1 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/OrganizationServiceTierSettings.kt @@ -0,0 +1,524 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.servicetiersettings + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.allMaxBy +import com.openai.core.checkRequired +import com.openai.core.collectAllProperties +import com.openai.core.getOrThrow +import com.openai.core.toImmutable +import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.admin.organization.projects.servicetiersettings.ProjectOptionalServiceTier +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class OrganizationServiceTierSettings +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val enabledTiers: JsonField, + private val object_: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("enabled_tiers") + @ExcludeMissing + enabledTiers: JsonField = JsonMissing.of(), + @JsonProperty("object") @ExcludeMissing object_: JsonValue = JsonMissing.of(), + ) : this(enabledTiers, object_, mutableMapOf()) + + /** + * Additional service tiers that requests in this organization can use. Use `"all"` to allow + * current and future tiers, or `[]` to allow only Standard. Project settings and tier + * eligibility still apply. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun enabledTiers(): EnabledTiers = enabledTiers.getRequired("enabled_tiers") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("organization.service_tier_settings") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("object") @ExcludeMissing fun _object_(): JsonValue = object_ + + /** + * Returns the raw JSON value of [enabledTiers]. + * + * Unlike [enabledTiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled_tiers") + @ExcludeMissing + fun _enabledTiers(): JsonField = enabledTiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional properties + * with the same name. Missing properties are omitted, while explicit nulls and unrecognized + * values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties( + additionalProperties, + "enabled_tiers" to this.enabledTiers, + "object" to this.object_, + ) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON properties. This + * accessor retains its legacy additional-properties behavior. + */ + @Deprecated("Use _allProperties() to access both declared and additional JSON properties.") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OrganizationServiceTierSettings]. + * + * The following fields are required: + * ```java + * .enabledTiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OrganizationServiceTierSettings]. */ + class Builder internal constructor() { + + private var enabledTiers: JsonField? = null + private var object_: JsonValue = JsonValue.from("organization.service_tier_settings") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(organizationServiceTierSettings: OrganizationServiceTierSettings) = + apply { + enabledTiers = organizationServiceTierSettings.enabledTiers + object_ = organizationServiceTierSettings.object_ + additionalProperties = + organizationServiceTierSettings.additionalProperties.toMutableMap() + } + + /** + * Additional service tiers that requests in this organization can use. Use `"all"` to allow + * current and future tiers, or `[]` to allow only Standard. Project settings and tier + * eligibility still apply. + */ + fun enabledTiers(enabledTiers: EnabledTiers) = enabledTiers(JsonField.of(enabledTiers)) + + /** + * Sets [Builder.enabledTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.enabledTiers] with a well-typed [EnabledTiers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabledTiers(enabledTiers: JsonField) = apply { + this.enabledTiers = enabledTiers + } + + /** Alias for calling [enabledTiers] with `EnabledTiers.ofAll()`. */ + fun enabledTiersAll() = enabledTiers(EnabledTiers.ofAll()) + + /** + * Alias for calling [enabledTiers] with + * `EnabledTiers.ofProjectOptionalService(projectOptionalService)`. + */ + fun enabledTiersOfProjectOptionalService( + projectOptionalService: List + ) = enabledTiers(EnabledTiers.ofProjectOptionalService(projectOptionalService)) + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("organization.service_tier_settings") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun object_(object_: JsonValue) = apply { this.object_ = object_ } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OrganizationServiceTierSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .enabledTiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OrganizationServiceTierSettings = + OrganizationServiceTierSettings( + checkRequired("enabledTiers", enabledTiers), + object_, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): OrganizationServiceTierSettings = apply { + if (validated) { + return@apply + } + + enabledTiers().validate() + _object_().let { + if (it != JsonValue.from("organization.service_tier_settings")) { + throw OpenAIInvalidDataException("'object_' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (enabledTiers.asKnown().getOrNull()?.validity() ?: 0) + + object_.let { if (it == JsonValue.from("organization.service_tier_settings")) 1 else 0 } + + /** + * Additional service tiers that requests in this organization can use. Use `"all"` to allow + * current and future tiers, or `[]` to allow only Standard. Project settings and tier + * eligibility still apply. + */ + @JsonDeserialize(using = EnabledTiers.Deserializer::class) + @JsonSerialize(using = EnabledTiers.Serializer::class) + class EnabledTiers + private constructor( + private val all: JsonValue? = null, + private val projectOptionalService: List? = null, + private val _json: JsonValue? = null, + ) { + + fun all(): Optional = Optional.ofNullable(all) + + fun projectOptionalService(): Optional> = + Optional.ofNullable(projectOptionalService) + + fun isAll(): Boolean = all != null + + fun isProjectOptionalService(): Boolean = projectOptionalService != null + + fun asAll(): JsonValue = all.getOrThrow("all") + + fun asProjectOptionalService(): List = + projectOptionalService.getOrThrow("projectOptionalService") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = enabledTiers.accept(new EnabledTiers.Visitor>() { + * @Override + * public Optional visitAll(JsonValue all) { + * return Optional.of(all.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + all != null -> visitor.visitAll(all) + projectOptionalService != null -> + visitor.visitProjectOptionalService(projectOptionalService) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): EnabledTiers = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAll(all: JsonValue) { + all.let { + if (it != JsonValue.from("all")) { + throw OpenAIInvalidDataException("'all' is invalid, received $it") + } + } + } + + override fun visitProjectOptionalService( + projectOptionalService: List + ) { + projectOptionalService.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAll(all: JsonValue) = + all.let { if (it == JsonValue.from("all")) 1 else 0 } + + override fun visitProjectOptionalService( + projectOptionalService: List + ) = projectOptionalService.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EnabledTiers && + all == other.all && + projectOptionalService == other.projectOptionalService && + (all != null || projectOptionalService != null || _json == other._json) + } + + override fun hashCode(): Int = + if (all == null && projectOptionalService == null) Objects.hash(_json) + else Objects.hash(all, projectOptionalService) + + override fun toString(): String = + when { + all != null -> "EnabledTiers{all=$all}" + projectOptionalService != null -> + "EnabledTiers{projectOptionalService=$projectOptionalService}" + _json != null -> "EnabledTiers{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EnabledTiers") + } + + companion object { + + @JvmStatic fun ofAll() = EnabledTiers(all = JsonValue.from("all")) + + @JvmStatic + fun ofProjectOptionalService(projectOptionalService: List) = + EnabledTiers(projectOptionalService = projectOptionalService.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [EnabledTiers] to a value of type + * [T]. + */ + interface Visitor { + + fun visitAll(all: JsonValue): T + + fun visitProjectOptionalService( + projectOptionalService: List + ): T + + /** + * Maps an unknown variant of [EnabledTiers] to a value of type [T]. + * + * An instance of [EnabledTiers] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown EnabledTiers") + } + } + + internal class Deserializer : BaseDeserializer(EnabledTiers::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): EnabledTiers { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { EnabledTiers(all = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef>()) + ?.let { EnabledTiers(projectOptionalService = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> EnabledTiers(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(EnabledTiers::class) { + + override fun serialize( + value: EnabledTiers, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.all != null -> generator.writeObject(value.all) + value.projectOptionalService != null -> + generator.writeObject(value.projectOptionalService) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid EnabledTiers") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OrganizationServiceTierSettings && + enabledTiers == other.enabledTiers && + object_ == other.object_ && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(enabledTiers, object_, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OrganizationServiceTierSettings{enabledTiers=$enabledTiers, object_=$object_, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingRetrieveParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingRetrieveParams.kt new file mode 100644 index 000000000..c12c51b29 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingRetrieveParams.kt @@ -0,0 +1,178 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.servicetiersettings + +import com.openai.core.Params +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import java.util.Objects + +/** Retrieve the enabled tiers for the organization bound to the Admin API key. */ +class ServiceTierSettingRetrieveParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ServiceTierSettingRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [ServiceTierSettingRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceTierSettingRetrieveParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(serviceTierSettingRetrieveParams: ServiceTierSettingRetrieveParams) = + apply { + additionalHeaders = serviceTierSettingRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = + serviceTierSettingRetrieveParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ServiceTierSettingRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ServiceTierSettingRetrieveParams = + ServiceTierSettingRetrieveParams( + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceTierSettingRetrieveParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "ServiceTierSettingRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingUpdateParams.kt new file mode 100644 index 000000000..009fd854b --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingUpdateParams.kt @@ -0,0 +1,750 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.servicetiersettings + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.Params +import com.openai.core.allMaxBy +import com.openai.core.checkRequired +import com.openai.core.collectAllProperties +import com.openai.core.getOrThrow +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import com.openai.core.toImmutable +import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.admin.organization.projects.servicetiersettings.ProjectOptionalServiceTier +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Choose which service tiers requests in this organization can use. Requires organization.read and + * organization.write. See + * [`service_tier` in the Responses API](https://developers.openai.com/api/reference/resources/responses/methods/create). + */ +class ServiceTierSettingUpdateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Additional service tiers that requests in this organization can use. Use `"all"` to allow + * current and future tiers, or `[]` to allow only Standard. Project settings and tier + * eligibility still apply. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun enabledTiers(): EnabledTiers = body.enabledTiers() + + /** + * Returns the raw JSON value of [enabledTiers]. + * + * Unlike [enabledTiers], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _enabledTiers(): JsonField = body._enabledTiers() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ServiceTierSettingUpdateParams]. + * + * The following fields are required: + * ```java + * .enabledTiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServiceTierSettingUpdateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(serviceTierSettingUpdateParams: ServiceTierSettingUpdateParams) = apply { + body = serviceTierSettingUpdateParams.body.toBuilder() + additionalHeaders = serviceTierSettingUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = serviceTierSettingUpdateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [enabledTiers] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Additional service tiers that requests in this organization can use. Use `"all"` to allow + * current and future tiers, or `[]` to allow only Standard. Project settings and tier + * eligibility still apply. + */ + fun enabledTiers(enabledTiers: EnabledTiers) = apply { body.enabledTiers(enabledTiers) } + + /** + * Sets [Builder.enabledTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.enabledTiers] with a well-typed [EnabledTiers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabledTiers(enabledTiers: JsonField) = apply { + body.enabledTiers(enabledTiers) + } + + /** Alias for calling [enabledTiers] with `EnabledTiers.ofAll()`. */ + fun enabledTiersAll() = apply { body.enabledTiersAll() } + + /** + * Alias for calling [enabledTiers] with + * `EnabledTiers.ofProjectOptionalService(projectOptionalService)`. + */ + fun enabledTiersOfProjectOptionalService( + projectOptionalService: List + ) = apply { body.enabledTiersOfProjectOptionalService(projectOptionalService) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ServiceTierSettingUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .enabledTiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServiceTierSettingUpdateParams = + ServiceTierSettingUpdateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val enabledTiers: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("enabled_tiers") + @ExcludeMissing + enabledTiers: JsonField = JsonMissing.of() + ) : this(enabledTiers, mutableMapOf()) + + /** + * Additional service tiers that requests in this organization can use. Use `"all"` to allow + * current and future tiers, or `[]` to allow only Standard. Project settings and tier + * eligibility still apply. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun enabledTiers(): EnabledTiers = enabledTiers.getRequired("enabled_tiers") + + /** + * Returns the raw JSON value of [enabledTiers]. + * + * Unlike [enabledTiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("enabled_tiers") + @ExcludeMissing + fun _enabledTiers(): JsonField = enabledTiers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + /** + * Returns an immutable snapshot of all present JSON properties, including declared and + * additional properties. + * + * Keys use their JSON names. Declared properties take precedence over additional properties + * with the same name. Missing properties are omitted, while explicit nulls and unrecognized + * values are preserved. + */ + fun _allProperties(): Map = + collectAllProperties(additionalProperties, "enabled_tiers" to this.enabledTiers) + + /** + * Returns the legacy additional-properties view. + * + * @deprecated Use [_allProperties] to access both declared and additional JSON properties. + * This accessor retains its legacy additional-properties behavior. + */ + @Deprecated("Use _allProperties() to access both declared and additional JSON properties.") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .enabledTiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var enabledTiers: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + enabledTiers = body.enabledTiers + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Additional service tiers that requests in this organization can use. Use `"all"` to + * allow current and future tiers, or `[]` to allow only Standard. Project settings and + * tier eligibility still apply. + */ + fun enabledTiers(enabledTiers: EnabledTiers) = enabledTiers(JsonField.of(enabledTiers)) + + /** + * Sets [Builder.enabledTiers] to an arbitrary JSON value. + * + * You should usually call [Builder.enabledTiers] with a well-typed [EnabledTiers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabledTiers(enabledTiers: JsonField) = apply { + this.enabledTiers = enabledTiers + } + + /** Alias for calling [enabledTiers] with `EnabledTiers.ofAll()`. */ + fun enabledTiersAll() = enabledTiers(EnabledTiers.ofAll()) + + /** + * Alias for calling [enabledTiers] with + * `EnabledTiers.ofProjectOptionalService(projectOptionalService)`. + */ + fun enabledTiersOfProjectOptionalService( + projectOptionalService: List + ) = enabledTiers(EnabledTiers.ofProjectOptionalService(projectOptionalService)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .enabledTiers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("enabledTiers", enabledTiers), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + enabledTiers().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (enabledTiers.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + enabledTiers == other.enabledTiers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(enabledTiers, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{enabledTiers=$enabledTiers, additionalProperties=$additionalProperties}" + } + + /** + * Additional service tiers that requests in this organization can use. Use `"all"` to allow + * current and future tiers, or `[]` to allow only Standard. Project settings and tier + * eligibility still apply. + */ + @JsonDeserialize(using = EnabledTiers.Deserializer::class) + @JsonSerialize(using = EnabledTiers.Serializer::class) + class EnabledTiers + private constructor( + private val all: JsonValue? = null, + private val projectOptionalService: List? = null, + private val _json: JsonValue? = null, + ) { + + fun all(): Optional = Optional.ofNullable(all) + + fun projectOptionalService(): Optional> = + Optional.ofNullable(projectOptionalService) + + fun isAll(): Boolean = all != null + + fun isProjectOptionalService(): Boolean = projectOptionalService != null + + fun asAll(): JsonValue = all.getOrThrow("all") + + fun asProjectOptionalService(): List = + projectOptionalService.getOrThrow("projectOptionalService") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = enabledTiers.accept(new EnabledTiers.Visitor>() { + * @Override + * public Optional visitAll(JsonValue all) { + * return Optional.of(all.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + all != null -> visitor.visitAll(all) + projectOptionalService != null -> + visitor.visitProjectOptionalService(projectOptionalService) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): EnabledTiers = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAll(all: JsonValue) { + all.let { + if (it != JsonValue.from("all")) { + throw OpenAIInvalidDataException("'all' is invalid, received $it") + } + } + } + + override fun visitProjectOptionalService( + projectOptionalService: List + ) { + projectOptionalService.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAll(all: JsonValue) = + all.let { if (it == JsonValue.from("all")) 1 else 0 } + + override fun visitProjectOptionalService( + projectOptionalService: List + ) = projectOptionalService.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EnabledTiers && + all == other.all && + projectOptionalService == other.projectOptionalService && + (all != null || projectOptionalService != null || _json == other._json) + } + + override fun hashCode(): Int = + if (all == null && projectOptionalService == null) Objects.hash(_json) + else Objects.hash(all, projectOptionalService) + + override fun toString(): String = + when { + all != null -> "EnabledTiers{all=$all}" + projectOptionalService != null -> + "EnabledTiers{projectOptionalService=$projectOptionalService}" + _json != null -> "EnabledTiers{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EnabledTiers") + } + + companion object { + + @JvmStatic fun ofAll() = EnabledTiers(all = JsonValue.from("all")) + + @JvmStatic + fun ofProjectOptionalService(projectOptionalService: List) = + EnabledTiers(projectOptionalService = projectOptionalService.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [EnabledTiers] to a value of type + * [T]. + */ + interface Visitor { + + fun visitAll(all: JsonValue): T + + fun visitProjectOptionalService( + projectOptionalService: List + ): T + + /** + * Maps an unknown variant of [EnabledTiers] to a value of type [T]. + * + * An instance of [EnabledTiers] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown EnabledTiers") + } + } + + internal class Deserializer : BaseDeserializer(EnabledTiers::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): EnabledTiers { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { EnabledTiers(all = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef>()) + ?.let { EnabledTiers(projectOptionalService = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> EnabledTiers(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(EnabledTiers::class) { + + override fun serialize( + value: EnabledTiers, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.all != null -> generator.writeObject(value.all) + value.projectOptionalService != null -> + generator.writeObject(value.projectOptionalService) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid EnabledTiers") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceTierSettingUpdateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ServiceTierSettingUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsync.kt index 348d2a4c9..917f07c59 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsync.kt @@ -3,7 +3,13 @@ package com.openai.services.async.admin import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.http.HttpResponseFor +import com.openai.models.admin.organization.OrganizationProfile +import com.openai.models.admin.organization.OrganizationRetrieveParams +import com.openai.models.admin.organization.OrganizationUpdateParams import com.openai.services.async.admin.organization.AdminApiKeyServiceAsync +import com.openai.services.async.admin.organization.ApiKeySettingServiceAsync import com.openai.services.async.admin.organization.AuditLogServiceAsync import com.openai.services.async.admin.organization.CertificateServiceAsync import com.openai.services.async.admin.organization.DataRetentionServiceAsync @@ -14,11 +20,13 @@ import com.openai.services.async.admin.organization.HealthServiceAsync import com.openai.services.async.admin.organization.InviteServiceAsync import com.openai.services.async.admin.organization.ProjectServiceAsync import com.openai.services.async.admin.organization.RoleServiceAsync +import com.openai.services.async.admin.organization.ServiceTierSettingServiceAsync import com.openai.services.async.admin.organization.SpendAlertServiceAsync import com.openai.services.async.admin.organization.SpendLimitServiceAsync import com.openai.services.async.admin.organization.UsageServiceAsync import com.openai.services.async.admin.organization.UserServiceAsync import com.openai.services.async.admin.organization.WorkloadIdentityProviderServiceAsync +import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface OrganizationServiceAsync { @@ -84,6 +92,54 @@ interface OrganizationServiceAsync { fun health(): HealthServiceAsync = throw UnsupportedOperationException("Subservice is not supported by this implementation") + fun serviceTierSettings(): ServiceTierSettingServiceAsync = + throw UnsupportedOperationException("Subservice is not supported by this implementation") + + fun apiKeySettings(): ApiKeySettingServiceAsync = + throw UnsupportedOperationException("Subservice is not supported by this implementation") + + /** Retrieve the organization bound to the Admin API key. Requires organization.read. */ + fun retrieve(): CompletableFuture = + retrieve(OrganizationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: OrganizationRetrieveParams = OrganizationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + throw UnsupportedOperationException("Operation is not supported by this implementation") + + /** @see retrieve */ + fun retrieve( + params: OrganizationRetrieveParams = OrganizationRetrieveParams.none() + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(requestOptions: RequestOptions): CompletableFuture = + retrieve(OrganizationRetrieveParams.none(), requestOptions) + + /** Update the organization bound to the Admin API key. Requires organization.write. */ + fun update(params: OrganizationUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + throw UnsupportedOperationException("Operation is not supported by this implementation") + + /** @see update */ + fun update( + body: OrganizationUpdateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(OrganizationUpdateParams.builder().body(body).build(), requestOptions) + + /** @see update */ + fun update(body: OrganizationUpdateParams.Body): CompletableFuture = + update(body, RequestOptions.none()) + /** * A view of [OrganizationServiceAsync] that provides access to raw HTTP responses for each * method. @@ -179,5 +235,70 @@ interface OrganizationServiceAsync { throw UnsupportedOperationException( "Subservice is not supported by this implementation" ) + + fun serviceTierSettings(): ServiceTierSettingServiceAsync.WithRawResponse = + throw UnsupportedOperationException( + "Subservice is not supported by this implementation" + ) + + fun apiKeySettings(): ApiKeySettingServiceAsync.WithRawResponse = + throw UnsupportedOperationException( + "Subservice is not supported by this implementation" + ) + + /** + * Returns a raw HTTP response for `get /organization`, but is otherwise the same as + * [OrganizationServiceAsync.retrieve]. + */ + fun retrieve(): CompletableFuture> = + retrieve(OrganizationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: OrganizationRetrieveParams = OrganizationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + throw UnsupportedOperationException("Operation is not supported by this implementation") + + /** @see retrieve */ + fun retrieve( + params: OrganizationRetrieveParams = OrganizationRetrieveParams.none() + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture> = + retrieve(OrganizationRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /organization`, but is otherwise the same as + * [OrganizationServiceAsync.update]. + */ + fun update( + params: OrganizationUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + throw UnsupportedOperationException("Operation is not supported by this implementation") + + /** @see update */ + fun update( + body: OrganizationUpdateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(OrganizationUpdateParams.builder().body(body).build(), requestOptions) + + /** @see update */ + fun update( + body: OrganizationUpdateParams.Body + ): CompletableFuture> = + update(body, RequestOptions.none()) } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncImpl.kt index d59242407..7f2148331 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncImpl.kt @@ -3,8 +3,26 @@ package com.openai.services.async.admin import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.SecurityOptions +import com.openai.core.handlers.errorBodyHandler +import com.openai.core.handlers.errorHandler +import com.openai.core.handlers.jsonHandler +import com.openai.core.http.HttpMethod +import com.openai.core.http.HttpRequest +import com.openai.core.http.HttpResponse +import com.openai.core.http.HttpResponse.Handler +import com.openai.core.http.HttpResponseFor +import com.openai.core.http.json +import com.openai.core.http.parseable +import com.openai.core.prepareAsync +import com.openai.models.admin.organization.OrganizationProfile +import com.openai.models.admin.organization.OrganizationRetrieveParams +import com.openai.models.admin.organization.OrganizationUpdateParams import com.openai.services.async.admin.organization.AdminApiKeyServiceAsync import com.openai.services.async.admin.organization.AdminApiKeyServiceAsyncImpl +import com.openai.services.async.admin.organization.ApiKeySettingServiceAsync +import com.openai.services.async.admin.organization.ApiKeySettingServiceAsyncImpl import com.openai.services.async.admin.organization.AuditLogServiceAsync import com.openai.services.async.admin.organization.AuditLogServiceAsyncImpl import com.openai.services.async.admin.organization.CertificateServiceAsync @@ -25,6 +43,8 @@ import com.openai.services.async.admin.organization.ProjectServiceAsync import com.openai.services.async.admin.organization.ProjectServiceAsyncImpl import com.openai.services.async.admin.organization.RoleServiceAsync import com.openai.services.async.admin.organization.RoleServiceAsyncImpl +import com.openai.services.async.admin.organization.ServiceTierSettingServiceAsync +import com.openai.services.async.admin.organization.ServiceTierSettingServiceAsyncImpl import com.openai.services.async.admin.organization.SpendAlertServiceAsync import com.openai.services.async.admin.organization.SpendAlertServiceAsyncImpl import com.openai.services.async.admin.organization.SpendLimitServiceAsync @@ -35,6 +55,7 @@ import com.openai.services.async.admin.organization.UserServiceAsync import com.openai.services.async.admin.organization.UserServiceAsyncImpl import com.openai.services.async.admin.organization.WorkloadIdentityProviderServiceAsync import com.openai.services.async.admin.organization.WorkloadIdentityProviderServiceAsyncImpl +import java.util.concurrent.CompletableFuture import java.util.function.Consumer class OrganizationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -92,6 +113,14 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption private val health: HealthServiceAsync by lazy { HealthServiceAsyncImpl(clientOptions) } + private val serviceTierSettings: ServiceTierSettingServiceAsync by lazy { + ServiceTierSettingServiceAsyncImpl(clientOptions) + } + + private val apiKeySettings: ApiKeySettingServiceAsync by lazy { + ApiKeySettingServiceAsyncImpl(clientOptions) + } + override fun withRawResponse(): OrganizationServiceAsync.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): OrganizationServiceAsync = @@ -131,9 +160,30 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption override fun health(): HealthServiceAsync = health + override fun serviceTierSettings(): ServiceTierSettingServiceAsync = serviceTierSettings + + override fun apiKeySettings(): ApiKeySettingServiceAsync = apiKeySettings + + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /organization + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /organization + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : OrganizationServiceAsync.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val auditLogs: AuditLogServiceAsync.WithRawResponse by lazy { AuditLogServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -199,6 +249,14 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption HealthServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val serviceTierSettings: ServiceTierSettingServiceAsync.WithRawResponse by lazy { + ServiceTierSettingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val apiKeySettings: ApiKeySettingServiceAsync.WithRawResponse by lazy { + ApiKeySettingServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): OrganizationServiceAsync.WithRawResponse = @@ -240,5 +298,79 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption override fun projects(): ProjectServiceAsync.WithRawResponse = projects override fun health(): HealthServiceAsync.WithRawResponse = health + + override fun serviceTierSettings(): ServiceTierSettingServiceAsync.WithRawResponse = + serviceTierSettings + + override fun apiKeySettings(): ApiKeySettingServiceAsync.WithRawResponse = apiKeySettings + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization") + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsync.kt new file mode 100644 index 000000000..77bd53ae6 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsync.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.async.admin.organization + +import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.http.HttpResponseFor +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingRetrieveParams +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingUpdateParams +import com.openai.models.admin.organization.apikeysettings.OrganizationApiKeySettings +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ApiKeySettingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ApiKeySettingServiceAsync + + /** Retrieve the organization policy for creating new project-attached keys. */ + fun retrieve(): CompletableFuture = + retrieve(ApiKeySettingRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: ApiKeySettingRetrieveParams = ApiKeySettingRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: ApiKeySettingRetrieveParams = ApiKeySettingRetrieveParams.none() + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(requestOptions: RequestOptions): CompletableFuture = + retrieve(ApiKeySettingRetrieveParams.none(), requestOptions) + + /** + * Update which project-attached keys can be created. Requires organization.read and + * organization.write. Omitted key types retain their current policy. + */ + fun update(params: ApiKeySettingUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ApiKeySettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [ApiKeySettingServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ApiKeySettingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /organization/api_key_settings`, but is otherwise + * the same as [ApiKeySettingServiceAsync.retrieve]. + */ + fun retrieve(): CompletableFuture> = + retrieve(ApiKeySettingRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: ApiKeySettingRetrieveParams = ApiKeySettingRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: ApiKeySettingRetrieveParams = ApiKeySettingRetrieveParams.none() + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture> = + retrieve(ApiKeySettingRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /organization/api_key_settings`, but is otherwise + * the same as [ApiKeySettingServiceAsync.update]. + */ + fun update( + params: ApiKeySettingUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ApiKeySettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsyncImpl.kt new file mode 100644 index 000000000..aa5b8819a --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsyncImpl.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.async.admin.organization + +import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.SecurityOptions +import com.openai.core.handlers.errorBodyHandler +import com.openai.core.handlers.errorHandler +import com.openai.core.handlers.jsonHandler +import com.openai.core.http.HttpMethod +import com.openai.core.http.HttpRequest +import com.openai.core.http.HttpResponse +import com.openai.core.http.HttpResponse.Handler +import com.openai.core.http.HttpResponseFor +import com.openai.core.http.json +import com.openai.core.http.parseable +import com.openai.core.prepareAsync +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingRetrieveParams +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingUpdateParams +import com.openai.models.admin.organization.apikeysettings.OrganizationApiKeySettings +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class ApiKeySettingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeySettingServiceAsync { + + private val withRawResponse: ApiKeySettingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ApiKeySettingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ApiKeySettingServiceAsync = + ApiKeySettingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ApiKeySettingRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /organization/api_key_settings + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ApiKeySettingUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /organization/api_key_settings + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeySettingServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ApiKeySettingServiceAsync.WithRawResponse = + ApiKeySettingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ApiKeySettingRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "api_key_settings") + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: ApiKeySettingUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "api_key_settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsync.kt new file mode 100644 index 000000000..f5ed36326 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsync.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.async.admin.organization + +import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.http.HttpResponseFor +import com.openai.models.admin.organization.servicetiersettings.OrganizationServiceTierSettings +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingRetrieveParams +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ServiceTierSettingServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ServiceTierSettingServiceAsync + + /** Retrieve the enabled tiers for the organization bound to the Admin API key. */ + fun retrieve(): CompletableFuture = + retrieve(ServiceTierSettingRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: ServiceTierSettingRetrieveParams = ServiceTierSettingRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: ServiceTierSettingRetrieveParams = ServiceTierSettingRetrieveParams.none() + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture = + retrieve(ServiceTierSettingRetrieveParams.none(), requestOptions) + + /** + * Choose which service tiers requests in this organization can use. Requires organization.read + * and organization.write. See + * [`service_tier` in the Responses API](https://developers.openai.com/api/reference/resources/responses/methods/create). + */ + fun update( + params: ServiceTierSettingUpdateParams + ): CompletableFuture = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ServiceTierSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [ServiceTierSettingServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ServiceTierSettingServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /organization/service_tier_settings`, but is + * otherwise the same as [ServiceTierSettingServiceAsync.retrieve]. + */ + fun retrieve(): CompletableFuture> = + retrieve(ServiceTierSettingRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: ServiceTierSettingRetrieveParams = ServiceTierSettingRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: ServiceTierSettingRetrieveParams = ServiceTierSettingRetrieveParams.none() + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture> = + retrieve(ServiceTierSettingRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /organization/service_tier_settings`, but is + * otherwise the same as [ServiceTierSettingServiceAsync.update]. + */ + fun update( + params: ServiceTierSettingUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ServiceTierSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsyncImpl.kt new file mode 100644 index 000000000..82e965afa --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsyncImpl.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.async.admin.organization + +import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.SecurityOptions +import com.openai.core.handlers.errorBodyHandler +import com.openai.core.handlers.errorHandler +import com.openai.core.handlers.jsonHandler +import com.openai.core.http.HttpMethod +import com.openai.core.http.HttpRequest +import com.openai.core.http.HttpResponse +import com.openai.core.http.HttpResponse.Handler +import com.openai.core.http.HttpResponseFor +import com.openai.core.http.json +import com.openai.core.http.parseable +import com.openai.core.prepareAsync +import com.openai.models.admin.organization.servicetiersettings.OrganizationServiceTierSettings +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingRetrieveParams +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class ServiceTierSettingServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : ServiceTierSettingServiceAsync { + + private val withRawResponse: ServiceTierSettingServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ServiceTierSettingServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): ServiceTierSettingServiceAsync = + ServiceTierSettingServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun retrieve( + params: ServiceTierSettingRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /organization/service_tier_settings + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ServiceTierSettingUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /organization/service_tier_settings + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceTierSettingServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ServiceTierSettingServiceAsync.WithRawResponse = + ServiceTierSettingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ServiceTierSettingRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "service_tier_settings") + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: ServiceTierSettingUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "service_tier_settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationService.kt index 69bf4d2ea..16dc9f881 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationService.kt @@ -2,8 +2,15 @@ package com.openai.services.blocking.admin +import com.google.errorprone.annotations.MustBeClosed import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.http.HttpResponseFor +import com.openai.models.admin.organization.OrganizationProfile +import com.openai.models.admin.organization.OrganizationRetrieveParams +import com.openai.models.admin.organization.OrganizationUpdateParams import com.openai.services.blocking.admin.organization.AdminApiKeyService +import com.openai.services.blocking.admin.organization.ApiKeySettingService import com.openai.services.blocking.admin.organization.AuditLogService import com.openai.services.blocking.admin.organization.CertificateService import com.openai.services.blocking.admin.organization.DataRetentionService @@ -14,6 +21,7 @@ import com.openai.services.blocking.admin.organization.HealthService import com.openai.services.blocking.admin.organization.InviteService import com.openai.services.blocking.admin.organization.ProjectService import com.openai.services.blocking.admin.organization.RoleService +import com.openai.services.blocking.admin.organization.ServiceTierSettingService import com.openai.services.blocking.admin.organization.SpendAlertService import com.openai.services.blocking.admin.organization.SpendLimitService import com.openai.services.blocking.admin.organization.UsageService @@ -84,6 +92,53 @@ interface OrganizationService { fun health(): HealthService = throw UnsupportedOperationException("Subservice is not supported by this implementation") + fun serviceTierSettings(): ServiceTierSettingService = + throw UnsupportedOperationException("Subservice is not supported by this implementation") + + fun apiKeySettings(): ApiKeySettingService = + throw UnsupportedOperationException("Subservice is not supported by this implementation") + + /** Retrieve the organization bound to the Admin API key. Requires organization.read. */ + fun retrieve(): OrganizationProfile = retrieve(OrganizationRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: OrganizationRetrieveParams = OrganizationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationProfile = + throw UnsupportedOperationException("Operation is not supported by this implementation") + + /** @see retrieve */ + fun retrieve( + params: OrganizationRetrieveParams = OrganizationRetrieveParams.none() + ): OrganizationProfile = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(requestOptions: RequestOptions): OrganizationProfile = + retrieve(OrganizationRetrieveParams.none(), requestOptions) + + /** Update the organization bound to the Admin API key. Requires organization.write. */ + fun update(params: OrganizationUpdateParams): OrganizationProfile = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationProfile = + throw UnsupportedOperationException("Operation is not supported by this implementation") + + /** @see update */ + fun update( + body: OrganizationUpdateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationProfile = + update(OrganizationUpdateParams.builder().body(body).build(), requestOptions) + + /** @see update */ + fun update(body: OrganizationUpdateParams.Body): OrganizationProfile = + update(body, RequestOptions.none()) + /** * A view of [OrganizationService] that provides access to raw HTTP responses for each method. */ @@ -178,5 +233,71 @@ interface OrganizationService { throw UnsupportedOperationException( "Subservice is not supported by this implementation" ) + + fun serviceTierSettings(): ServiceTierSettingService.WithRawResponse = + throw UnsupportedOperationException( + "Subservice is not supported by this implementation" + ) + + fun apiKeySettings(): ApiKeySettingService.WithRawResponse = + throw UnsupportedOperationException( + "Subservice is not supported by this implementation" + ) + + /** + * Returns a raw HTTP response for `get /organization`, but is otherwise the same as + * [OrganizationService.retrieve]. + */ + @MustBeClosed + fun retrieve(): HttpResponseFor = + retrieve(OrganizationRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: OrganizationRetrieveParams = OrganizationRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + throw UnsupportedOperationException("Operation is not supported by this implementation") + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: OrganizationRetrieveParams = OrganizationRetrieveParams.none() + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(requestOptions: RequestOptions): HttpResponseFor = + retrieve(OrganizationRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /organization`, but is otherwise the same as + * [OrganizationService.update]. + */ + @MustBeClosed + fun update(params: OrganizationUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + throw UnsupportedOperationException("Operation is not supported by this implementation") + + /** @see update */ + @MustBeClosed + fun update( + body: OrganizationUpdateParams.Body, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(OrganizationUpdateParams.builder().body(body).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(body: OrganizationUpdateParams.Body): HttpResponseFor = + update(body, RequestOptions.none()) } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationServiceImpl.kt index 3ee4af8cf..d8c1fe0df 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationServiceImpl.kt @@ -3,8 +3,26 @@ package com.openai.services.blocking.admin import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.SecurityOptions +import com.openai.core.handlers.errorBodyHandler +import com.openai.core.handlers.errorHandler +import com.openai.core.handlers.jsonHandler +import com.openai.core.http.HttpMethod +import com.openai.core.http.HttpRequest +import com.openai.core.http.HttpResponse +import com.openai.core.http.HttpResponse.Handler +import com.openai.core.http.HttpResponseFor +import com.openai.core.http.json +import com.openai.core.http.parseable +import com.openai.core.prepare +import com.openai.models.admin.organization.OrganizationProfile +import com.openai.models.admin.organization.OrganizationRetrieveParams +import com.openai.models.admin.organization.OrganizationUpdateParams import com.openai.services.blocking.admin.organization.AdminApiKeyService import com.openai.services.blocking.admin.organization.AdminApiKeyServiceImpl +import com.openai.services.blocking.admin.organization.ApiKeySettingService +import com.openai.services.blocking.admin.organization.ApiKeySettingServiceImpl import com.openai.services.blocking.admin.organization.AuditLogService import com.openai.services.blocking.admin.organization.AuditLogServiceImpl import com.openai.services.blocking.admin.organization.CertificateService @@ -25,6 +43,8 @@ import com.openai.services.blocking.admin.organization.ProjectService import com.openai.services.blocking.admin.organization.ProjectServiceImpl import com.openai.services.blocking.admin.organization.RoleService import com.openai.services.blocking.admin.organization.RoleServiceImpl +import com.openai.services.blocking.admin.organization.ServiceTierSettingService +import com.openai.services.blocking.admin.organization.ServiceTierSettingServiceImpl import com.openai.services.blocking.admin.organization.SpendAlertService import com.openai.services.blocking.admin.organization.SpendAlertServiceImpl import com.openai.services.blocking.admin.organization.SpendLimitService @@ -82,6 +102,14 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl private val health: HealthService by lazy { HealthServiceImpl(clientOptions) } + private val serviceTierSettings: ServiceTierSettingService by lazy { + ServiceTierSettingServiceImpl(clientOptions) + } + + private val apiKeySettings: ApiKeySettingService by lazy { + ApiKeySettingServiceImpl(clientOptions) + } + override fun withRawResponse(): OrganizationService.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): OrganizationService = @@ -121,9 +149,30 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl override fun health(): HealthService = health + override fun serviceTierSettings(): ServiceTierSettingService = serviceTierSettings + + override fun apiKeySettings(): ApiKeySettingService = apiKeySettings + + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): OrganizationProfile = + // get /organization + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): OrganizationProfile = + // post /organization + withRawResponse().update(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : OrganizationService.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + private val auditLogs: AuditLogService.WithRawResponse by lazy { AuditLogServiceImpl.WithRawResponseImpl(clientOptions) } @@ -189,6 +238,14 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl HealthServiceImpl.WithRawResponseImpl(clientOptions) } + private val serviceTierSettings: ServiceTierSettingService.WithRawResponse by lazy { + ServiceTierSettingServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val apiKeySettings: ApiKeySettingService.WithRawResponse by lazy { + ApiKeySettingServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): OrganizationService.WithRawResponse = @@ -229,5 +286,73 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl override fun projects(): ProjectService.WithRawResponse = projects override fun health(): HealthService.WithRawResponse = health + + override fun serviceTierSettings(): ServiceTierSettingService.WithRawResponse = + serviceTierSettings + + override fun apiKeySettings(): ApiKeySettingService.WithRawResponse = apiKeySettings + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization") + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingService.kt new file mode 100644 index 000000000..5fe471596 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingService.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.blocking.admin.organization + +import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.http.HttpResponseFor +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingRetrieveParams +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingUpdateParams +import com.openai.models.admin.organization.apikeysettings.OrganizationApiKeySettings +import java.util.function.Consumer + +interface ApiKeySettingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ApiKeySettingService + + /** Retrieve the organization policy for creating new project-attached keys. */ + fun retrieve(): OrganizationApiKeySettings = retrieve(ApiKeySettingRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: ApiKeySettingRetrieveParams = ApiKeySettingRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationApiKeySettings + + /** @see retrieve */ + fun retrieve( + params: ApiKeySettingRetrieveParams = ApiKeySettingRetrieveParams.none() + ): OrganizationApiKeySettings = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(requestOptions: RequestOptions): OrganizationApiKeySettings = + retrieve(ApiKeySettingRetrieveParams.none(), requestOptions) + + /** + * Update which project-attached keys can be created. Requires organization.read and + * organization.write. Omitted key types retain their current policy. + */ + fun update(params: ApiKeySettingUpdateParams): OrganizationApiKeySettings = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ApiKeySettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationApiKeySettings + + /** + * A view of [ApiKeySettingService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ApiKeySettingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /organization/api_key_settings`, but is otherwise + * the same as [ApiKeySettingService.retrieve]. + */ + @MustBeClosed + fun retrieve(): HttpResponseFor = + retrieve(ApiKeySettingRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ApiKeySettingRetrieveParams = ApiKeySettingRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ApiKeySettingRetrieveParams = ApiKeySettingRetrieveParams.none() + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(requestOptions: RequestOptions): HttpResponseFor = + retrieve(ApiKeySettingRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /organization/api_key_settings`, but is otherwise + * the same as [ApiKeySettingService.update]. + */ + @MustBeClosed + fun update(params: ApiKeySettingUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ApiKeySettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingServiceImpl.kt new file mode 100644 index 000000000..d799989ac --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingServiceImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.blocking.admin.organization + +import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.SecurityOptions +import com.openai.core.handlers.errorBodyHandler +import com.openai.core.handlers.errorHandler +import com.openai.core.handlers.jsonHandler +import com.openai.core.http.HttpMethod +import com.openai.core.http.HttpRequest +import com.openai.core.http.HttpResponse +import com.openai.core.http.HttpResponse.Handler +import com.openai.core.http.HttpResponseFor +import com.openai.core.http.json +import com.openai.core.http.parseable +import com.openai.core.prepare +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingRetrieveParams +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingUpdateParams +import com.openai.models.admin.organization.apikeysettings.OrganizationApiKeySettings +import java.util.function.Consumer + +class ApiKeySettingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeySettingService { + + private val withRawResponse: ApiKeySettingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ApiKeySettingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ApiKeySettingService = + ApiKeySettingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ApiKeySettingRetrieveParams, + requestOptions: RequestOptions, + ): OrganizationApiKeySettings = + // get /organization/api_key_settings + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: ApiKeySettingUpdateParams, + requestOptions: RequestOptions, + ): OrganizationApiKeySettings = + // post /organization/api_key_settings + withRawResponse().update(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeySettingService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ApiKeySettingService.WithRawResponse = + ApiKeySettingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ApiKeySettingRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "api_key_settings") + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: ApiKeySettingUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "api_key_settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingService.kt new file mode 100644 index 000000000..176ae5f47 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingService.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.blocking.admin.organization + +import com.google.errorprone.annotations.MustBeClosed +import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.http.HttpResponseFor +import com.openai.models.admin.organization.servicetiersettings.OrganizationServiceTierSettings +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingRetrieveParams +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingUpdateParams +import java.util.function.Consumer + +interface ServiceTierSettingService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ServiceTierSettingService + + /** Retrieve the enabled tiers for the organization bound to the Admin API key. */ + fun retrieve(): OrganizationServiceTierSettings = + retrieve(ServiceTierSettingRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: ServiceTierSettingRetrieveParams = ServiceTierSettingRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationServiceTierSettings + + /** @see retrieve */ + fun retrieve( + params: ServiceTierSettingRetrieveParams = ServiceTierSettingRetrieveParams.none() + ): OrganizationServiceTierSettings = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(requestOptions: RequestOptions): OrganizationServiceTierSettings = + retrieve(ServiceTierSettingRetrieveParams.none(), requestOptions) + + /** + * Choose which service tiers requests in this organization can use. Requires organization.read + * and organization.write. See + * [`service_tier` in the Responses API](https://developers.openai.com/api/reference/resources/responses/methods/create). + */ + fun update(params: ServiceTierSettingUpdateParams): OrganizationServiceTierSettings = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ServiceTierSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationServiceTierSettings + + /** + * A view of [ServiceTierSettingService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ServiceTierSettingService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /organization/service_tier_settings`, but is + * otherwise the same as [ServiceTierSettingService.retrieve]. + */ + @MustBeClosed + fun retrieve(): HttpResponseFor = + retrieve(ServiceTierSettingRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ServiceTierSettingRetrieveParams = ServiceTierSettingRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ServiceTierSettingRetrieveParams = ServiceTierSettingRetrieveParams.none() + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + requestOptions: RequestOptions + ): HttpResponseFor = + retrieve(ServiceTierSettingRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /organization/service_tier_settings`, but is + * otherwise the same as [ServiceTierSettingService.update]. + */ + @MustBeClosed + fun update( + params: ServiceTierSettingUpdateParams + ): HttpResponseFor = update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ServiceTierSettingUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingServiceImpl.kt new file mode 100644 index 000000000..bcfc8c42b --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingServiceImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.blocking.admin.organization + +import com.openai.core.ClientOptions +import com.openai.core.RequestOptions +import com.openai.core.SecurityOptions +import com.openai.core.handlers.errorBodyHandler +import com.openai.core.handlers.errorHandler +import com.openai.core.handlers.jsonHandler +import com.openai.core.http.HttpMethod +import com.openai.core.http.HttpRequest +import com.openai.core.http.HttpResponse +import com.openai.core.http.HttpResponse.Handler +import com.openai.core.http.HttpResponseFor +import com.openai.core.http.json +import com.openai.core.http.parseable +import com.openai.core.prepare +import com.openai.models.admin.organization.servicetiersettings.OrganizationServiceTierSettings +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingRetrieveParams +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingUpdateParams +import java.util.function.Consumer + +class ServiceTierSettingServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceTierSettingService { + + private val withRawResponse: ServiceTierSettingService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ServiceTierSettingService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ServiceTierSettingService = + ServiceTierSettingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ServiceTierSettingRetrieveParams, + requestOptions: RequestOptions, + ): OrganizationServiceTierSettings = + // get /organization/service_tier_settings + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: ServiceTierSettingUpdateParams, + requestOptions: RequestOptions, + ): OrganizationServiceTierSettings = + // post /organization/service_tier_settings + withRawResponse().update(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ServiceTierSettingService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ServiceTierSettingService.WithRawResponse = + ServiceTierSettingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ServiceTierSettingRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "service_tier_settings") + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: ServiceTierSettingUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "service_tier_settings") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationProfileTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationProfileTest.kt new file mode 100644 index 000000000..895f15dc6 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationProfileTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrganizationProfileTest { + + @Test + fun createAndRoundtrip() { + val organizationProfile = + OrganizationProfile.builder() + .id("id") + .createdAt(0L) + .description("description") + .name("name") + .personal(true) + .title("title") + .build() + + assertThat(organizationProfile.id()).isEqualTo("id") + assertThat(organizationProfile.createdAt()).isEqualTo(0L) + assertThat(organizationProfile.description()).contains("description") + assertThat(organizationProfile.name()).contains("name") + assertThat(organizationProfile.personal()).isEqualTo(true) + assertThat(organizationProfile.title()).contains("title") + + val jsonMapper = jsonMapper() + + val roundtrippedOrganizationProfile = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationProfile), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationProfile).isEqualTo(organizationProfile) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationRetrieveParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationRetrieveParamsTest.kt new file mode 100644 index 000000000..9d02ac768 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationRetrieveParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization + +import org.junit.jupiter.api.Test + +internal class OrganizationRetrieveParamsTest { + + @Test + fun create() { + OrganizationRetrieveParams.builder().build() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationUpdateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationUpdateParamsTest.kt new file mode 100644 index 000000000..811b5609d --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationUpdateParamsTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrganizationUpdateParamsTest { + + @Test + fun create() { + OrganizationUpdateParams.builder() + .body( + OrganizationUpdateParams.Body.TitleUpdate.builder() + .title("x") + .description("description") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + OrganizationUpdateParams.builder() + .body( + OrganizationUpdateParams.Body.TitleUpdate.builder() + .title("x") + .description("description") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OrganizationUpdateParams.Body.ofTitleUpdate( + OrganizationUpdateParams.Body.TitleUpdate.builder() + .title("x") + .description("description") + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OrganizationUpdateParams.builder() + .body(OrganizationUpdateParams.Body.TitleUpdate.builder().title("x").build()) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OrganizationUpdateParams.Body.ofTitleUpdate( + OrganizationUpdateParams.Body.TitleUpdate.builder().title("x").build() + ) + ) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingRetrieveParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingRetrieveParamsTest.kt new file mode 100644 index 000000000..dbfd2b4bc --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingRetrieveParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.apikeysettings + +import org.junit.jupiter.api.Test + +internal class ApiKeySettingRetrieveParamsTest { + + @Test + fun create() { + ApiKeySettingRetrieveParams.builder().build() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingUpdateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingUpdateParamsTest.kt new file mode 100644 index 000000000..e5b3f32d6 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingUpdateParamsTest.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.apikeysettings + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiKeySettingUpdateParamsTest { + + @Test + fun create() { + ApiKeySettingUpdateParams.builder() + .creation( + ApiKeySettingUpdateParams.Creation.builder() + .serviceAccountKeys( + ApiKeySettingUpdateParams.Creation.ServiceAccountKeys.builder() + .allowed(true) + .build() + ) + .userOwnedProjectKeys( + ApiKeySettingUpdateParams.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ApiKeySettingUpdateParams.builder() + .creation( + ApiKeySettingUpdateParams.Creation.builder() + .serviceAccountKeys( + ApiKeySettingUpdateParams.Creation.ServiceAccountKeys.builder() + .allowed(true) + .build() + ) + .userOwnedProjectKeys( + ApiKeySettingUpdateParams.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.creation()) + .isEqualTo( + ApiKeySettingUpdateParams.Creation.builder() + .serviceAccountKeys( + ApiKeySettingUpdateParams.Creation.ServiceAccountKeys.builder() + .allowed(true) + .build() + ) + .userOwnedProjectKeys( + ApiKeySettingUpdateParams.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ApiKeySettingUpdateParams.builder() + .creation( + ApiKeySettingUpdateParams.Creation.builder() + .userOwnedProjectKeys( + ApiKeySettingUpdateParams.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.creation()) + .isEqualTo( + ApiKeySettingUpdateParams.Creation.builder() + .userOwnedProjectKeys( + ApiKeySettingUpdateParams.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/OrganizationApiKeySettingsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/OrganizationApiKeySettingsTest.kt new file mode 100644 index 000000000..442ac0feb --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/OrganizationApiKeySettingsTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.apikeysettings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrganizationApiKeySettingsTest { + + @Test + fun createAndRoundtrip() { + val organizationApiKeySettings = + OrganizationApiKeySettings.builder() + .creation( + OrganizationApiKeySettings.Creation.builder() + .serviceAccountKeys( + OrganizationApiKeySettings.Creation.ServiceAccountKeys.builder() + .allowed(true) + .build() + ) + .userOwnedProjectKeys( + OrganizationApiKeySettings.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + .build() + + assertThat(organizationApiKeySettings.creation()) + .contains( + OrganizationApiKeySettings.Creation.builder() + .serviceAccountKeys( + OrganizationApiKeySettings.Creation.ServiceAccountKeys.builder() + .allowed(true) + .build() + ) + .userOwnedProjectKeys( + OrganizationApiKeySettings.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + + val jsonMapper = jsonMapper() + + val roundtrippedOrganizationApiKeySettings = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationApiKeySettings), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationApiKeySettings).isEqualTo(organizationApiKeySettings) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/OrganizationServiceTierSettingsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/OrganizationServiceTierSettingsTest.kt new file mode 100644 index 000000000..a7b83aefb --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/OrganizationServiceTierSettingsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.servicetiersettings + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OrganizationServiceTierSettingsTest { + + @Test + fun createAndRoundtrip() { + val organizationServiceTierSettings = + OrganizationServiceTierSettings.builder().enabledTiersAll().build() + + assertThat(organizationServiceTierSettings.enabledTiers()) + .isEqualTo(OrganizationServiceTierSettings.EnabledTiers.ofAll()) + + val jsonMapper = jsonMapper() + + val roundtrippedOrganizationServiceTierSettings = + jsonMapper.readValue( + jsonMapper.writeValueAsString(organizationServiceTierSettings), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOrganizationServiceTierSettings) + .isEqualTo(organizationServiceTierSettings) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingRetrieveParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingRetrieveParamsTest.kt new file mode 100644 index 000000000..6b93702ca --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingRetrieveParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.servicetiersettings + +import org.junit.jupiter.api.Test + +internal class ServiceTierSettingRetrieveParamsTest { + + @Test + fun create() { + ServiceTierSettingRetrieveParams.builder().build() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingUpdateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingUpdateParamsTest.kt new file mode 100644 index 000000000..f30b32bca --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingUpdateParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.models.admin.organization.servicetiersettings + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServiceTierSettingUpdateParamsTest { + + @Test + fun create() { + ServiceTierSettingUpdateParams.builder().enabledTiersAll().build() + } + + @Test + fun body() { + val params = ServiceTierSettingUpdateParams.builder().enabledTiersAll().build() + + val body = params._body() + + assertThat(body.enabledTiers()) + .isEqualTo(ServiceTierSettingUpdateParams.EnabledTiers.ofAll()) + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncTest.kt new file mode 100644 index 000000000..554bcd078 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.async.admin + +import com.openai.TestServerExtension +import com.openai.client.okhttp.OpenAIOkHttpClientAsync +import com.openai.models.admin.organization.OrganizationUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OrganizationServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val organizationServiceAsync = client.admin().organization() + + val organizationProfileFuture = organizationServiceAsync.retrieve() + + val organizationProfile = organizationProfileFuture.get() + organizationProfile.validate() + } + + @Test + fun update() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val organizationServiceAsync = client.admin().organization() + + val organizationProfileFuture = + organizationServiceAsync.update( + OrganizationUpdateParams.Body.ofTitleUpdate( + OrganizationUpdateParams.Body.TitleUpdate.builder() + .title("x") + .description("description") + .build() + ) + ) + + val organizationProfile = organizationProfileFuture.get() + organizationProfile.validate() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsyncTest.kt new file mode 100644 index 000000000..f2f07c5f0 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsyncTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.async.admin.organization + +import com.openai.TestServerExtension +import com.openai.client.okhttp.OpenAIOkHttpClientAsync +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ApiKeySettingServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val apiKeySettingServiceAsync = client.admin().organization().apiKeySettings() + + val organizationApiKeySettingsFuture = apiKeySettingServiceAsync.retrieve() + + val organizationApiKeySettings = organizationApiKeySettingsFuture.get() + organizationApiKeySettings.validate() + } + + @Test + fun update() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val apiKeySettingServiceAsync = client.admin().organization().apiKeySettings() + + val organizationApiKeySettingsFuture = + apiKeySettingServiceAsync.update( + ApiKeySettingUpdateParams.builder() + .creation( + ApiKeySettingUpdateParams.Creation.builder() + .serviceAccountKeys( + ApiKeySettingUpdateParams.Creation.ServiceAccountKeys.builder() + .allowed(true) + .build() + ) + .userOwnedProjectKeys( + ApiKeySettingUpdateParams.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + .build() + ) + + val organizationApiKeySettings = organizationApiKeySettingsFuture.get() + organizationApiKeySettings.validate() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsyncTest.kt new file mode 100644 index 000000000..9a0995013 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsyncTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.async.admin.organization + +import com.openai.TestServerExtension +import com.openai.client.okhttp.OpenAIOkHttpClientAsync +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ServiceTierSettingServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val serviceTierSettingServiceAsync = client.admin().organization().serviceTierSettings() + + val organizationServiceTierSettingsFuture = serviceTierSettingServiceAsync.retrieve() + + val organizationServiceTierSettings = organizationServiceTierSettingsFuture.get() + organizationServiceTierSettings.validate() + } + + @Test + fun update() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val serviceTierSettingServiceAsync = client.admin().organization().serviceTierSettings() + + val organizationServiceTierSettingsFuture = + serviceTierSettingServiceAsync.update( + ServiceTierSettingUpdateParams.builder().enabledTiersAll().build() + ) + + val organizationServiceTierSettings = organizationServiceTierSettingsFuture.get() + organizationServiceTierSettings.validate() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/OrganizationServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/OrganizationServiceTest.kt new file mode 100644 index 000000000..3d2fd69e5 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/OrganizationServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.blocking.admin + +import com.openai.TestServerExtension +import com.openai.client.okhttp.OpenAIOkHttpClient +import com.openai.models.admin.organization.OrganizationUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OrganizationServiceTest { + + @Test + fun retrieve() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val organizationService = client.admin().organization() + + val organizationProfile = organizationService.retrieve() + + organizationProfile.validate() + } + + @Test + fun update() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val organizationService = client.admin().organization() + + val organizationProfile = + organizationService.update( + OrganizationUpdateParams.Body.ofTitleUpdate( + OrganizationUpdateParams.Body.TitleUpdate.builder() + .title("x") + .description("description") + .build() + ) + ) + + organizationProfile.validate() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingServiceTest.kt new file mode 100644 index 000000000..2f8826d99 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingServiceTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.blocking.admin.organization + +import com.openai.TestServerExtension +import com.openai.client.okhttp.OpenAIOkHttpClient +import com.openai.models.admin.organization.apikeysettings.ApiKeySettingUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ApiKeySettingServiceTest { + + @Test + fun retrieve() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val apiKeySettingService = client.admin().organization().apiKeySettings() + + val organizationApiKeySettings = apiKeySettingService.retrieve() + + organizationApiKeySettings.validate() + } + + @Test + fun update() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val apiKeySettingService = client.admin().organization().apiKeySettings() + + val organizationApiKeySettings = + apiKeySettingService.update( + ApiKeySettingUpdateParams.builder() + .creation( + ApiKeySettingUpdateParams.Creation.builder() + .serviceAccountKeys( + ApiKeySettingUpdateParams.Creation.ServiceAccountKeys.builder() + .allowed(true) + .build() + ) + .userOwnedProjectKeys( + ApiKeySettingUpdateParams.Creation.UserOwnedProjectKeys.builder() + .allowed(true) + .build() + ) + .build() + ) + .build() + ) + + organizationApiKeySettings.validate() + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingServiceTest.kt new file mode 100644 index 000000000..5747f3cdc --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingServiceTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +package com.openai.services.blocking.admin.organization + +import com.openai.TestServerExtension +import com.openai.client.okhttp.OpenAIOkHttpClient +import com.openai.models.admin.organization.servicetiersettings.ServiceTierSettingUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ServiceTierSettingServiceTest { + + @Test + fun retrieve() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val serviceTierSettingService = client.admin().organization().serviceTierSettings() + + val organizationServiceTierSettings = serviceTierSettingService.retrieve() + + organizationServiceTierSettings.validate() + } + + @Test + fun update() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val serviceTierSettingService = client.admin().organization().serviceTierSettings() + + val organizationServiceTierSettings = + serviceTierSettingService.update( + ServiceTierSettingUpdateParams.builder().enabledTiersAll().build() + ) + + organizationServiceTierSettings.validate() + } +} diff --git a/scripts/castiron/generated-files.json b/scripts/castiron/generated-files.json index 3de29958e..60f53af52 100644 --- a/scripts/castiron/generated-files.json +++ b/scripts/castiron/generated-files.json @@ -117,6 +117,18 @@ "mode": "100644", "sha256": "d639a2f26b16dfb6770a4c4e9ec5003eca4960164fdbd708204403f6134d3145" }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationProfile.kt": { + "mode": "100644", + "sha256": "b5c911053cf62f83770c1685253243c3bcdf50d518ec9eac4796136a802a6c57" + }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationRetrieveParams.kt": { + "mode": "100644", + "sha256": "f6db04bce9a9a34f480ed895919464c0f110403d664519cda2054b4cd0baa3c7" + }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/OrganizationUpdateParams.kt": { + "mode": "100644", + "sha256": "a1e867615e8d1b914f1cd8e191f5c29681f751300205a9fa305fa43a43136ce1" + }, "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKey.kt": { "mode": "100644", "sha256": "54246e124828595b8b0baa8a72a1058a4c766650cac2f80ba474adba255b7ff1" @@ -157,6 +169,18 @@ "mode": "100644", "sha256": "1ee7fd865c08455d98a4d1870894473516909e6ce9034f097847f625e9f630a1" }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingRetrieveParams.kt": { + "mode": "100644", + "sha256": "e8aff05738f2c925ffb6c5de7db7c534c90c397795680c9838d5fececce4da26" + }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingUpdateParams.kt": { + "mode": "100644", + "sha256": "5161c21e3baca612093169514fad3bb8fcf73fcb7c1963d639d82fbf947b73af" + }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/apikeysettings/OrganizationApiKeySettings.kt": { + "mode": "100644", + "sha256": "795072db96a05b978a56bc69059cda77c2c1c7f437586b368fe438b55aca1ea3" + }, "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPage.kt": { "mode": "100644", "sha256": "747b499a0be8658a3b3b0d06be844ccbab6838cc084b8f50e7ab8227386964ac" @@ -1197,6 +1221,18 @@ "mode": "100644", "sha256": "32800f080347cd26422aef27b2041c1c558079be952354cfa7f754de12f56cae" }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/OrganizationServiceTierSettings.kt": { + "mode": "100644", + "sha256": "05867880565298ed927dac9687b82943438e22f9ccf4785c911f858e4d4e5bd5" + }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingRetrieveParams.kt": { + "mode": "100644", + "sha256": "1d0aab2381d4f1553395e640c0ef898f262cfd1c539a59dfea3f68c5fcac6072" + }, + "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingUpdateParams.kt": { + "mode": "100644", + "sha256": "ecc5cde298dc690b12400c3417543f5b26f96990be2df0c4a50d60be15ead28f" + }, "openai-java-core/src/main/kotlin/com/openai/models/admin/organization/spendalerts/OrganizationSpendAlert.kt": { "mode": "100644", "sha256": "adb4c9d6ab3710ea54629422a844222defae97f254587fc948885d7e9dd228f7" @@ -7247,11 +7283,11 @@ }, "openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsync.kt": { "mode": "100644", - "sha256": "134defddb61fbd2041a8d4d95d9eddfb57a4c9caa98b08538366b999b3aa4ea2" + "sha256": "16e840686cf73f83c4c1c7808e1fa3d1c2b48b06d12aa92465310452ac95859f" }, "openai-java-core/src/main/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncImpl.kt": { "mode": "100644", - "sha256": "8b3828b27fd9d2585939ced06621a3e78065c6af1984b2e2307f9c3f79765311" + "sha256": "86db5d210f77a6867d29d333b0b240ccf6243875141b6e66b6f8cb51f991e58f" }, "openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/AdminApiKeyServiceAsync.kt": { "mode": "100644", @@ -7261,6 +7297,14 @@ "mode": "100644", "sha256": "8afe79fc66d9690dac3f780a4edbb65d5b306ca311acdf5a5b0cf1773b631627" }, + "openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsync.kt": { + "mode": "100644", + "sha256": "b3596de30f43994f6251caf339ff71343cf9748155890e8a7cb909cbbf0b8080" + }, + "openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsyncImpl.kt": { + "mode": "100644", + "sha256": "d3b506438864aecbfe9111dfedecf87f61c2a33b0f6a4e537ce65acc3829d7d4" + }, "openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/AuditLogServiceAsync.kt": { "mode": "100644", "sha256": "fd1aaf4ffd522f6872ffc26e07f673a2988e96d4a917abf58dc78967ce1d6cd4" @@ -7341,6 +7385,14 @@ "mode": "100644", "sha256": "db40a6e6949f59660fcbc943a3705e55fa617d931d0c2d1bfc4e38da380fee90" }, + "openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsync.kt": { + "mode": "100644", + "sha256": "4f15939073672b64a09abac973b5974edefd9cf08299eec01cd93c5133b0bac7" + }, + "openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsyncImpl.kt": { + "mode": "100644", + "sha256": "657322aad5eea864524eafad3c4b5854cd88fa05a0f4c952e41b906fc76dfd97" + }, "openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsync.kt": { "mode": "100644", "sha256": "f1b827b860bedde604ae52ea10d2452c4ba998c906717644472c4658460a300d" @@ -8343,11 +8395,11 @@ }, "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationService.kt": { "mode": "100644", - "sha256": "8b5b6761e29caaf83795b5e9705d839f2b494cc23c3a00d777dec49e1474dc30" + "sha256": "1e9d8c3ef64a33e234ceef631a35fd4d2ba8c6ba968b4ced10605215fb943056" }, "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/OrganizationServiceImpl.kt": { "mode": "100644", - "sha256": "57c4c43a17dd134ef816690f78357aec48b622300990db0b129c10eed81f6a2d" + "sha256": "fde96321e4b26de488885089833c6751b9ed19a1b50ca34e98922d6f08e4e6bb" }, "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/AdminApiKeyService.kt": { "mode": "100644", @@ -8357,6 +8409,14 @@ "mode": "100644", "sha256": "6cf4c376e1a763e2b066e4210024048a14addde7eff2cf8724c801bf41dc707b" }, + "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingService.kt": { + "mode": "100644", + "sha256": "ced6e7dfca2e95aa73c38a9aedd3b4a8e4beff7bcf74422c423159f4ea8cf3b6" + }, + "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingServiceImpl.kt": { + "mode": "100644", + "sha256": "605ed041c11e3e33d9c17e181dca7242550a07e437b2b4d5eac01f165449fc79" + }, "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/AuditLogService.kt": { "mode": "100644", "sha256": "522e319b8fc7d78ca5d114952c0f79ec1282e83818724fb3276a570822b77cca" @@ -8437,6 +8497,14 @@ "mode": "100644", "sha256": "62ab0f2a07c1418b037d0b425fff41b7fc66923e826db7d67d72ff5d789dc22d" }, + "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingService.kt": { + "mode": "100644", + "sha256": "883758a6bf43fd59df5c4021b4a0e1294159b2397ef3fac4c2d36990f13808b2" + }, + "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingServiceImpl.kt": { + "mode": "100644", + "sha256": "e5e0cd2b45bfa1ced69dae60178463d9d1678421f0acd3dda710070b5199732a" + }, "openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertService.kt": { "mode": "100644", "sha256": "444f00226c4143a426d32c46a3fc29b4f5a159956875ebe7e01e8924860381b6" @@ -9305,6 +9373,18 @@ "mode": "100644", "sha256": "cd8deeb52ffd9489cce8367ae3bd1aecef953d15eec6a403192bebd13a5e0b6f" }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationProfileTest.kt": { + "mode": "100644", + "sha256": "0dc49e782f39f2fe835f4ceb16e390a70663589cc84174570a994597deeaa50f" + }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationRetrieveParamsTest.kt": { + "mode": "100644", + "sha256": "a52c59229e37010c9f141f10447be7bd62df16bee47101f0d2530ede977a4808" + }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/OrganizationUpdateParamsTest.kt": { + "mode": "100644", + "sha256": "f0b2766b2d3cfb2232e8a4081f739c9d0049c19d5df82534dff533ff4575046b" + }, "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParamsTest.kt": { "mode": "100644", "sha256": "01445d9c6864018424ec1d7106eb0df6e1810e0c4f4a472b8e88ed7e3f2e517f" @@ -9337,6 +9417,18 @@ "mode": "100644", "sha256": "c7c7430b79fc6c4d4606726eaad647793b69420cad28b25dcd73625400173e53" }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingRetrieveParamsTest.kt": { + "mode": "100644", + "sha256": "d901699fb911124c89353f8db9d8456a1da38e0651b92d70dce0d40806a93ff4" + }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/ApiKeySettingUpdateParamsTest.kt": { + "mode": "100644", + "sha256": "2fc437ec6ee497c2f9ab91f4a8301d94056ee1659cb875170292c60074a2cc9b" + }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/apikeysettings/OrganizationApiKeySettingsTest.kt": { + "mode": "100644", + "sha256": "485aacc149dd7d34f30d371759bd0e44f5c45b019b79080f213a76fbab8aa332" + }, "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponseTest.kt": { "mode": "100644", "sha256": "66fb8c1cebfca9cf3d32d89a3411931f5d9d94549fba429a7b51279627fe4da0" @@ -10161,6 +10253,18 @@ "mode": "100644", "sha256": "22d0ed107724efe7384105cadb4819afd90cb112922b8b6f6fdac068ab7f9aab" }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/OrganizationServiceTierSettingsTest.kt": { + "mode": "100644", + "sha256": "cb254dabb19693433cf67259cd982e93351518304745215bf7a055e463fe97cc" + }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingRetrieveParamsTest.kt": { + "mode": "100644", + "sha256": "7d092bbbba900c7ce8ab820fe38f3cdb6d1148f4a819bd18235ca9f1dd6fb6ae" + }, + "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/servicetiersettings/ServiceTierSettingUpdateParamsTest.kt": { + "mode": "100644", + "sha256": "01d4f9bd9e10bd66a0b67d16e973a4765acf4a7e36b2df70a78cd3d0b84c63e9" + }, "openai-java-core/src/test/kotlin/com/openai/models/admin/organization/spendalerts/OrganizationSpendAlertDeletedTest.kt": { "mode": "100644", "sha256": "aa3f6854ff0c7464bbaba3113818b2e02575369c4e7a1a0910651aaa226b073d" @@ -15493,6 +15597,10 @@ "mode": "100644", "sha256": "e024d6c08a6bc313daaab7cf291407bbba830514b055fa66cced01ee0447085c" }, + "openai-java-core/src/test/kotlin/com/openai/services/async/admin/OrganizationServiceAsyncTest.kt": { + "mode": "100644", + "sha256": "7c90ae67721b56e23b99d587ae9fa5080b0257adfae46305d057e71c71a37639" + }, "openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/AdminApiKeyServiceAsyncPaginationContractTest.kt": { "mode": "100644", "sha256": "e3ba21f0f8cdce8c16e257c57baa4f8de51298a90ecbc131d4c5c8d3784f9f15" @@ -15501,6 +15609,10 @@ "mode": "100644", "sha256": "d6f59685993352a2665eecbf6d42a58a227f138d743f8f5cd6c78ce398cc5583" }, + "openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/ApiKeySettingServiceAsyncTest.kt": { + "mode": "100644", + "sha256": "284ea52077095e7696af2f71c6c6262b365b8a63fd02051bf15c9e36f4045541" + }, "openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/AuditLogServiceAsyncPaginationContractTest.kt": { "mode": "100644", "sha256": "b2b39cdec4abe0058284bfda6c77c92ecdd278aaf43001d62b6aa93cdca0752a" @@ -15569,6 +15681,10 @@ "mode": "100644", "sha256": "d2b5601f21ee3c9fb25118302af7106b0f10aaac3b1a3d2e2db0db0b05efccaa" }, + "openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/ServiceTierSettingServiceAsyncTest.kt": { + "mode": "100644", + "sha256": "d87a0c138df435f7bd195766ac71632575053d6f666e09e65813689bb4151715" + }, "openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncPaginationContractTest.kt": { "mode": "100644", "sha256": "2bfaa10f25dea972ac9435f92b309fab1cd441c4b128e3f8df0320b6ffebefa8" @@ -16293,6 +16409,10 @@ "mode": "100644", "sha256": "3ea469da4565f1164e846c36f7d9e52b452d7ca601aa063914beb9c1df82cd81" }, + "openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/OrganizationServiceTest.kt": { + "mode": "100644", + "sha256": "f517a137daf50856b265d50ba108566d6a3ac1ec77da04e88f87f7035a5ecf3f" + }, "openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/AdminApiKeyServicePaginationContractTest.kt": { "mode": "100644", "sha256": "ee2890cfb3f18e6f19e8d2c966b406f88fef5e31f60cb91050d68f21195e9e1d" @@ -16301,6 +16421,10 @@ "mode": "100644", "sha256": "b5845ff192fda71daf6034f3b536afaf4eb1a40d4e4468b5022a2b3935bd43a3" }, + "openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/ApiKeySettingServiceTest.kt": { + "mode": "100644", + "sha256": "44b3916c263038cf040dd3b70bae1f65c7930bc2e40e4e1695d5783e49cd0100" + }, "openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/AuditLogServicePaginationContractTest.kt": { "mode": "100644", "sha256": "dd000a03df34813ebfa08f1e1ff793a051c17fcddb660b7be6f6f580144c8724" @@ -16369,6 +16493,10 @@ "mode": "100644", "sha256": "f62c77f553154d014012ed3b6745d358fa9f39bf55aaa464155161ef4345423c" }, + "openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/ServiceTierSettingServiceTest.kt": { + "mode": "100644", + "sha256": "3acb2b6b08ce1787c2a591c110d9fc368ccfda34f2ba048c5c6a85dac84bb420" + }, "openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServicePaginationContractTest.kt": { "mode": "100644", "sha256": "2509e466a132ebf7f188b3b08908905e82ff0e67a1b2904906efe1ed800f579e"