Skip to content

Commit 5f536fb

Browse files
algolia-bote-krebsshortcutsmillotp
committed
feat(specs): rename composition to composition-full (private) and add composition (public) (generated)
algolia/api-clients-automation#4357 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Emmanuel Krebs <[email protected]> Co-authored-by: shortcuts <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 4c7995d commit 5f536fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2619
-0
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/** Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
2+
* https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
*/
4+
package algoliasearch.api
5+
6+
import algoliasearch.composition.ErrorBase
7+
import algoliasearch.composition.RequestBody
8+
import algoliasearch.composition.SearchForFacetValuesRequest
9+
import algoliasearch.composition.SearchForFacetValuesResponse
10+
import algoliasearch.composition.SearchResponse
11+
import algoliasearch.composition._
12+
import algoliasearch.ApiClient
13+
import algoliasearch.api.CompositionClient.hosts
14+
import algoliasearch.api.CompositionClient.readTimeout
15+
import algoliasearch.api.CompositionClient.writeTimeout
16+
import algoliasearch.api.CompositionClient.connectTimeout
17+
import algoliasearch.config._
18+
import algoliasearch.internal.util._
19+
20+
import java.util.concurrent.TimeUnit
21+
import scala.concurrent.duration.Duration
22+
import scala.concurrent.{ExecutionContext, Future}
23+
import scala.util.Random
24+
25+
object CompositionClient {
26+
27+
/** Creates a new CompositionClient instance using default hosts.
28+
*
29+
* @param appId
30+
* application ID
31+
* @param apiKey
32+
* api key
33+
*
34+
* @param clientOptions
35+
* client options
36+
*/
37+
def apply(
38+
appId: String,
39+
apiKey: String,
40+
clientOptions: ClientOptions = ClientOptions()
41+
) = new CompositionClient(
42+
appId = appId,
43+
apiKey = apiKey,
44+
clientOptions = clientOptions
45+
)
46+
47+
private def readTimeout(): Duration = {
48+
Duration(5000, TimeUnit.MILLISECONDS)
49+
}
50+
51+
private def connectTimeout(): Duration = {
52+
Duration(2000, TimeUnit.MILLISECONDS)
53+
}
54+
55+
private def writeTimeout(): Duration = {
56+
Duration(30000, TimeUnit.MILLISECONDS)
57+
}
58+
59+
private def hosts(appId: String): Seq[Host] = {
60+
val commonHosts = Random.shuffle(
61+
List(
62+
Host(appId + "-1.algolianet.com", Set(CallType.Read, CallType.Write)),
63+
Host(appId + "-2.algolianet.com", Set(CallType.Read, CallType.Write)),
64+
Host(appId + "-3.algolianet.com", Set(CallType.Read, CallType.Write))
65+
)
66+
)
67+
List(
68+
Host(appId + "-dsn.algolia.net", Set(CallType.Read)),
69+
Host(appId + ".algolia.net", Set(CallType.Write))
70+
) ++ commonHosts
71+
}
72+
}
73+
74+
class CompositionClient(
75+
appId: String,
76+
apiKey: String,
77+
clientOptions: ClientOptions = ClientOptions()
78+
) extends ApiClient(
79+
appId = appId,
80+
apiKey = apiKey,
81+
clientName = "Composition",
82+
defaultHosts = hosts(appId),
83+
defaultReadTimeout = readTimeout(),
84+
defaultWriteTimeout = writeTimeout(),
85+
defaultConnectTimeout = connectTimeout(),
86+
formats = JsonSupport.format,
87+
options = clientOptions
88+
) {
89+
90+
/** Runs a query on a single composition and returns matching results.
91+
*
92+
* Required API Key ACLs:
93+
* - search
94+
*
95+
* @param compositionID
96+
* Unique Composition ObjectID.
97+
*/
98+
def search(compositionID: String, requestBody: RequestBody, requestOptions: Option[RequestOptions] = None)(implicit
99+
ec: ExecutionContext
100+
): Future[SearchResponse] = Future {
101+
requireNotNull(compositionID, "Parameter `compositionID` is required when calling `search`.")
102+
requireNotNull(requestBody, "Parameter `requestBody` is required when calling `search`.")
103+
104+
val request = HttpRequest
105+
.builder()
106+
.withMethod("POST")
107+
.withPath(s"/1/compositions/${escape(compositionID)}/run")
108+
.withBody(requestBody)
109+
.withRead(true)
110+
.build()
111+
execute[SearchResponse](request, requestOptions)
112+
}
113+
114+
/** Searches for values of a specified facet attribute on the composition's main source's index. - By default, facet
115+
* values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching for
116+
* facet values doesn't work if you have **more than 65 searchable facets and searchable attributes combined**.
117+
*
118+
* Required API Key ACLs:
119+
* - search
120+
*
121+
* @param compositionID
122+
* Unique Composition ObjectID.
123+
* @param facetName
124+
* Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting`
125+
* index setting with the `searchable()` modifier.
126+
*/
127+
def searchForFacetValues(
128+
compositionID: String,
129+
facetName: String,
130+
searchForFacetValuesRequest: Option[SearchForFacetValuesRequest] = None,
131+
requestOptions: Option[RequestOptions] = None
132+
)(implicit ec: ExecutionContext): Future[SearchForFacetValuesResponse] = Future {
133+
requireNotNull(compositionID, "Parameter `compositionID` is required when calling `searchForFacetValues`.")
134+
requireNotNull(facetName, "Parameter `facetName` is required when calling `searchForFacetValues`.")
135+
136+
val request = HttpRequest
137+
.builder()
138+
.withMethod("POST")
139+
.withPath(s"/1/compositions/${escape(compositionID)}/facets/${escape(facetName)}/query")
140+
.withBody(searchForFacetValuesRequest)
141+
.withRead(true)
142+
.build()
143+
execute[SearchForFacetValuesResponse](request, requestOptions)
144+
}
145+
146+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/** Composition API Composition API.
2+
*
3+
* The version of the OpenAPI document: 1.0.0
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech Do not edit the class manually.
7+
*/
8+
package algoliasearch.composition
9+
10+
import org.json4s._
11+
12+
/** Precision of a coordinate-based search in meters to group results with similar distances. The Geo ranking criterion
13+
* considers all matches within the same range of distances to be equal.
14+
*/
15+
sealed trait AroundPrecision
16+
17+
object AroundPrecision {
18+
19+
case class IntValue(value: Int) extends AroundPrecision
20+
case class SeqOfRange(value: Seq[Range]) extends AroundPrecision
21+
22+
def apply(value: Int): AroundPrecision = {
23+
AroundPrecision.IntValue(value)
24+
}
25+
def apply(value: Seq[Range]): AroundPrecision = {
26+
AroundPrecision.SeqOfRange(value)
27+
}
28+
29+
}
30+
31+
object AroundPrecisionSerializer extends Serializer[AroundPrecision] {
32+
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), AroundPrecision] = {
33+
34+
case (TypeInfo(clazz, _), json) if clazz == classOf[AroundPrecision] =>
35+
json match {
36+
case JInt(value) => AroundPrecision.IntValue(value.toInt)
37+
case JArray(value) if value.forall(_.isInstanceOf[JArray]) => AroundPrecision.SeqOfRange(value.map(_.extract))
38+
case _ => throw new MappingException("Can't convert " + json + " to AroundPrecision")
39+
}
40+
}
41+
42+
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: AroundPrecision =>
43+
value match {
44+
case AroundPrecision.IntValue(value) => JInt(value)
45+
case AroundPrecision.SeqOfRange(value) => JArray(value.map(Extraction.decompose).toList)
46+
}
47+
}
48+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/** Composition API Composition API.
2+
*
3+
* The version of the OpenAPI document: 1.0.0
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech Do not edit the class manually.
7+
*/
8+
package algoliasearch.composition
9+
10+
import algoliasearch.composition.AroundRadiusAll._
11+
12+
import org.json4s._
13+
14+
/** Maximum radius for a search around a central location. This parameter works in combination with the `aroundLatLng`
15+
* and `aroundLatLngViaIP` parameters. By default, the search radius is determined automatically from the density of
16+
* hits around the central location. The search radius is small if there are many hits close to the central
17+
* coordinates.
18+
*/
19+
sealed trait AroundRadius
20+
21+
trait AroundRadiusTrait extends AroundRadius
22+
23+
object AroundRadius {
24+
25+
case class IntValue(value: Int) extends AroundRadius
26+
27+
def apply(value: Int): AroundRadius = {
28+
AroundRadius.IntValue(value)
29+
}
30+
31+
}
32+
33+
object AroundRadiusSerializer extends Serializer[AroundRadius] {
34+
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), AroundRadius] = {
35+
36+
case (TypeInfo(clazz, _), json) if clazz == classOf[AroundRadius] =>
37+
json match {
38+
case JInt(value) => AroundRadius.IntValue(value.toInt)
39+
case value: JString => Extraction.extract[AroundRadiusAll](value)
40+
case _ => throw new MappingException("Can't convert " + json + " to AroundRadius")
41+
}
42+
}
43+
44+
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: AroundRadius =>
45+
value match {
46+
case AroundRadius.IntValue(value) => JInt(value)
47+
case value: AroundRadiusAll => JString(value.toString)
48+
}
49+
}
50+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/** Composition API Composition API.
2+
*
3+
* The version of the OpenAPI document: 1.0.0
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech Do not edit the class manually.
7+
*/
8+
package algoliasearch.composition
9+
10+
import org.json4s._
11+
12+
sealed trait AroundRadiusAll extends AroundRadiusTrait
13+
14+
/** Return all records with a valid `_geoloc` attribute. Don't filter by distance.
15+
*/
16+
object AroundRadiusAll {
17+
case object All extends AroundRadiusAll {
18+
override def toString = "all"
19+
}
20+
val values: Seq[AroundRadiusAll] = Seq(All)
21+
22+
def withName(name: String): AroundRadiusAll = AroundRadiusAll.values
23+
.find(_.toString == name)
24+
.getOrElse(throw new MappingException(s"Unknown AroundRadiusAll value: $name"))
25+
}
26+
27+
class AroundRadiusAllSerializer
28+
extends CustomSerializer[AroundRadiusAll](_ =>
29+
(
30+
{
31+
case JString(value) => AroundRadiusAll.withName(value)
32+
case JNull => null
33+
},
34+
{ case value: AroundRadiusAll =>
35+
JString(value.toString)
36+
}
37+
)
38+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** Composition API Composition API.
2+
*
3+
* The version of the OpenAPI document: 1.0.0
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech Do not edit the class manually.
7+
*/
8+
package algoliasearch.composition
9+
10+
/** Banner with image and link to redirect users.
11+
*/
12+
case class Banner(
13+
image: Option[BannerImage] = scala.None,
14+
link: Option[BannerLink] = scala.None
15+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** Composition API Composition API.
2+
*
3+
* The version of the OpenAPI document: 1.0.0
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech Do not edit the class manually.
7+
*/
8+
package algoliasearch.composition
9+
10+
/** Image to show inside a banner.
11+
*/
12+
case class BannerImage(
13+
urls: Option[Seq[BannerImageUrl]] = scala.None,
14+
title: Option[String] = scala.None
15+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** Composition API Composition API.
2+
*
3+
* The version of the OpenAPI document: 1.0.0
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech Do not edit the class manually.
7+
*/
8+
package algoliasearch.composition
9+
10+
/** URL for an image to show inside a banner.
11+
*/
12+
case class BannerImageUrl(
13+
url: Option[String] = scala.None
14+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** Composition API Composition API.
2+
*
3+
* The version of the OpenAPI document: 1.0.0
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech Do not edit the class manually.
7+
*/
8+
package algoliasearch.composition
9+
10+
/** Link for a banner defined in the Merchandising Studio.
11+
*/
12+
case class BannerLink(
13+
url: Option[String] = scala.None
14+
)

0 commit comments

Comments
 (0)