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 <[email protected]>
Co-authored-by: Kai Welke <[email protected]>
Co-authored-by: shortcuts <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
4 people committed Aug 28, 2024
1 parent 56e1a95 commit 09b7da8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions Sources/Search/Models/AttributeToUpdate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Foundation
import Core
#endif

@available(*, deprecated, message: "This schema is deprecated.")
public enum AttributeToUpdate: Codable, JSONEncodable, AbstractEncodable {
case string(String)
case builtInOperation(BuiltInOperation)
Expand Down
25 changes: 22 additions & 3 deletions Sources/Search/SearchClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,7 @@ open class SearchClient {
open func partialUpdateObject(
indexName: String,
objectID: String,
attributesToUpdate: [String: AttributeToUpdate],
attributesToUpdate: Codable,
createIfNotExists: Bool? = nil,
requestOptions: RequestOptions? = nil
) async throws -> UpdatedAtWithObjectIdResponse {
Expand All @@ -2668,7 +2668,26 @@ open 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.
// 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 @@ -2685,7 +2704,7 @@ open class SearchClient {
open func partialUpdateObjectWithHTTPInfo(
indexName: String,
objectID: String,
attributesToUpdate: [String: AttributeToUpdate],
attributesToUpdate: Codable,
createIfNotExists: Bool? = nil,
requestOptions userRequestOptions: RequestOptions? = nil
) async throws -> Response<UpdatedAtWithObjectIdResponse> {
Expand Down

0 comments on commit 09b7da8

Please sign in to comment.