From 60839f138e39650feae484f3a54355ab60d1081e Mon Sep 17 00:00:00 2001 From: courier-codegen Date: Thu, 24 Sep 2026 17:24:53 +0000 Subject: [PATCH] [C-21018] Add GET /preferences/logs to the API spec --- .stats.yml | 2 +- .../PreferenceChangeLogEntry.kt | 588 ++++++++++++++++++ .../PreferenceChangeLogValue.kt | 294 +++++++++ .../PreferenceLogsListResponse.kt | 237 +++++++ .../WorkspacePreferenceListLogsParams.kt | 297 +++++++++ .../async/WorkspacePreferenceServiceAsync.kt | 51 ++ .../WorkspacePreferenceServiceAsyncImpl.kt | 39 ++ .../blocking/WorkspacePreferenceService.kt | 51 ++ .../WorkspacePreferenceServiceImpl.kt | 36 ++ .../PreferenceChangeLogEntryTest.kt | 87 +++ .../PreferenceChangeLogValueTest.kt | 47 ++ .../PreferenceLogsListResponseTest.kt | 103 +++ .../WorkspacePreferenceListLogsParamsTest.kt | 55 ++ .../WorkspacePreferenceServiceAsyncTest.kt | 22 + .../WorkspacePreferenceServiceTest.kt | 21 + 15 files changed, 1929 insertions(+), 1 deletion(-) create mode 100644 courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogEntry.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogValue.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceLogsListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/WorkspacePreferenceListLogsParams.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogEntryTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogValueTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceLogsListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/WorkspacePreferenceListLogsParamsTest.kt diff --git a/.stats.yml b/.stats.yml index 64079606..5fe5772a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 157 +configured_endpoints: 158 diff --git a/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogEntry.kt b/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogEntry.kt new file mode 100644 index 00000000..cf7b8a4c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogEntry.kt @@ -0,0 +1,588 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.models.workspacepreferences + +import com.courier.core.ExcludeMissing +import com.courier.core.JsonField +import com.courier.core.JsonMissing +import com.courier.core.JsonValue +import com.courier.core.checkKnown +import com.courier.core.checkRequired +import com.courier.core.toImmutable +import com.courier.errors.CourierInvalidDataException +import com.courier.models.ChannelClassification +import com.courier.models.PreferenceStatus +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 java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PreferenceChangeLogEntry +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val customRouting: JsonField>, + private val hasCustomRouting: JsonField, + private val status: JsonField, + private val timestamp: JsonField, + private val topicId: JsonField, + private val topicName: JsonField, + private val userId: JsonField, + private val previous: JsonField, + private val tenantId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("custom_routing") + @ExcludeMissing + customRouting: JsonField> = JsonMissing.of(), + @JsonProperty("has_custom_routing") + @ExcludeMissing + hasCustomRouting: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("timestamp") @ExcludeMissing timestamp: JsonField = JsonMissing.of(), + @JsonProperty("topic_id") @ExcludeMissing topicId: JsonField = JsonMissing.of(), + @JsonProperty("topic_name") @ExcludeMissing topicName: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + @JsonProperty("previous") + @ExcludeMissing + previous: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + ) : this( + id, + customRouting, + hasCustomRouting, + status, + timestamp, + topicId, + topicName, + userId, + previous, + tenantId, + mutableMapOf(), + ) + + /** + * Unique identifier for this change. + * + * @throws CourierInvalidDataException 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") + + /** + * The channels chosen for this topic, present only when has_custom_routing is true. Empty + * otherwise. + * + * @throws CourierInvalidDataException 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 customRouting(): List = customRouting.getRequired("custom_routing") + + /** + * Whether specific delivery channels were chosen for this topic rather than the topic's default + * routing. + * + * @throws CourierInvalidDataException 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 hasCustomRouting(): Boolean = hasCustomRouting.getRequired("has_custom_routing") + + /** + * The subscription status the change set. + * + * @throws CourierInvalidDataException 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 status(): PreferenceStatus = status.getRequired("status") + + /** + * When the change was made, as an ISO-8601 date-time in UTC. + * + * @throws CourierInvalidDataException 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 timestamp(): String = timestamp.getRequired("timestamp") + + /** + * The subscription topic the change applies to. + * + * @throws CourierInvalidDataException 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 topicId(): String = topicId.getRequired("topic_id") + + /** + * The display name of that topic when the change was made. + * + * @throws CourierInvalidDataException 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 topicName(): String = topicName.getRequired("topic_name") + + /** + * The user whose preference changed. + * + * @throws CourierInvalidDataException 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 userId(): String = userId.getRequired("user_id") + + /** + * The value before this change, where it was recorded. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previous(): Optional = previous.getOptional("previous") + + /** + * The tenant context the change was made in. Absent when the user set the preference outside + * any tenant. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tenantId(): Optional = tenantId.getOptional("tenant_id") + + /** + * 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 [customRouting]. + * + * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("custom_routing") + @ExcludeMissing + fun _customRouting(): JsonField> = customRouting + + /** + * Returns the raw JSON value of [hasCustomRouting]. + * + * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("has_custom_routing") + @ExcludeMissing + fun _hasCustomRouting(): JsonField = hasCustomRouting + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [timestamp]. + * + * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timestamp") @ExcludeMissing fun _timestamp(): JsonField = timestamp + + /** + * Returns the raw JSON value of [topicId]. + * + * Unlike [topicId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topic_id") @ExcludeMissing fun _topicId(): JsonField = topicId + + /** + * Returns the raw JSON value of [topicName]. + * + * Unlike [topicName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topic_name") @ExcludeMissing fun _topicName(): JsonField = topicName + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + /** + * Returns the raw JSON value of [previous]. + * + * Unlike [previous], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("previous") + @ExcludeMissing + fun _previous(): JsonField = previous + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PreferenceChangeLogEntry]. + * + * The following fields are required: + * ```java + * .id() + * .customRouting() + * .hasCustomRouting() + * .status() + * .timestamp() + * .topicId() + * .topicName() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceChangeLogEntry]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var customRouting: JsonField>? = null + private var hasCustomRouting: JsonField? = null + private var status: JsonField? = null + private var timestamp: JsonField? = null + private var topicId: JsonField? = null + private var topicName: JsonField? = null + private var userId: JsonField? = null + private var previous: JsonField = JsonMissing.of() + private var tenantId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preferenceChangeLogEntry: PreferenceChangeLogEntry) = apply { + id = preferenceChangeLogEntry.id + customRouting = preferenceChangeLogEntry.customRouting.map { it.toMutableList() } + hasCustomRouting = preferenceChangeLogEntry.hasCustomRouting + status = preferenceChangeLogEntry.status + timestamp = preferenceChangeLogEntry.timestamp + topicId = preferenceChangeLogEntry.topicId + topicName = preferenceChangeLogEntry.topicName + userId = preferenceChangeLogEntry.userId + previous = preferenceChangeLogEntry.previous + tenantId = preferenceChangeLogEntry.tenantId + additionalProperties = preferenceChangeLogEntry.additionalProperties.toMutableMap() + } + + /** Unique identifier for this change. */ + 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 } + + /** + * The channels chosen for this topic, present only when has_custom_routing is true. Empty + * otherwise. + */ + fun customRouting(customRouting: List) = + customRouting(JsonField.of(customRouting)) + + /** + * Sets [Builder.customRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.customRouting] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customRouting(customRouting: JsonField>) = apply { + this.customRouting = customRouting.map { it.toMutableList() } + } + + /** + * Adds a single [ChannelClassification] to [Builder.customRouting]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomRouting(customRouting: ChannelClassification) = apply { + this.customRouting = + (this.customRouting ?: JsonField.of(mutableListOf())).also { + checkKnown("customRouting", it).add(customRouting) + } + } + + /** + * Whether specific delivery channels were chosen for this topic rather than the topic's + * default routing. + */ + fun hasCustomRouting(hasCustomRouting: Boolean) = + hasCustomRouting(JsonField.of(hasCustomRouting)) + + /** + * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hasCustomRouting(hasCustomRouting: JsonField) = apply { + this.hasCustomRouting = hasCustomRouting + } + + /** The subscription status the change set. */ + fun status(status: PreferenceStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [PreferenceStatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** When the change was made, as an ISO-8601 date-time in UTC. */ + fun timestamp(timestamp: String) = timestamp(JsonField.of(timestamp)) + + /** + * Sets [Builder.timestamp] to an arbitrary JSON value. + * + * You should usually call [Builder.timestamp] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun timestamp(timestamp: JsonField) = apply { this.timestamp = timestamp } + + /** The subscription topic the change applies to. */ + fun topicId(topicId: String) = topicId(JsonField.of(topicId)) + + /** + * Sets [Builder.topicId] to an arbitrary JSON value. + * + * You should usually call [Builder.topicId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun topicId(topicId: JsonField) = apply { this.topicId = topicId } + + /** The display name of that topic when the change was made. */ + fun topicName(topicName: String) = topicName(JsonField.of(topicName)) + + /** + * Sets [Builder.topicName] to an arbitrary JSON value. + * + * You should usually call [Builder.topicName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topicName(topicName: JsonField) = apply { this.topicName = topicName } + + /** The user whose preference changed. */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** The value before this change, where it was recorded. */ + fun previous(previous: PreferenceChangeLogValue) = previous(JsonField.of(previous)) + + /** + * Sets [Builder.previous] to an arbitrary JSON value. + * + * You should usually call [Builder.previous] with a well-typed [PreferenceChangeLogValue] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun previous(previous: JsonField) = apply { + this.previous = previous + } + + /** + * The tenant context the change was made in. Absent when the user set the preference + * outside any tenant. + */ + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + 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 [PreferenceChangeLogEntry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .customRouting() + * .hasCustomRouting() + * .status() + * .timestamp() + * .topicId() + * .topicName() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PreferenceChangeLogEntry = + PreferenceChangeLogEntry( + checkRequired("id", id), + checkRequired("customRouting", customRouting).map { it.toImmutable() }, + checkRequired("hasCustomRouting", hasCustomRouting), + checkRequired("status", status), + checkRequired("timestamp", timestamp), + checkRequired("topicId", topicId), + checkRequired("topicName", topicName), + checkRequired("userId", userId), + previous, + tenantId, + 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 CourierInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PreferenceChangeLogEntry = apply { + if (validated) { + return@apply + } + + id() + customRouting().forEach { it.validate() } + hasCustomRouting() + status().validate() + timestamp() + topicId() + topicName() + userId() + previous().ifPresent { it.validate() } + tenantId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + 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) + + (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasCustomRouting.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (topicId.asKnown().isPresent) 1 else 0) + + (if (topicName.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (previous.asKnown().getOrNull()?.validity() ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceChangeLogEntry && + id == other.id && + customRouting == other.customRouting && + hasCustomRouting == other.hasCustomRouting && + status == other.status && + timestamp == other.timestamp && + topicId == other.topicId && + topicName == other.topicName && + userId == other.userId && + previous == other.previous && + tenantId == other.tenantId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + customRouting, + hasCustomRouting, + status, + timestamp, + topicId, + topicName, + userId, + previous, + tenantId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PreferenceChangeLogEntry{id=$id, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, status=$status, timestamp=$timestamp, topicId=$topicId, topicName=$topicName, userId=$userId, previous=$previous, tenantId=$tenantId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogValue.kt b/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogValue.kt new file mode 100644 index 00000000..15bdb558 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogValue.kt @@ -0,0 +1,294 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.models.workspacepreferences + +import com.courier.core.ExcludeMissing +import com.courier.core.JsonField +import com.courier.core.JsonMissing +import com.courier.core.JsonValue +import com.courier.core.checkKnown +import com.courier.core.checkRequired +import com.courier.core.toImmutable +import com.courier.errors.CourierInvalidDataException +import com.courier.models.ChannelClassification +import com.courier.models.PreferenceStatus +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 java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class PreferenceChangeLogValue +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val customRouting: JsonField>, + private val hasCustomRouting: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("custom_routing") + @ExcludeMissing + customRouting: JsonField> = JsonMissing.of(), + @JsonProperty("has_custom_routing") + @ExcludeMissing + hasCustomRouting: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + ) : this(customRouting, hasCustomRouting, status, mutableMapOf()) + + /** + * The channels chosen before the change. + * + * @throws CourierInvalidDataException 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 customRouting(): List = customRouting.getRequired("custom_routing") + + /** + * Whether custom routing was in effect before the change. + * + * @throws CourierInvalidDataException 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 hasCustomRouting(): Boolean = hasCustomRouting.getRequired("has_custom_routing") + + /** + * The subscription status before the change. + * + * @throws CourierInvalidDataException 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 status(): PreferenceStatus = status.getRequired("status") + + /** + * Returns the raw JSON value of [customRouting]. + * + * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("custom_routing") + @ExcludeMissing + fun _customRouting(): JsonField> = customRouting + + /** + * Returns the raw JSON value of [hasCustomRouting]. + * + * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("has_custom_routing") + @ExcludeMissing + fun _hasCustomRouting(): JsonField = hasCustomRouting + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PreferenceChangeLogValue]. + * + * The following fields are required: + * ```java + * .customRouting() + * .hasCustomRouting() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceChangeLogValue]. */ + class Builder internal constructor() { + + private var customRouting: JsonField>? = null + private var hasCustomRouting: JsonField? = null + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preferenceChangeLogValue: PreferenceChangeLogValue) = apply { + customRouting = preferenceChangeLogValue.customRouting.map { it.toMutableList() } + hasCustomRouting = preferenceChangeLogValue.hasCustomRouting + status = preferenceChangeLogValue.status + additionalProperties = preferenceChangeLogValue.additionalProperties.toMutableMap() + } + + /** The channels chosen before the change. */ + fun customRouting(customRouting: List) = + customRouting(JsonField.of(customRouting)) + + /** + * Sets [Builder.customRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.customRouting] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customRouting(customRouting: JsonField>) = apply { + this.customRouting = customRouting.map { it.toMutableList() } + } + + /** + * Adds a single [ChannelClassification] to [Builder.customRouting]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomRouting(customRouting: ChannelClassification) = apply { + this.customRouting = + (this.customRouting ?: JsonField.of(mutableListOf())).also { + checkKnown("customRouting", it).add(customRouting) + } + } + + /** Whether custom routing was in effect before the change. */ + fun hasCustomRouting(hasCustomRouting: Boolean) = + hasCustomRouting(JsonField.of(hasCustomRouting)) + + /** + * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hasCustomRouting(hasCustomRouting: JsonField) = apply { + this.hasCustomRouting = hasCustomRouting + } + + /** The subscription status before the change. */ + fun status(status: PreferenceStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [PreferenceStatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + 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 [PreferenceChangeLogValue]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customRouting() + * .hasCustomRouting() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PreferenceChangeLogValue = + PreferenceChangeLogValue( + checkRequired("customRouting", customRouting).map { it.toImmutable() }, + checkRequired("hasCustomRouting", hasCustomRouting), + checkRequired("status", status), + 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 CourierInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PreferenceChangeLogValue = apply { + if (validated) { + return@apply + } + + customRouting().forEach { it.validate() } + hasCustomRouting() + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + 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 = + (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasCustomRouting.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceChangeLogValue && + customRouting == other.customRouting && + hasCustomRouting == other.hasCustomRouting && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customRouting, hasCustomRouting, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PreferenceChangeLogValue{customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceLogsListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceLogsListResponse.kt new file mode 100644 index 00000000..516e69de --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/PreferenceLogsListResponse.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.models.workspacepreferences + +import com.courier.core.ExcludeMissing +import com.courier.core.JsonField +import com.courier.core.JsonMissing +import com.courier.core.JsonValue +import com.courier.core.checkKnown +import com.courier.core.checkRequired +import com.courier.core.toImmutable +import com.courier.errors.CourierInvalidDataException +import com.courier.models.Paging +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 java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class PreferenceLogsListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") + @ExcludeMissing + items: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(items, paging, mutableMapOf()) + + /** + * One entry per preference change, newest first. + * + * @throws CourierInvalidDataException 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 items(): List = items.getRequired("items") + + /** + * @throws CourierInvalidDataException 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 paging(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") + @ExcludeMissing + fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PreferenceLogsListResponse]. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceLogsListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preferenceLogsListResponse: PreferenceLogsListResponse) = apply { + items = preferenceLogsListResponse.items.map { it.toMutableList() } + paging = preferenceLogsListResponse.paging + additionalProperties = preferenceLogsListResponse.additionalProperties.toMutableMap() + } + + /** One entry per preference change, newest first. */ + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [PreferenceChangeLogEntry] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: PreferenceChangeLogEntry) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + 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 [PreferenceLogsListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PreferenceLogsListResponse = + PreferenceLogsListResponse( + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("paging", paging), + 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 CourierInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): PreferenceLogsListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + 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 = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceLogsListResponse && + items == other.items && + paging == other.paging && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PreferenceLogsListResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/WorkspacePreferenceListLogsParams.kt b/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/WorkspacePreferenceListLogsParams.kt new file mode 100644 index 00000000..235dae3c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/models/workspacepreferences/WorkspacePreferenceListLogsParams.kt @@ -0,0 +1,297 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.models.workspacepreferences + +import com.courier.core.Params +import com.courier.core.http.Headers +import com.courier.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns the history of preference changes in this environment, newest first. Each entry records + * one change a user made to one subscription topic, and carries the value before it where there was + * one. Supply user_id to read a single user's history instead of the whole environment. + */ +class WorkspacePreferenceListLogsParams +private constructor( + private val cursor: String?, + private val limit: Long?, + private val since: String?, + private val tenantId: String?, + private val userId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * A cursor from a previous response's paging.cursor. Continue only while paging.more is true; + * the cursor is omitted on the last page. + */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** How many entries to return. Defaults to 25. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Return only changes at or after this time, as an ISO-8601 date or date-time. A date alone is + * read as the start of that day in UTC. + */ + fun since(): Optional = Optional.ofNullable(since) + + /** + * Narrow to the changes this user made in one tenant context. Only valid together with user_id. + */ + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** Return only this user's changes. Omit it to read every change in the environment. */ + fun userId(): Optional = Optional.ofNullable(userId) + + /** 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(): WorkspacePreferenceListLogsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [WorkspacePreferenceListLogsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspacePreferenceListLogsParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var limit: Long? = null + private var since: String? = null + private var tenantId: String? = null + private var userId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(workspacePreferenceListLogsParams: WorkspacePreferenceListLogsParams) = + apply { + cursor = workspacePreferenceListLogsParams.cursor + limit = workspacePreferenceListLogsParams.limit + since = workspacePreferenceListLogsParams.since + tenantId = workspacePreferenceListLogsParams.tenantId + userId = workspacePreferenceListLogsParams.userId + additionalHeaders = workspacePreferenceListLogsParams.additionalHeaders.toBuilder() + additionalQueryParams = + workspacePreferenceListLogsParams.additionalQueryParams.toBuilder() + } + + /** + * A cursor from a previous response's paging.cursor. Continue only while paging.more is + * true; the cursor is omitted on the last page. + */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** How many entries to return. Defaults to 25. */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Return only changes at or after this time, as an ISO-8601 date or date-time. A date alone + * is read as the start of that day in UTC. + */ + fun since(since: String?) = apply { this.since = since } + + /** Alias for calling [Builder.since] with `since.orElse(null)`. */ + fun since(since: Optional) = since(since.getOrNull()) + + /** + * Narrow to the changes this user made in one tenant context. Only valid together with + * user_id. + */ + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** Return only this user's changes. Omit it to read every change in the environment. */ + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + 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 [WorkspacePreferenceListLogsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WorkspacePreferenceListLogsParams = + WorkspacePreferenceListLogsParams( + cursor, + limit, + since, + tenantId, + userId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + since?.let { put("since", it) } + tenantId?.let { put("tenant_id", it) } + userId?.let { put("user_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspacePreferenceListLogsParams && + cursor == other.cursor && + limit == other.limit && + since == other.since && + tenantId == other.tenantId && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + cursor, + limit, + since, + tenantId, + userId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "WorkspacePreferenceListLogsParams{cursor=$cursor, limit=$limit, since=$since, tenantId=$tenantId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsync.kt index 12b28922..a60d1b52 100644 --- a/courier-java-core/src/main/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsync.kt @@ -6,12 +6,14 @@ import com.courier.core.ClientOptions import com.courier.core.RequestOptions import com.courier.core.http.HttpResponse import com.courier.core.http.HttpResponseFor +import com.courier.models.workspacepreferences.PreferenceLogsListResponse import com.courier.models.workspacepreferences.PublishPreferencesRequest import com.courier.models.workspacepreferences.PublishPreferencesResponse import com.courier.models.workspacepreferences.WorkspacePreferenceArchiveParams import com.courier.models.workspacepreferences.WorkspacePreferenceCreateParams import com.courier.models.workspacepreferences.WorkspacePreferenceCreateRequest import com.courier.models.workspacepreferences.WorkspacePreferenceGetResponse +import com.courier.models.workspacepreferences.WorkspacePreferenceListLogsParams import com.courier.models.workspacepreferences.WorkspacePreferenceListParams import com.courier.models.workspacepreferences.WorkspacePreferenceListResponse import com.courier.models.workspacepreferences.WorkspacePreferencePublishParams @@ -170,6 +172,30 @@ interface WorkspacePreferenceServiceAsync { fun archive(sectionId: String, requestOptions: RequestOptions): CompletableFuture = archive(sectionId, WorkspacePreferenceArchiveParams.none(), requestOptions) + /** + * Returns the history of preference changes in this environment, newest first. Each entry + * records one change a user made to one subscription topic, and carries the value before it + * where there was one. Supply user_id to read a single user's history instead of the whole + * environment. + */ + fun listLogs(): CompletableFuture = + listLogs(WorkspacePreferenceListLogsParams.none()) + + /** @see listLogs */ + fun listLogs( + params: WorkspacePreferenceListLogsParams = WorkspacePreferenceListLogsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see listLogs */ + fun listLogs( + params: WorkspacePreferenceListLogsParams = WorkspacePreferenceListLogsParams.none() + ): CompletableFuture = listLogs(params, RequestOptions.none()) + + /** @see listLogs */ + fun listLogs(requestOptions: RequestOptions): CompletableFuture = + listLogs(WorkspacePreferenceListLogsParams.none(), requestOptions) + /** * Publishes the workspace preference page, snapshotting every preference and topic, and returns * the page id and a preview URL. @@ -395,6 +421,31 @@ interface WorkspacePreferenceServiceAsync { ): CompletableFuture = archive(sectionId, WorkspacePreferenceArchiveParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `get /preferences/logs`, but is otherwise the same as + * [WorkspacePreferenceServiceAsync.listLogs]. + */ + fun listLogs(): CompletableFuture> = + listLogs(WorkspacePreferenceListLogsParams.none()) + + /** @see listLogs */ + fun listLogs( + params: WorkspacePreferenceListLogsParams = WorkspacePreferenceListLogsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see listLogs */ + fun listLogs( + params: WorkspacePreferenceListLogsParams = WorkspacePreferenceListLogsParams.none() + ): CompletableFuture> = + listLogs(params, RequestOptions.none()) + + /** @see listLogs */ + fun listLogs( + requestOptions: RequestOptions + ): CompletableFuture> = + listLogs(WorkspacePreferenceListLogsParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /preferences/publish`, but is otherwise the same as * [WorkspacePreferenceServiceAsync.publish]. diff --git a/courier-java-core/src/main/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsyncImpl.kt index f002b233..25d0301f 100644 --- a/courier-java-core/src/main/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsyncImpl.kt @@ -17,10 +17,12 @@ import com.courier.core.http.HttpResponseFor import com.courier.core.http.json import com.courier.core.http.parseable import com.courier.core.prepareAsync +import com.courier.models.workspacepreferences.PreferenceLogsListResponse import com.courier.models.workspacepreferences.PublishPreferencesResponse import com.courier.models.workspacepreferences.WorkspacePreferenceArchiveParams import com.courier.models.workspacepreferences.WorkspacePreferenceCreateParams import com.courier.models.workspacepreferences.WorkspacePreferenceGetResponse +import com.courier.models.workspacepreferences.WorkspacePreferenceListLogsParams import com.courier.models.workspacepreferences.WorkspacePreferenceListParams import com.courier.models.workspacepreferences.WorkspacePreferenceListResponse import com.courier.models.workspacepreferences.WorkspacePreferencePublishParams @@ -85,6 +87,13 @@ internal constructor(private val clientOptions: ClientOptions) : WorkspacePrefer // delete /preferences/sections/{section_id} withRawResponse().archive(params, requestOptions).thenAccept {} + override fun listLogs( + params: WorkspacePreferenceListLogsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /preferences/logs + withRawResponse().listLogs(params, requestOptions).thenApply { it.parse() } + override fun publish( params: WorkspacePreferencePublishParams, requestOptions: RequestOptions, @@ -239,6 +248,36 @@ internal constructor(private val clientOptions: ClientOptions) : WorkspacePrefer } } + private val listLogsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listLogs( + params: WorkspacePreferenceListLogsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("preferences", "logs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listLogsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val publishHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/courier-java-core/src/main/kotlin/com/courier/services/blocking/WorkspacePreferenceService.kt b/courier-java-core/src/main/kotlin/com/courier/services/blocking/WorkspacePreferenceService.kt index 33bb5ed5..5cf6206d 100644 --- a/courier-java-core/src/main/kotlin/com/courier/services/blocking/WorkspacePreferenceService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/services/blocking/WorkspacePreferenceService.kt @@ -6,12 +6,14 @@ import com.courier.core.ClientOptions import com.courier.core.RequestOptions import com.courier.core.http.HttpResponse import com.courier.core.http.HttpResponseFor +import com.courier.models.workspacepreferences.PreferenceLogsListResponse import com.courier.models.workspacepreferences.PublishPreferencesRequest import com.courier.models.workspacepreferences.PublishPreferencesResponse import com.courier.models.workspacepreferences.WorkspacePreferenceArchiveParams import com.courier.models.workspacepreferences.WorkspacePreferenceCreateParams import com.courier.models.workspacepreferences.WorkspacePreferenceCreateRequest import com.courier.models.workspacepreferences.WorkspacePreferenceGetResponse +import com.courier.models.workspacepreferences.WorkspacePreferenceListLogsParams import com.courier.models.workspacepreferences.WorkspacePreferenceListParams import com.courier.models.workspacepreferences.WorkspacePreferenceListResponse import com.courier.models.workspacepreferences.WorkspacePreferencePublishParams @@ -163,6 +165,29 @@ interface WorkspacePreferenceService { fun archive(sectionId: String, requestOptions: RequestOptions) = archive(sectionId, WorkspacePreferenceArchiveParams.none(), requestOptions) + /** + * Returns the history of preference changes in this environment, newest first. Each entry + * records one change a user made to one subscription topic, and carries the value before it + * where there was one. Supply user_id to read a single user's history instead of the whole + * environment. + */ + fun listLogs(): PreferenceLogsListResponse = listLogs(WorkspacePreferenceListLogsParams.none()) + + /** @see listLogs */ + fun listLogs( + params: WorkspacePreferenceListLogsParams = WorkspacePreferenceListLogsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PreferenceLogsListResponse + + /** @see listLogs */ + fun listLogs( + params: WorkspacePreferenceListLogsParams = WorkspacePreferenceListLogsParams.none() + ): PreferenceLogsListResponse = listLogs(params, RequestOptions.none()) + + /** @see listLogs */ + fun listLogs(requestOptions: RequestOptions): PreferenceLogsListResponse = + listLogs(WorkspacePreferenceListLogsParams.none(), requestOptions) + /** * Publishes the workspace preference page, snapshotting every preference and topic, and returns * the page id and a preview URL. @@ -392,6 +417,32 @@ interface WorkspacePreferenceService { fun archive(sectionId: String, requestOptions: RequestOptions): HttpResponse = archive(sectionId, WorkspacePreferenceArchiveParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `get /preferences/logs`, but is otherwise the same as + * [WorkspacePreferenceService.listLogs]. + */ + @MustBeClosed + fun listLogs(): HttpResponseFor = + listLogs(WorkspacePreferenceListLogsParams.none()) + + /** @see listLogs */ + @MustBeClosed + fun listLogs( + params: WorkspacePreferenceListLogsParams = WorkspacePreferenceListLogsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listLogs */ + @MustBeClosed + fun listLogs( + params: WorkspacePreferenceListLogsParams = WorkspacePreferenceListLogsParams.none() + ): HttpResponseFor = listLogs(params, RequestOptions.none()) + + /** @see listLogs */ + @MustBeClosed + fun listLogs(requestOptions: RequestOptions): HttpResponseFor = + listLogs(WorkspacePreferenceListLogsParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /preferences/publish`, but is otherwise the same as * [WorkspacePreferenceService.publish]. diff --git a/courier-java-core/src/main/kotlin/com/courier/services/blocking/WorkspacePreferenceServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/services/blocking/WorkspacePreferenceServiceImpl.kt index b0b37ee2..028297bb 100644 --- a/courier-java-core/src/main/kotlin/com/courier/services/blocking/WorkspacePreferenceServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/services/blocking/WorkspacePreferenceServiceImpl.kt @@ -17,10 +17,12 @@ import com.courier.core.http.HttpResponseFor import com.courier.core.http.json import com.courier.core.http.parseable import com.courier.core.prepare +import com.courier.models.workspacepreferences.PreferenceLogsListResponse import com.courier.models.workspacepreferences.PublishPreferencesResponse import com.courier.models.workspacepreferences.WorkspacePreferenceArchiveParams import com.courier.models.workspacepreferences.WorkspacePreferenceCreateParams import com.courier.models.workspacepreferences.WorkspacePreferenceGetResponse +import com.courier.models.workspacepreferences.WorkspacePreferenceListLogsParams import com.courier.models.workspacepreferences.WorkspacePreferenceListParams import com.courier.models.workspacepreferences.WorkspacePreferenceListResponse import com.courier.models.workspacepreferences.WorkspacePreferencePublishParams @@ -79,6 +81,13 @@ internal constructor(private val clientOptions: ClientOptions) : WorkspacePrefer withRawResponse().archive(params, requestOptions) } + override fun listLogs( + params: WorkspacePreferenceListLogsParams, + requestOptions: RequestOptions, + ): PreferenceLogsListResponse = + // get /preferences/logs + withRawResponse().listLogs(params, requestOptions).parse() + override fun publish( params: WorkspacePreferencePublishParams, requestOptions: RequestOptions, @@ -221,6 +230,33 @@ internal constructor(private val clientOptions: ClientOptions) : WorkspacePrefer } } + private val listLogsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listLogs( + params: WorkspacePreferenceListLogsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("preferences", "logs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listLogsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val publishHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogEntryTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogEntryTest.kt new file mode 100644 index 00000000..b7506a6a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogEntryTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.models.workspacepreferences + +import com.courier.core.jsonMapper +import com.courier.models.ChannelClassification +import com.courier.models.PreferenceStatus +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceChangeLogEntryTest { + + @Test + fun create() { + val preferenceChangeLogEntry = + PreferenceChangeLogEntry.builder() + .id("id") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .timestamp("timestamp") + .topicId("topic_id") + .topicName("topic_name") + .userId("user_id") + .previous( + PreferenceChangeLogValue.builder() + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .build() + ) + .tenantId("tenant_id") + .build() + + assertThat(preferenceChangeLogEntry.id()).isEqualTo("id") + assertThat(preferenceChangeLogEntry.customRouting()) + .containsExactly(ChannelClassification.DIRECT_MESSAGE) + assertThat(preferenceChangeLogEntry.hasCustomRouting()).isEqualTo(true) + assertThat(preferenceChangeLogEntry.status()).isEqualTo(PreferenceStatus.OPTED_IN) + assertThat(preferenceChangeLogEntry.timestamp()).isEqualTo("timestamp") + assertThat(preferenceChangeLogEntry.topicId()).isEqualTo("topic_id") + assertThat(preferenceChangeLogEntry.topicName()).isEqualTo("topic_name") + assertThat(preferenceChangeLogEntry.userId()).isEqualTo("user_id") + assertThat(preferenceChangeLogEntry.previous()) + .contains( + PreferenceChangeLogValue.builder() + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .build() + ) + assertThat(preferenceChangeLogEntry.tenantId()).contains("tenant_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val preferenceChangeLogEntry = + PreferenceChangeLogEntry.builder() + .id("id") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .timestamp("timestamp") + .topicId("topic_id") + .topicName("topic_name") + .userId("user_id") + .previous( + PreferenceChangeLogValue.builder() + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .build() + ) + .tenantId("tenant_id") + .build() + + val roundtrippedPreferenceChangeLogEntry = + jsonMapper.readValue( + jsonMapper.writeValueAsString(preferenceChangeLogEntry), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPreferenceChangeLogEntry).isEqualTo(preferenceChangeLogEntry) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogValueTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogValueTest.kt new file mode 100644 index 00000000..9f6135a3 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceChangeLogValueTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.models.workspacepreferences + +import com.courier.core.jsonMapper +import com.courier.models.ChannelClassification +import com.courier.models.PreferenceStatus +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceChangeLogValueTest { + + @Test + fun create() { + val preferenceChangeLogValue = + PreferenceChangeLogValue.builder() + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .build() + + assertThat(preferenceChangeLogValue.customRouting()) + .containsExactly(ChannelClassification.DIRECT_MESSAGE) + assertThat(preferenceChangeLogValue.hasCustomRouting()).isEqualTo(true) + assertThat(preferenceChangeLogValue.status()).isEqualTo(PreferenceStatus.OPTED_IN) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val preferenceChangeLogValue = + PreferenceChangeLogValue.builder() + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .build() + + val roundtrippedPreferenceChangeLogValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(preferenceChangeLogValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPreferenceChangeLogValue).isEqualTo(preferenceChangeLogValue) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceLogsListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceLogsListResponseTest.kt new file mode 100644 index 00000000..2d737093 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/PreferenceLogsListResponseTest.kt @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.models.workspacepreferences + +import com.courier.core.jsonMapper +import com.courier.models.ChannelClassification +import com.courier.models.Paging +import com.courier.models.PreferenceStatus +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceLogsListResponseTest { + + @Test + fun create() { + val preferenceLogsListResponse = + PreferenceLogsListResponse.builder() + .addItem( + PreferenceChangeLogEntry.builder() + .id("id") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .timestamp("timestamp") + .topicId("topic_id") + .topicName("topic_name") + .userId("user_id") + .previous( + PreferenceChangeLogValue.builder() + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .build() + ) + .tenantId("tenant_id") + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + assertThat(preferenceLogsListResponse.items()) + .containsExactly( + PreferenceChangeLogEntry.builder() + .id("id") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .timestamp("timestamp") + .topicId("topic_id") + .topicName("topic_name") + .userId("user_id") + .previous( + PreferenceChangeLogValue.builder() + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .build() + ) + .tenantId("tenant_id") + .build() + ) + assertThat(preferenceLogsListResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val preferenceLogsListResponse = + PreferenceLogsListResponse.builder() + .addItem( + PreferenceChangeLogEntry.builder() + .id("id") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .timestamp("timestamp") + .topicId("topic_id") + .topicName("topic_name") + .userId("user_id") + .previous( + PreferenceChangeLogValue.builder() + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .status(PreferenceStatus.OPTED_IN) + .build() + ) + .tenantId("tenant_id") + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + val roundtrippedPreferenceLogsListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(preferenceLogsListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPreferenceLogsListResponse).isEqualTo(preferenceLogsListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/WorkspacePreferenceListLogsParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/WorkspacePreferenceListLogsParamsTest.kt new file mode 100644 index 00000000..4138d222 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/models/workspacepreferences/WorkspacePreferenceListLogsParamsTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.models.workspacepreferences + +import com.courier.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspacePreferenceListLogsParamsTest { + + @Test + fun create() { + WorkspacePreferenceListLogsParams.builder() + .cursor("cursor") + .limit(1L) + .since("since") + .tenantId("tenant_id") + .userId("user_id") + .build() + } + + @Test + fun queryParams() { + val params = + WorkspacePreferenceListLogsParams.builder() + .cursor("cursor") + .limit(1L) + .since("since") + .tenantId("tenant_id") + .userId("user_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("cursor", "cursor") + .put("limit", "1") + .put("since", "since") + .put("tenant_id", "tenant_id") + .put("user_id", "user_id") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = WorkspacePreferenceListLogsParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsyncTest.kt index 4f3c111f..db1a32b4 100644 --- a/courier-java-core/src/test/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/services/async/WorkspacePreferenceServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.courier.models.ChannelClassification import com.courier.models.workspacepreferences.PublishPreferencesRequest import com.courier.models.workspacepreferences.WorkspacePreferenceCreateParams import com.courier.models.workspacepreferences.WorkspacePreferenceCreateRequest +import com.courier.models.workspacepreferences.WorkspacePreferenceListLogsParams import com.courier.models.workspacepreferences.WorkspacePreferencePublishParams import com.courier.models.workspacepreferences.WorkspacePreferenceReplaceParams import com.courier.models.workspacepreferences.WorkspacePreferenceReplaceRequest @@ -77,6 +78,27 @@ internal class WorkspacePreferenceServiceAsyncTest { val response = future.get() } + @Disabled("Mock server tests are disabled") + @Test + fun listLogs() { + val client = CourierOkHttpClientAsync.builder().apiKey("My API Key").build() + val workspacePreferenceServiceAsync = client.workspacePreferences() + + val preferenceLogsListResponseFuture = + workspacePreferenceServiceAsync.listLogs( + WorkspacePreferenceListLogsParams.builder() + .cursor("cursor") + .limit(1L) + .since("since") + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + + val preferenceLogsListResponse = preferenceLogsListResponseFuture.get() + preferenceLogsListResponse.validate() + } + @Disabled("Mock server tests are disabled") @Test fun publish() { diff --git a/courier-java-core/src/test/kotlin/com/courier/services/blocking/WorkspacePreferenceServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/services/blocking/WorkspacePreferenceServiceTest.kt index bdc29054..694365cc 100644 --- a/courier-java-core/src/test/kotlin/com/courier/services/blocking/WorkspacePreferenceServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/services/blocking/WorkspacePreferenceServiceTest.kt @@ -7,6 +7,7 @@ import com.courier.models.ChannelClassification import com.courier.models.workspacepreferences.PublishPreferencesRequest import com.courier.models.workspacepreferences.WorkspacePreferenceCreateParams import com.courier.models.workspacepreferences.WorkspacePreferenceCreateRequest +import com.courier.models.workspacepreferences.WorkspacePreferenceListLogsParams import com.courier.models.workspacepreferences.WorkspacePreferencePublishParams import com.courier.models.workspacepreferences.WorkspacePreferenceReplaceParams import com.courier.models.workspacepreferences.WorkspacePreferenceReplaceRequest @@ -71,6 +72,26 @@ internal class WorkspacePreferenceServiceTest { workspacePreferenceService.archive("section_id") } + @Disabled("Mock server tests are disabled") + @Test + fun listLogs() { + val client = CourierOkHttpClient.builder().apiKey("My API Key").build() + val workspacePreferenceService = client.workspacePreferences() + + val preferenceLogsListResponse = + workspacePreferenceService.listLogs( + WorkspacePreferenceListLogsParams.builder() + .cursor("cursor") + .limit(1L) + .since("since") + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + + preferenceLogsListResponse.validate() + } + @Disabled("Mock server tests are disabled") @Test fun publish() {