Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 149
configured_endpoints: 154
Original file line number Diff line number Diff line change
@@ -0,0 +1,357 @@
// File generated from our OpenAPI spec by Stainless.

package com.courier.models.automations

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.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

/** An Automation run as it appears in a list response. */
class AutomationRunListItem
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
private val runId: JsonField<String>,
private val source: JsonField<List<String>>,
private val createdAt: JsonField<String>,
private val status: JsonField<String>,
private val templateId: JsonField<String>,
private val additionalProperties: MutableMap<String, JsonValue>,
) {

@JsonCreator
private constructor(
@JsonProperty("run_id") @ExcludeMissing runId: JsonField<String> = JsonMissing.of(),
@JsonProperty("source") @ExcludeMissing source: JsonField<List<String>> = JsonMissing.of(),
@JsonProperty("created_at") @ExcludeMissing createdAt: JsonField<String> = JsonMissing.of(),
@JsonProperty("status") @ExcludeMissing status: JsonField<String> = JsonMissing.of(),
@JsonProperty("template_id")
@ExcludeMissing
templateId: JsonField<String> = JsonMissing.of(),
) : this(runId, source, createdAt, status, templateId, mutableMapOf())

/**
* A unique identifier representing the run.
*
* @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 runId(): String = runId.getRequired("run_id")

/**
* Internal provenance strings describing what started the run, e.g. `invoke/<template_id>` or
* `segment/page/Pricing Page`. Diagnostic only — the format is unstable and should not be
* parsed.
*
* @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 source(): List<String> = source.getRequired("source")

/**
* When the run started, as an ISO 8601 timestamp.
*
* @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun createdAt(): Optional<String> = createdAt.getOptional("created_at")

/**
* The state of the run: `PROCESSING`, `PROCESSED`, `WAITING`, `CANCELED`, `ERROR`, `THROTTLED`,
* or `NOT PROCESSED`. Not an enum — new values have been added before.
*
* @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun status(): Optional<String> = status.getOptional("status")

/**
* The id of the Automation Template this run belongs to.
*
* @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun templateId(): Optional<String> = templateId.getOptional("template_id")

/**
* Returns the raw JSON value of [runId].
*
* Unlike [runId], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField<String> = runId

/**
* Returns the raw JSON value of [source].
*
* Unlike [source], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("source") @ExcludeMissing fun _source(): JsonField<List<String>> = source

/**
* 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<String> = createdAt

/**
* 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<String> = status

/**
* Returns the raw JSON value of [templateId].
*
* Unlike [templateId], this method doesn't throw if the JSON field has an unexpected type.
*/
@JsonProperty("template_id") @ExcludeMissing fun _templateId(): JsonField<String> = templateId

@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
additionalProperties.put(key, value)
}

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> =
Collections.unmodifiableMap(additionalProperties)

fun toBuilder() = Builder().from(this)

companion object {

/**
* Returns a mutable builder for constructing an instance of [AutomationRunListItem].
*
* The following fields are required:
* ```java
* .runId()
* .source()
* ```
*/
@JvmStatic fun builder() = Builder()
}

/** A builder for [AutomationRunListItem]. */
class Builder internal constructor() {

private var runId: JsonField<String>? = null
private var source: JsonField<MutableList<String>>? = null
private var createdAt: JsonField<String> = JsonMissing.of()
private var status: JsonField<String> = JsonMissing.of()
private var templateId: JsonField<String> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(automationRunListItem: AutomationRunListItem) = apply {
runId = automationRunListItem.runId
source = automationRunListItem.source.map { it.toMutableList() }
createdAt = automationRunListItem.createdAt
status = automationRunListItem.status
templateId = automationRunListItem.templateId
additionalProperties = automationRunListItem.additionalProperties.toMutableMap()
}

/** A unique identifier representing the run. */
fun runId(runId: String) = runId(JsonField.of(runId))

/**
* Sets [Builder.runId] to an arbitrary JSON value.
*
* You should usually call [Builder.runId] with a well-typed [String] value instead. This
* method is primarily for setting the field to an undocumented or not yet supported value.
*/
fun runId(runId: JsonField<String>) = apply { this.runId = runId }

/**
* Internal provenance strings describing what started the run, e.g. `invoke/<template_id>`
* or `segment/page/Pricing Page`. Diagnostic only — the format is unstable and should not
* be parsed.
*/
fun source(source: List<String>) = source(JsonField.of(source))

/**
* Sets [Builder.source] to an arbitrary JSON value.
*
* You should usually call [Builder.source] with a well-typed `List<String>` value instead.
* This method is primarily for setting the field to an undocumented or not yet supported
* value.
*/
fun source(source: JsonField<List<String>>) = apply {
this.source = source.map { it.toMutableList() }
}

/**
* Adds a single [String] to [Builder.source].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
fun addSource(source: String) = apply {
this.source =
(this.source ?: JsonField.of(mutableListOf())).also {
checkKnown("source", it).add(source)
}
}

/** When the run started, as an ISO 8601 timestamp. */
fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt))

/**
* Sets [Builder.createdAt] to an arbitrary JSON value.
*
* You should usually call [Builder.createdAt] with a well-typed [String] value instead.
* This method is primarily for setting the field to an undocumented or not yet supported
* value.
*/
fun createdAt(createdAt: JsonField<String>) = apply { this.createdAt = createdAt }

/**
* The state of the run: `PROCESSING`, `PROCESSED`, `WAITING`, `CANCELED`, `ERROR`,
* `THROTTLED`, or `NOT PROCESSED`. Not an enum — new values have been added before.
*/
fun status(status: String) = status(JsonField.of(status))

/**
* Sets [Builder.status] to an arbitrary JSON value.
*
* You should usually call [Builder.status] with a well-typed [String] value instead. This
* method is primarily for setting the field to an undocumented or not yet supported value.
*/
fun status(status: JsonField<String>) = apply { this.status = status }

/** The id of the Automation Template this run belongs to. */
fun templateId(templateId: String) = templateId(JsonField.of(templateId))

/**
* Sets [Builder.templateId] to an arbitrary JSON value.
*
* You should usually call [Builder.templateId] with a well-typed [String] value instead.
* This method is primarily for setting the field to an undocumented or not yet supported
* value.
*/
fun templateId(templateId: JsonField<String>) = apply { this.templateId = templateId }

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
}

fun putAdditionalProperty(key: String, value: JsonValue) = apply {
additionalProperties.put(key, value)
}

fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.putAll(additionalProperties)
}

fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }

fun removeAllAdditionalProperties(keys: Set<String>) = apply {
keys.forEach(::removeAdditionalProperty)
}

/**
* Returns an immutable instance of [AutomationRunListItem].
*
* Further updates to this [Builder] will not mutate the returned instance.
*
* The following fields are required:
* ```java
* .runId()
* .source()
* ```
*
* @throws IllegalStateException if any required field is unset.
*/
fun build(): AutomationRunListItem =
AutomationRunListItem(
checkRequired("runId", runId),
checkRequired("source", source).map { it.toImmutable() },
createdAt,
status,
templateId,
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(): AutomationRunListItem = apply {
if (validated) {
return@apply
}

runId()
source()
createdAt()
status()
templateId()
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 (runId.asKnown().isPresent) 1 else 0) +
(source.asKnown().getOrNull()?.size ?: 0) +
(if (createdAt.asKnown().isPresent) 1 else 0) +
(if (status.asKnown().isPresent) 1 else 0) +
(if (templateId.asKnown().isPresent) 1 else 0)

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}

return other is AutomationRunListItem &&
runId == other.runId &&
source == other.source &&
createdAt == other.createdAt &&
status == other.status &&
templateId == other.templateId &&
additionalProperties == other.additionalProperties
}

private val hashCode: Int by lazy {
Objects.hash(runId, source, createdAt, status, templateId, additionalProperties)
}

override fun hashCode(): Int = hashCode

override fun toString() =
"AutomationRunListItem{runId=$runId, source=$source, createdAt=$createdAt, status=$status, templateId=$templateId, additionalProperties=$additionalProperties}"
}
Loading
Loading