Skip to content

Commit

Permalink
fix(specs): partial update operation (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3486

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Kai Welke <kai.welke@algolia.com>
Co-authored-by: shortcuts <vannicattec@gmail.com>
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
  • Loading branch information
4 people committed Aug 28, 2024
1 parent 9a32522 commit 69fe082
Show file tree
Hide file tree
Showing 12 changed files with 464 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ public class SearchClient(
}

/**
* Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor.
* Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn't exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn't exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don't have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it's not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn't exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn't exist yet, the engine only creates it if you pass an IncrementSet value that's greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove.
*
* Required API Key ACLs:
* - addObject
Expand All @@ -964,9 +964,10 @@ public class SearchClient(
* @param createIfNotExists Whether to create a new record if it doesn't exist. (default to true)
* @param requestOptions additional request configuration.
*/
public suspend fun partialUpdateObject(indexName: String, objectID: String, attributesToUpdate: Map<kotlin.String, AttributeToUpdate>, createIfNotExists: Boolean? = null, requestOptions: RequestOptions? = null): UpdatedAtWithObjectIdResponse {
public suspend fun partialUpdateObject(indexName: String, objectID: String, attributesToUpdate: JsonObject, createIfNotExists: Boolean? = null, requestOptions: RequestOptions? = null): UpdatedAtWithObjectIdResponse {
require(indexName.isNotBlank()) { "Parameter `indexName` is required when calling `partialUpdateObject`." }
require(objectID.isNotBlank()) { "Parameter `objectID` is required when calling `partialUpdateObject`." }
require(attributesToUpdate.isNotEmpty()) { "Parameter `attributesToUpdate` is required when calling `partialUpdateObject`." }
val requestConfig = RequestConfig(
method = RequestMethod.POST,
path = listOf("1", "indexes", "$indexName", "$objectID", "partial"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.abtesting

import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

/**
* Error.
*
* @param message
*/
@Serializable(ErrorBaseSerializer::class)
public data class ErrorBase(

val message: String? = null,

val additionalProperties: Map<String, JsonElement>? = null,
)

internal object ErrorBaseSerializer : KSerializer<ErrorBase> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ErrorBase") {
element<String>("message", isOptional = true)
}

override fun deserialize(decoder: Decoder): ErrorBase {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return ErrorBase(
message = tree["message"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}

override fun serialize(encoder: Encoder, value: ErrorBase) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
value.message?.let { put("message", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.analytics

import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

/**
* Error.
*
* @param message
*/
@Serializable(ErrorBaseSerializer::class)
public data class ErrorBase(

val message: String? = null,

val additionalProperties: Map<String, JsonElement>? = null,
)

internal object ErrorBaseSerializer : KSerializer<ErrorBase> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ErrorBase") {
element<String>("message", isOptional = true)
}

override fun deserialize(decoder: Decoder): ErrorBase {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return ErrorBase(
message = tree["message"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}

override fun serialize(encoder: Encoder, value: ErrorBase) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
value.message?.let { put("message", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.ingestion

import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

/**
* Error.
*
* @param message
*/
@Serializable(ErrorBaseSerializer::class)
public data class ErrorBase(

val message: String? = null,

val additionalProperties: Map<String, JsonElement>? = null,
)

internal object ErrorBaseSerializer : KSerializer<ErrorBase> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ErrorBase") {
element<String>("message", isOptional = true)
}

override fun deserialize(decoder: Decoder): ErrorBase {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return ErrorBase(
message = tree["message"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}

override fun serialize(encoder: Encoder, value: ErrorBase) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
value.message?.let { put("message", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.insights

import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

/**
* Error.
*
* @param message
*/
@Serializable(ErrorBaseSerializer::class)
public data class ErrorBase(

val message: String? = null,

val additionalProperties: Map<String, JsonElement>? = null,
)

internal object ErrorBaseSerializer : KSerializer<ErrorBase> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ErrorBase") {
element<String>("message", isOptional = true)
}

override fun deserialize(decoder: Decoder): ErrorBase {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return ErrorBase(
message = tree["message"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}

override fun serialize(encoder: Encoder, value: ErrorBase) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
value.message?.let { put("message", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.monitoring

import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

/**
* Error.
*
* @param message
*/
@Serializable(ErrorBaseSerializer::class)
public data class ErrorBase(

val message: String? = null,

val additionalProperties: Map<String, JsonElement>? = null,
)

internal object ErrorBaseSerializer : KSerializer<ErrorBase> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ErrorBase") {
element<String>("message", isOptional = true)
}

override fun deserialize(decoder: Decoder): ErrorBase {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return ErrorBase(
message = tree["message"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}

override fun serialize(encoder: Encoder, value: ErrorBase) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
value.message?.let { put("message", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.personalization

import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

/**
* Error.
*
* @param message
*/
@Serializable(ErrorBaseSerializer::class)
public data class ErrorBase(

val message: String? = null,

val additionalProperties: Map<String, JsonElement>? = null,
)

internal object ErrorBaseSerializer : KSerializer<ErrorBase> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ErrorBase") {
element<String>("message", isOptional = true)
}

override fun deserialize(decoder: Decoder): ErrorBase {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return ErrorBase(
message = tree["message"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}

override fun serialize(encoder: Encoder, value: ErrorBase) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
value.message?.let { put("message", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.querysuggestions

import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

/**
* Error.
*
* @param message
*/
@Serializable(ErrorBaseSerializer::class)
public data class ErrorBase(

val message: String? = null,

val additionalProperties: Map<String, JsonElement>? = null,
)

internal object ErrorBaseSerializer : KSerializer<ErrorBase> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ErrorBase") {
element<String>("message", isOptional = true)
}

override fun deserialize(decoder: Decoder): ErrorBase {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return ErrorBase(
message = tree["message"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}

override fun serialize(encoder: Encoder, value: ErrorBase) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
value.message?.let { put("message", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. */
package com.algolia.client.model.recommend

import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

/**
* Error.
*
* @param message
*/
@Serializable(ErrorBaseSerializer::class)
public data class ErrorBase(

val message: String? = null,

val additionalProperties: Map<String, JsonElement>? = null,
)

internal object ErrorBaseSerializer : KSerializer<ErrorBase> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ErrorBase") {
element<String>("message", isOptional = true)
}

override fun deserialize(decoder: Decoder): ErrorBase {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return ErrorBase(
message = tree["message"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}

override fun serialize(encoder: Encoder, value: ErrorBase) {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
value.message?.let { put("message", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
}
}
Loading

0 comments on commit 69fe082

Please sign in to comment.