Skip to content

Commit

Permalink
feat(specs): rename composition to composition-full (private) and add…
Browse files Browse the repository at this point in the history
… composition (public) (generated)

algolia/api-clients-automation#4357

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Emmanuel Krebs <e-krebs@users.noreply.github.com>
Co-authored-by: shortcuts <vannicattec@gmail.com>
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
  • Loading branch information
4 people committed Jan 22, 2025
1 parent de68bf3 commit 4579300
Show file tree
Hide file tree
Showing 52 changed files with 2,001 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/** 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.api

import com.algolia.client.configuration.*
import com.algolia.client.exception.*
import com.algolia.client.extensions.internal.*
import com.algolia.client.model.composition.*
import com.algolia.client.model.composition.RequestBody
import com.algolia.client.transport.*
import com.algolia.client.transport.internal.*
import kotlinx.serialization.json.*
import kotlin.time.Duration.Companion.milliseconds

public class CompositionClient(
override val appId: String,
override var apiKey: String,
override val options: ClientOptions = ClientOptions(),
) : ApiClient {

init {
require(appId.isNotBlank()) { "`appId` is missing." }
require(apiKey.isNotBlank()) { "`apiKey` is missing." }
}

override val requester: Requester = requesterOf(clientName = "Composition", appId = appId, apiKey = apiKey, connectTimeout = 2000.milliseconds, readTimeout = 5000.milliseconds, writeTimeout = 30000.milliseconds, options = options) {
listOf(
Host("$appId-dsn.algolia.net", CallType.Read),
Host("$appId.algolia.net", CallType.Write),
) + mutableListOf(
Host("$appId-1.algolianet.com"),
Host("$appId-2.algolianet.com"),
Host("$appId-3.algolianet.com"),
).apply { shuffle() }
}

/**
* Runs a query on a single composition and returns matching results.
*
* Required API Key ACLs:
* - search
* @param compositionID Unique Composition ObjectID.
* @param requestBody
* @param requestOptions additional request configuration.
*/
public suspend fun search(compositionID: String, requestBody: RequestBody, requestOptions: RequestOptions? = null): SearchResponse {
require(compositionID.isNotBlank()) { "Parameter `compositionID` is required when calling `search`." }
val requestConfig = RequestConfig(
method = RequestMethod.POST,
path = listOf("1", "compositions", "$compositionID", "run"),
isRead = true,
body = requestBody,
)
return requester.execute(
requestConfig = requestConfig,
requestOptions = requestOptions,
)
}

/**
* Searches for values of a specified facet attribute on the composition's main source's index. - By default, facet values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching for facet values doesn't work if you have **more than 65 searchable facets and searchable attributes combined**.
*
* Required API Key ACLs:
* - search
* @param compositionID Unique Composition ObjectID.
* @param facetName Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting` index setting with the `searchable()` modifier.
* @param searchForFacetValuesRequest
* @param requestOptions additional request configuration.
*/
public suspend fun searchForFacetValues(compositionID: String, facetName: String, searchForFacetValuesRequest: SearchForFacetValuesRequest? = null, requestOptions: RequestOptions? = null): SearchForFacetValuesResponse {
require(compositionID.isNotBlank()) { "Parameter `compositionID` is required when calling `searchForFacetValues`." }
require(facetName.isNotBlank()) { "Parameter `facetName` is required when calling `searchForFacetValues`." }
val requestConfig = RequestConfig(
method = RequestMethod.POST,
path = listOf("1", "compositions", "$compositionID", "facets", "$facetName", "query"),
isRead = true,
body = searchForFacetValuesRequest,
)
return requester.execute(
requestConfig = requestConfig,
requestOptions = requestOptions,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/** 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.composition

import com.algolia.client.exception.AlgoliaClientException
import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
import kotlin.jvm.JvmInline

/**
* Precision of a coordinate-based search in meters to group results with similar distances. The Geo ranking criterion considers all matches within the same range of distances to be equal.
*
* Implementations:
* - [Int] - *[AroundPrecision.of]*
* - [List<Range>] - *[AroundPrecision.of]*
*/
@Serializable(AroundPrecisionSerializer::class)
public sealed interface AroundPrecision {
@Serializable
@JvmInline
public value class IntValue(public val value: Int) : AroundPrecision

@Serializable
@JvmInline
public value class ListOfRangeValue(public val value: List<Range>) : AroundPrecision

public companion object {

public fun of(value: Int): AroundPrecision = IntValue(value)

public fun of(value: List<Range>): AroundPrecision = ListOfRangeValue(value)
}
}

internal class AroundPrecisionSerializer : JsonContentPolymorphicSerializer<AroundPrecision>(AroundPrecision::class) {
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<AroundPrecision> = when {
element.isInt -> AroundPrecision.IntValue.serializer()
element is JsonArray -> AroundPrecision.ListOfRangeValue.serializer()
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/** 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.composition

import com.algolia.client.exception.AlgoliaClientException
import com.algolia.client.extensions.internal.*
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
import kotlin.jvm.JvmInline

/**
* Maximum radius for a search around a central location. This parameter works in combination with the `aroundLatLng` and `aroundLatLngViaIP` parameters. By default, the search radius is determined automatically from the density of hits around the central location. The search radius is small if there are many hits close to the central coordinates.
*
* Implementations:
* - [AroundRadiusAll]
* - [Int] - *[AroundRadius.of]*
*/
@Serializable(AroundRadiusSerializer::class)
public sealed interface AroundRadius {
@Serializable
@JvmInline
public value class IntValue(public val value: Int) : AroundRadius

@Serializable
@JvmInline
public value class AroundRadiusAllValue(public val value: AroundRadiusAll) : AroundRadius

public companion object {

public fun of(value: Int): AroundRadius = IntValue(value)

public fun of(value: AroundRadiusAll): AroundRadius = AroundRadiusAllValue(value)
}
}

internal class AroundRadiusSerializer : JsonContentPolymorphicSerializer<AroundRadius>(AroundRadius::class) {
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<AroundRadius> = when {
element.isInt -> AroundRadius.IntValue.serializer()
element.isString -> AroundRadiusAll.serializer()
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** 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.composition

import kotlinx.serialization.*

/**
* Return all records with a valid `_geoloc` attribute. Don't filter by distance.
*/
@Serializable
public enum class AroundRadiusAll(public val value: kotlin.String) : AroundRadius {

@SerialName(value = "all")
All("all");

override fun toString(): kotlin.String = value
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** 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.composition

import kotlinx.serialization.*
import kotlinx.serialization.json.*

/**
* Banner with image and link to redirect users.
*
* @param image
* @param link
*/
@Serializable
public data class Banner(

@SerialName(value = "image") val image: BannerImage? = null,

@SerialName(value = "link") val link: BannerLink? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** 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.composition

import kotlinx.serialization.*
import kotlinx.serialization.json.*

/**
* Image to show inside a banner.
*
* @param urls
* @param title
*/
@Serializable
public data class BannerImage(

@SerialName(value = "urls") val urls: List<BannerImageUrl>? = null,

@SerialName(value = "title") val title: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** 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.composition

import kotlinx.serialization.*
import kotlinx.serialization.json.*

/**
* URL for an image to show inside a banner.
*
* @param url
*/
@Serializable
public data class BannerImageUrl(

@SerialName(value = "url") val url: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** 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.composition

import kotlinx.serialization.*
import kotlinx.serialization.json.*

/**
* Link for a banner defined in the Merchandising Studio.
*
* @param url
*/
@Serializable
public data class BannerLink(

@SerialName(value = "url") val url: String? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** 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.composition

import kotlinx.serialization.*
import kotlinx.serialization.json.*

/**
* CompositionIdRankingInfo
*
* @param index
* @param injectedItemKey
*/
@Serializable
public data class CompositionIdRankingInfo(

@SerialName(value = "index") val index: String,

@SerialName(value = "injectedItemKey") val injectedItemKey: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** 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.composition

import kotlinx.serialization.*
import kotlinx.serialization.json.*

/**
* CompositionRunAppliedRules
*
* @param objectID Unique record identifier.
*/
@Serializable
public data class CompositionRunAppliedRules(

/** Unique record identifier. */
@SerialName(value = "objectID") val objectID: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/** 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.composition

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

/**
* CompositionRunSearchResponse
*
* @param objectID Unique record identifier.
* @param appliedRules
*/
@Serializable(CompositionRunSearchResponseSerializer::class)
public data class CompositionRunSearchResponse(

/** Unique record identifier. */
val objectID: String,

val appliedRules: List<CompositionRunAppliedRules>? = null,

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

internal object CompositionRunSearchResponseSerializer : KSerializer<CompositionRunSearchResponse> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("CompositionRunSearchResponse") {
element<String>("objectID")
element<List<CompositionRunAppliedRules>>("appliedRules", isOptional = true)
}

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

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

0 comments on commit 4579300

Please sign in to comment.