Skip to content

Commit b9f8671

Browse files
authored
Merge branch 'main' into docs/contributing
2 parents 9a930ae + 2e18da6 commit b9f8671

File tree

79 files changed

+4910
-11
lines changed

Some content is hidden

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

79 files changed

+4910
-11
lines changed

clients/algoliasearch-client-swift/AlgoliaSearchClient.podspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Pod::Spec.new do |s|
2626
subs.source_files = 'Sources/Analytics/**/*.swift'
2727
subs.dependency 'AlgoliaSearchClient/Core'
2828
end
29+
s.subspec 'Composition' do |subs|
30+
subs.source_files = 'Sources/Composition/**/*.swift'
31+
subs.dependency 'AlgoliaSearchClient/Core'
32+
end
2933
s.subspec 'Ingestion' do |subs|
3034
subs.source_files = 'Sources/Ingestion/**/*.swift'
3135
subs.dependency 'AlgoliaSearchClient/Core'

clients/algoliasearch-client-swift/Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ products.append(
5757
[
5858
"Abtesting",
5959
"Analytics",
60+
"Composition",
6061
"Ingestion",
6162
"Insights",
6263
"Monitoring",
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
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+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
open class CompositionClient {
10+
private var configuration: CompositionClientConfiguration
11+
private var transporter: Transporter
12+
13+
var appID: String {
14+
self.configuration.appID
15+
}
16+
17+
public init(configuration: CompositionClientConfiguration, transporter: Transporter) {
18+
self.configuration = configuration
19+
self.transporter = transporter
20+
}
21+
22+
public convenience init(configuration: CompositionClientConfiguration) {
23+
self.init(configuration: configuration, transporter: Transporter(configuration: configuration))
24+
}
25+
26+
public convenience init(appID: String, apiKey: String) throws {
27+
try self.init(configuration: CompositionClientConfiguration(appID: appID, apiKey: apiKey))
28+
}
29+
30+
open func setClientApiKey(apiKey: String) {
31+
self.configuration.apiKey = apiKey
32+
self.transporter.setClientApiKey(apiKey: apiKey)
33+
}
34+
35+
/// - parameter compositionID: (path) Unique Composition ObjectID.
36+
/// - parameter requestBody: (body)
37+
/// - returns: CompositionSearchResponse
38+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
39+
open func search<T: Codable>(
40+
compositionID: String,
41+
requestBody: CompositionRequestBody,
42+
requestOptions: RequestOptions? = nil
43+
) async throws -> CompositionSearchResponse<T> {
44+
let response: Response<CompositionSearchResponse<T>> = try await searchWithHTTPInfo(
45+
compositionID: compositionID,
46+
requestBody: requestBody,
47+
requestOptions: requestOptions
48+
)
49+
50+
guard let body = response.body else {
51+
throw AlgoliaError.missingData
52+
}
53+
54+
return body
55+
}
56+
57+
// Runs a query on a single composition and returns matching results.
58+
// Required API Key ACLs:
59+
// - search
60+
//
61+
// - parameter compositionID: (path) Unique Composition ObjectID.
62+
//
63+
// - parameter requestBody: (body)
64+
// - returns: RequestBuilder<CompositionSearchResponse>
65+
66+
open func searchWithHTTPInfo<T: Codable>(
67+
compositionID: String,
68+
requestBody: CompositionRequestBody,
69+
requestOptions userRequestOptions: RequestOptions? = nil
70+
) async throws -> Response<CompositionSearchResponse<T>> {
71+
guard !compositionID.isEmpty else {
72+
throw AlgoliaError.invalidArgument("compositionID", "search")
73+
}
74+
75+
var resourcePath = "/1/compositions/{compositionID}/run"
76+
let compositionIDPreEscape = "\(APIHelper.mapValueToPathItem(compositionID))"
77+
let compositionIDPostEscape = compositionIDPreEscape
78+
.addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? ""
79+
resourcePath = resourcePath.replacingOccurrences(
80+
of: "{compositionID}",
81+
with: compositionIDPostEscape,
82+
options: .literal,
83+
range: nil
84+
)
85+
let body = requestBody
86+
let queryParameters: [String: Any?]? = nil
87+
88+
let nillableHeaders: [String: Any?]? = nil
89+
90+
let headers = APIHelper.rejectNilHeaders(nillableHeaders)
91+
92+
return try await self.transporter.send(
93+
method: "POST",
94+
path: resourcePath,
95+
data: body,
96+
requestOptions: RequestOptions(
97+
headers: headers,
98+
queryParameters: queryParameters
99+
) + userRequestOptions,
100+
useReadTransporter: true
101+
)
102+
}
103+
104+
/// - parameter compositionID: (path) Unique Composition ObjectID.
105+
/// - parameter facetName: (path) Facet attribute in which to search for values. This attribute must be included in
106+
/// the `attributesForFaceting` index setting with the `searchable()` modifier.
107+
/// - parameter searchForFacetValuesRequest: (body) (optional)
108+
/// - returns: CompositionSearchForFacetValuesResponse
109+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
110+
open func searchForFacetValues(
111+
compositionID: String,
112+
facetName: String,
113+
searchForFacetValuesRequest: CompositionSearchForFacetValuesRequest? = nil,
114+
requestOptions: RequestOptions? = nil
115+
) async throws -> CompositionSearchForFacetValuesResponse {
116+
let response: Response<CompositionSearchForFacetValuesResponse> = try await searchForFacetValuesWithHTTPInfo(
117+
compositionID: compositionID,
118+
facetName: facetName,
119+
searchForFacetValuesRequest: searchForFacetValuesRequest,
120+
requestOptions: requestOptions
121+
)
122+
123+
guard let body = response.body else {
124+
throw AlgoliaError.missingData
125+
}
126+
127+
return body
128+
}
129+
130+
// Searches for values of a specified facet attribute on the composition's main source's index. - By default, facet
131+
// values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching
132+
// for facet values doesn't work if you have **more than 65 searchable facets and searchable attributes combined**.
133+
// Required API Key ACLs:
134+
// - search
135+
//
136+
// - parameter compositionID: (path) Unique Composition ObjectID.
137+
//
138+
// - parameter facetName: (path) Facet attribute in which to search for values. This attribute must be included in
139+
// the `attributesForFaceting` index setting with the `searchable()` modifier.
140+
//
141+
// - parameter searchForFacetValuesRequest: (body) (optional)
142+
// - returns: RequestBuilder<CompositionSearchForFacetValuesResponse>
143+
144+
open func searchForFacetValuesWithHTTPInfo(
145+
compositionID: String,
146+
facetName: String,
147+
searchForFacetValuesRequest: CompositionSearchForFacetValuesRequest? = nil,
148+
requestOptions userRequestOptions: RequestOptions? = nil
149+
) async throws -> Response<CompositionSearchForFacetValuesResponse> {
150+
guard !compositionID.isEmpty else {
151+
throw AlgoliaError.invalidArgument("compositionID", "searchForFacetValues")
152+
}
153+
154+
guard !facetName.isEmpty else {
155+
throw AlgoliaError.invalidArgument("facetName", "searchForFacetValues")
156+
}
157+
158+
var resourcePath = "/1/compositions/{compositionID}/facets/{facetName}/query"
159+
let compositionIDPreEscape = "\(APIHelper.mapValueToPathItem(compositionID))"
160+
let compositionIDPostEscape = compositionIDPreEscape
161+
.addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? ""
162+
resourcePath = resourcePath.replacingOccurrences(
163+
of: "{compositionID}",
164+
with: compositionIDPostEscape,
165+
options: .literal,
166+
range: nil
167+
)
168+
let facetNamePreEscape = "\(APIHelper.mapValueToPathItem(facetName))"
169+
let facetNamePostEscape = facetNamePreEscape
170+
.addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? ""
171+
resourcePath = resourcePath.replacingOccurrences(
172+
of: "{facetName}",
173+
with: facetNamePostEscape,
174+
options: .literal,
175+
range: nil
176+
)
177+
let body = searchForFacetValuesRequest
178+
let queryParameters: [String: Any?]? = nil
179+
180+
let nillableHeaders: [String: Any?]? = nil
181+
182+
let headers = APIHelper.rejectNilHeaders(nillableHeaders)
183+
184+
return try await self.transporter.send(
185+
method: "POST",
186+
path: resourcePath,
187+
data: body ?? AnyCodable(),
188+
requestOptions: RequestOptions(
189+
headers: headers,
190+
queryParameters: queryParameters
191+
) + userRequestOptions,
192+
useReadTransporter: true
193+
)
194+
}
195+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
public struct CompositionClientConfiguration: BaseConfiguration, Credentials {
10+
public let appID: String
11+
public var apiKey: String
12+
public var writeTimeout: TimeInterval
13+
public var readTimeout: TimeInterval
14+
public var logLevel: LogLevel
15+
public var defaultHeaders: [String: String]?
16+
public var hosts: [RetryableHost]
17+
public let compression: CompressionAlgorithm
18+
19+
public init(
20+
appID: String,
21+
apiKey: String,
22+
writeTimeout: TimeInterval = 30,
23+
readTimeout: TimeInterval = 5,
24+
logLevel: LogLevel = DefaultConfiguration.default.logLevel,
25+
defaultHeaders: [String: String]? = DefaultConfiguration.default.defaultHeaders,
26+
hosts: [RetryableHost]? = nil
27+
) throws {
28+
guard !appID.isEmpty else {
29+
throw AlgoliaError.invalidCredentials("appId")
30+
}
31+
32+
guard !apiKey.isEmpty else {
33+
throw AlgoliaError.invalidCredentials("apiKey")
34+
}
35+
36+
self.appID = appID
37+
self.apiKey = apiKey
38+
self.writeTimeout = writeTimeout
39+
self.readTimeout = readTimeout
40+
self.logLevel = logLevel
41+
self.defaultHeaders = [
42+
"X-Algolia-Application-Id": appID,
43+
"X-Algolia-API-Key": apiKey,
44+
"Content-Type": "application/json",
45+
].merging(defaultHeaders ?? [:]) { _, new in new }
46+
self.compression = .none
47+
48+
UserAgentController.append(UserAgent(title: "Composition", version: Version.current.description))
49+
50+
guard let hosts else {
51+
func buildHost(_ components: (suffix: String, callType: RetryableHost.CallTypeSupport)) throws
52+
-> RetryableHost {
53+
guard let url = URL(string: "https://\(appID)\(components.suffix)") else {
54+
throw AlgoliaError.runtimeError("Malformed URL")
55+
}
56+
57+
return RetryableHost(url: url, callType: components.callType)
58+
}
59+
60+
let hosts = try [
61+
("-dsn.algolia.net", .read),
62+
(".algolia.net", .write),
63+
].map(buildHost)
64+
65+
let commonHosts = try [
66+
("-1.algolianet.com", .universal),
67+
("-2.algolianet.com", .universal),
68+
("-3.algolianet.com", .universal),
69+
].map(buildHost).shuffled()
70+
71+
self.hosts = hosts + commonHosts
72+
73+
return
74+
}
75+
76+
self.hosts = hosts
77+
}
78+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
/// Precision of a coordinate-based search in meters to group results with similar distances. The Geo ranking criterion
10+
/// considers all matches within the same range of distances to be equal.
11+
public enum CompositionAroundPrecision: Codable, JSONEncodable, AbstractEncodable {
12+
case int(Int)
13+
case arrayOfCompositionRange([CompositionRange])
14+
15+
public func encode(to encoder: Encoder) throws {
16+
var container = encoder.singleValueContainer()
17+
switch self {
18+
case let .int(value):
19+
try container.encode(value)
20+
case let .arrayOfCompositionRange(value):
21+
try container.encode(value)
22+
}
23+
}
24+
25+
public init(from decoder: Decoder) throws {
26+
let container = try decoder.singleValueContainer()
27+
if let value = try? container.decode(Int.self) {
28+
self = .int(value)
29+
} else if let value = try? container.decode([CompositionRange].self) {
30+
self = .arrayOfCompositionRange(value)
31+
} else {
32+
throw DecodingError.typeMismatch(
33+
Self.Type.self,
34+
.init(
35+
codingPath: decoder.codingPath,
36+
debugDescription: "Unable to decode instance of CompositionAroundPrecision"
37+
)
38+
)
39+
}
40+
}
41+
42+
public func GetActualInstance() -> Encodable {
43+
switch self {
44+
case let .int(value):
45+
value as Int
46+
case let .arrayOfCompositionRange(value):
47+
value as [CompositionRange]
48+
}
49+
}
50+
}
51+
52+
extension CompositionAroundPrecision: Equatable {}
53+
extension CompositionAroundPrecision: Hashable {}

0 commit comments

Comments
 (0)