From caa12514a29579a804be91803f756c04f6beb438 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Wed, 11 Sep 2024 15:28:07 +0000 Subject: [PATCH] chore(scripts): improve release script with git diff [skip-bc] (generated) https://github.com/algolia/api-clients-automation/pull/3686 Co-authored-by: Pierre Millot --- .github/ISSUE_TEMPLATE/Bug_report.yml | 1 - AlgoliaSearchClient.podspec | 4 - Package.swift | 1 - Sources/Usage/Models/ErrorItem.swift | 56 -- Sources/Usage/Models/ForbiddenError.swift | 50 - Sources/Usage/Models/Granularity.swift | 14 - Sources/Usage/Models/IndexUsage.swift | 38 - Sources/Usage/Models/InvalidRequest.swift | 38 - .../Usage/Models/InvalidRequestError.swift | 50 - Sources/Usage/Models/Statistic.swift | 96 -- Sources/Usage/Models/StatisticEntry.swift | 45 - Sources/Usage/Models/StatisticValue.swift | 48 - Sources/Usage/Models/UsageErrorBase.swift | 86 -- Sources/Usage/Models/UsageForbidden.swift | 38 - Sources/Usage/UsageClient.swift | 881 ------------------ Sources/Usage/UsageClientConfiguration.swift | 59 -- 16 files changed, 1505 deletions(-) delete mode 100644 Sources/Usage/Models/ErrorItem.swift delete mode 100644 Sources/Usage/Models/ForbiddenError.swift delete mode 100644 Sources/Usage/Models/Granularity.swift delete mode 100644 Sources/Usage/Models/IndexUsage.swift delete mode 100644 Sources/Usage/Models/InvalidRequest.swift delete mode 100644 Sources/Usage/Models/InvalidRequestError.swift delete mode 100644 Sources/Usage/Models/Statistic.swift delete mode 100644 Sources/Usage/Models/StatisticEntry.swift delete mode 100644 Sources/Usage/Models/StatisticValue.swift delete mode 100644 Sources/Usage/Models/UsageErrorBase.swift delete mode 100644 Sources/Usage/Models/UsageForbidden.swift delete mode 100644 Sources/Usage/UsageClient.swift delete mode 100644 Sources/Usage/UsageClientConfiguration.swift diff --git a/.github/ISSUE_TEMPLATE/Bug_report.yml b/.github/ISSUE_TEMPLATE/Bug_report.yml index e919fd952..ecf2dfdbd 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.yml +++ b/.github/ISSUE_TEMPLATE/Bug_report.yml @@ -39,7 +39,6 @@ body: - Query-Suggestions - Recommend - Search - - Usage - Crawler validations: required: true diff --git a/AlgoliaSearchClient.podspec b/AlgoliaSearchClient.podspec index de82cec1c..58cd67fb6 100644 --- a/AlgoliaSearchClient.podspec +++ b/AlgoliaSearchClient.podspec @@ -54,8 +54,4 @@ Pod::Spec.new do |s| subs.source_files = 'Sources/Search/**/*.swift' subs.dependency 'AlgoliaSearchClient/Core' end - s.subspec 'Usage' do |subs| - subs.source_files = 'Sources/Usage/**/*.swift' - subs.dependency 'AlgoliaSearchClient/Core' - end end \ No newline at end of file diff --git a/Package.swift b/Package.swift index 7469a0c64..a6816a4ff 100644 --- a/Package.swift +++ b/Package.swift @@ -64,7 +64,6 @@ products.append( "QuerySuggestions", "Recommend", "Search", - "Usage", ].enumerated().forEach { _, library in targets.append( .target( diff --git a/Sources/Usage/Models/ErrorItem.swift b/Sources/Usage/Models/ErrorItem.swift deleted file mode 100644 index 925f42e67..000000000 --- a/Sources/Usage/Models/ErrorItem.swift +++ /dev/null @@ -1,56 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public struct ErrorItem: Codable, JSONEncodable { - public var code: String? - public var message: String - public var line: Int? - public var position: Int? - - public init(code: String? = nil, message: String, line: Int? = nil, position: Int? = nil) { - self.code = code - self.message = message - self.line = line - self.position = position - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case code - case message - case line - case position - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.code, forKey: .code) - try container.encode(self.message, forKey: .message) - try container.encodeIfPresent(self.line, forKey: .line) - try container.encodeIfPresent(self.position, forKey: .position) - } -} - -extension ErrorItem: Equatable { - public static func ==(lhs: ErrorItem, rhs: ErrorItem) -> Bool { - lhs.code == rhs.code && - lhs.message == rhs.message && - lhs.line == rhs.line && - lhs.position == rhs.position - } -} - -extension ErrorItem: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.code?.hashValue) - hasher.combine(self.message.hashValue) - hasher.combine(self.line?.hashValue) - hasher.combine(self.position?.hashValue) - } -} diff --git a/Sources/Usage/Models/ForbiddenError.swift b/Sources/Usage/Models/ForbiddenError.swift deleted file mode 100644 index bb01acc18..000000000 --- a/Sources/Usage/Models/ForbiddenError.swift +++ /dev/null @@ -1,50 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public struct ForbiddenError: Codable, JSONEncodable { - public var code: String? - public var message: String? - public var errors: [ErrorItem]? - - public init(code: String? = nil, message: String? = nil, errors: [ErrorItem]? = nil) { - self.code = code - self.message = message - self.errors = errors - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case code - case message - case errors - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.code, forKey: .code) - try container.encodeIfPresent(self.message, forKey: .message) - try container.encodeIfPresent(self.errors, forKey: .errors) - } -} - -extension ForbiddenError: Equatable { - public static func ==(lhs: ForbiddenError, rhs: ForbiddenError) -> Bool { - lhs.code == rhs.code && - lhs.message == rhs.message && - lhs.errors == rhs.errors - } -} - -extension ForbiddenError: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.code?.hashValue) - hasher.combine(self.message?.hashValue) - hasher.combine(self.errors?.hashValue) - } -} diff --git a/Sources/Usage/Models/Granularity.swift b/Sources/Usage/Models/Granularity.swift deleted file mode 100644 index 84eeebd53..000000000 --- a/Sources/Usage/Models/Granularity.swift +++ /dev/null @@ -1,14 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public enum Granularity: String, Codable, CaseIterable { - case hourly - case daily -} - -extension Granularity: Hashable {} diff --git a/Sources/Usage/Models/IndexUsage.swift b/Sources/Usage/Models/IndexUsage.swift deleted file mode 100644 index f6ba27864..000000000 --- a/Sources/Usage/Models/IndexUsage.swift +++ /dev/null @@ -1,38 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public struct IndexUsage: Codable, JSONEncodable { - public var statistics: [StatisticEntry]? - - public init(statistics: [StatisticEntry]? = nil) { - self.statistics = statistics - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case statistics - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.statistics, forKey: .statistics) - } -} - -extension IndexUsage: Equatable { - public static func ==(lhs: IndexUsage, rhs: IndexUsage) -> Bool { - lhs.statistics == rhs.statistics - } -} - -extension IndexUsage: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.statistics?.hashValue) - } -} diff --git a/Sources/Usage/Models/InvalidRequest.swift b/Sources/Usage/Models/InvalidRequest.swift deleted file mode 100644 index 3ebb41662..000000000 --- a/Sources/Usage/Models/InvalidRequest.swift +++ /dev/null @@ -1,38 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public struct InvalidRequest: Codable, JSONEncodable { - public var error: InvalidRequestError - - public init(error: InvalidRequestError) { - self.error = error - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case error - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self.error, forKey: .error) - } -} - -extension InvalidRequest: Equatable { - public static func ==(lhs: InvalidRequest, rhs: InvalidRequest) -> Bool { - lhs.error == rhs.error - } -} - -extension InvalidRequest: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.error.hashValue) - } -} diff --git a/Sources/Usage/Models/InvalidRequestError.swift b/Sources/Usage/Models/InvalidRequestError.swift deleted file mode 100644 index 2614ba5d4..000000000 --- a/Sources/Usage/Models/InvalidRequestError.swift +++ /dev/null @@ -1,50 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public struct InvalidRequestError: Codable, JSONEncodable { - public var code: String? - public var message: String? - public var errors: [ErrorItem]? - - public init(code: String? = nil, message: String? = nil, errors: [ErrorItem]? = nil) { - self.code = code - self.message = message - self.errors = errors - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case code - case message - case errors - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.code, forKey: .code) - try container.encodeIfPresent(self.message, forKey: .message) - try container.encodeIfPresent(self.errors, forKey: .errors) - } -} - -extension InvalidRequestError: Equatable { - public static func ==(lhs: InvalidRequestError, rhs: InvalidRequestError) -> Bool { - lhs.code == rhs.code && - lhs.message == rhs.message && - lhs.errors == rhs.errors - } -} - -extension InvalidRequestError: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.code?.hashValue) - hasher.combine(self.message?.hashValue) - hasher.combine(self.errors?.hashValue) - } -} diff --git a/Sources/Usage/Models/Statistic.swift b/Sources/Usage/Models/Statistic.swift deleted file mode 100644 index 7bdb291af..000000000 --- a/Sources/Usage/Models/Statistic.swift +++ /dev/null @@ -1,96 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public enum Statistic: String, Codable, CaseIterable { - case star = "*" - case searchOperations = "search_operations" - case totalSearchOperations = "total_search_operations" - case totalSearchRequests = "total_search_requests" - case queriesOperations = "queries_operations" - case multiQueriesOperations = "multi_queries_operations" - case aclOperations = "acl_operations" - case totalAclOperations = "total_acl_operations" - case getApiKeysOperations = "get_api_keys_operations" - case getApiKeyOperations = "get_api_key_operations" - case addApiKeyOperations = "add_api_key_operations" - case updateApiKeyOperations = "update_api_key_operations" - case deleteApiKeyOperations = "delete_api_key_operations" - case listApiKeyOperations = "list_api_key_operations" - case indexingOperations = "indexing_operations" - case totalIndexingOperations = "total_indexing_operations" - case browseOperations = "browse_operations" - case clearIndexOperations = "clear_index_operations" - case copyMoveOperations = "copy_move_operations" - case deleteIndexOperations = "delete_index_operations" - case getLogOperations = "get_log_operations" - case getSettingsOperations = "get_settings_operations" - case setSettingsOperations = "set_settings_operations" - case listIndicesOperations = "list_indices_operations" - case waitTaskOperations = "wait_task_operations" - case recordOperations = "record_operations" - case totalRecordsOperations = "total_records_operations" - case addRecordOperations = "add_record_operations" - case batchOperations = "batch_operations" - case deleteByQueryOperations = "delete_by_query_operations" - case deleteRecordOperations = "delete_record_operations" - case getRecordOperations = "get_record_operations" - case partialUpdateRecordOperations = "partial_update_record_operations" - case updateRecordOperations = "update_record_operations" - case synonymOperations = "synonym_operations" - case totalSynonymOperations = "total_synonym_operations" - case batchSynonymOperations = "batch_synonym_operations" - case clearSynonymOperations = "clear_synonym_operations" - case deleteSynonymOperations = "delete_synonym_operations" - case getSynonymOperations = "get_synonym_operations" - case querySynonymOperations = "query_synonym_operations" - case updateSynonymOperations = "update_synonym_operations" - case ruleOperations = "rule_operations" - case totalRulesOperations = "total_rules_operations" - case batchRulesOperations = "batch_rules_operations" - case clearRulesOperations = "clear_rules_operations" - case deleteRulesOperations = "delete_rules_operations" - case getRulesOperations = "get_rules_operations" - case saveRulesOperations = "save_rules_operations" - case searchRulesOperations = "search_rules_operations" - case totalRecommendRequests = "total_recommend_requests" - case totalWriteOperations = "total_write_operations" - case totalReadOperations = "total_read_operations" - case totalOperations = "total_operations" - case querysuggestionsTotalSearchOperations = "querysuggestions_total_search_operations" - case querysuggestionsTotalSearchRequests = "querysuggestions_total_search_requests" - case querysuggestionsTotalAclOperations = "querysuggestions_total_acl_operations" - case querysuggestionsTotalIndexingOperations = "querysuggestions_total_indexing_operations" - case querysuggestionsTotalRecordsOperations = "querysuggestions_total_records_operations" - case querysuggestionsTotalSynonymOperations = "querysuggestions_total_synonym_operations" - case querysuggestionsTotalRulesOperations = "querysuggestions_total_rules_operations" - case querysuggestionsTotalWriteOperations = "querysuggestions_total_write_operations" - case querysuggestionsTotalReadOperations = "querysuggestions_total_read_operations" - case querysuggestionsTotalOperations = "querysuggestions_total_operations" - case avgProcessingTime = "avg_processing_time" - case _90pProcessingTime = "90p_processing_time" - case _99pProcessingTime = "99p_processing_time" - case queriesAboveLastMsProcessingTime = "queries_above_last_ms_processing_time" - case records - case dataSize = "data_size" - case fileSize = "file_size" - case maxQps = "max_qps" - case regionMaxQps = "region_max_qps" - case totalMaxQps = "total_max_qps" - case usedSearchCapacity = "used_search_capacity" - case avgUsedSearchCapacity = "avg_used_search_capacity" - case regionUsedSearchCapacity = "region_used_search_capacity" - case regionAvgUsedSearchCapacity = "region_avg_used_search_capacity" - case totalUsedSearchCapacity = "total_used_search_capacity" - case totalAvgUsedSearchCapacity = "total_avg_used_search_capacity" - case degradedQueriesSsdUsedQueriesImpacted = "degraded_queries_ssd_used_queries_impacted" - case degradedQueriesSsdUsedSecondsImpacted = "degraded_queries_ssd_used_seconds_impacted" - case degradedQueriesMaxCapacityQueriesImpacted = "degraded_queries_max_capacity_queries_impacted" - case degradedQueriesMaxCapacitySecondsImpacted = "degraded_queries_max_capacity_seconds_impacted" -} - -extension Statistic: Hashable {} diff --git a/Sources/Usage/Models/StatisticEntry.swift b/Sources/Usage/Models/StatisticEntry.swift deleted file mode 100644 index 314659965..000000000 --- a/Sources/Usage/Models/StatisticEntry.swift +++ /dev/null @@ -1,45 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public struct StatisticEntry: Codable, JSONEncodable { - /// Timestamp, measured in milliseconds since the Unix epoch. - public var t: Int? - public var v: StatisticValue? - - public init(t: Int? = nil, v: StatisticValue? = nil) { - self.t = t - self.v = v - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case t - case v - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.t, forKey: .t) - try container.encodeIfPresent(self.v, forKey: .v) - } -} - -extension StatisticEntry: Equatable { - public static func ==(lhs: StatisticEntry, rhs: StatisticEntry) -> Bool { - lhs.t == rhs.t && - lhs.v == rhs.v - } -} - -extension StatisticEntry: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.t?.hashValue) - hasher.combine(self.v?.hashValue) - } -} diff --git a/Sources/Usage/Models/StatisticValue.swift b/Sources/Usage/Models/StatisticValue.swift deleted file mode 100644 index 33f9fbfa9..000000000 --- a/Sources/Usage/Models/StatisticValue.swift +++ /dev/null @@ -1,48 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public enum StatisticValue: Codable, JSONEncodable, AbstractEncodable { - case int(Int) - case dictionaryOfStringToInt([String: Int]) - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - switch self { - case let .int(value): - try container.encode(value) - case let .dictionaryOfStringToInt(value): - try container.encode(value) - } - } - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - if let value = try? container.decode(Int.self) { - self = .int(value) - } else if let value = try? container.decode([String: Int].self) { - self = .dictionaryOfStringToInt(value) - } else { - throw DecodingError.typeMismatch( - Self.Type.self, - .init(codingPath: decoder.codingPath, debugDescription: "Unable to decode instance of StatisticValue") - ) - } - } - - public func GetActualInstance() -> Encodable { - switch self { - case let .int(value): - value as Int - case let .dictionaryOfStringToInt(value): - value as [String: Int] - } - } -} - -extension StatisticValue: Equatable {} -extension StatisticValue: Hashable {} diff --git a/Sources/Usage/Models/UsageErrorBase.swift b/Sources/Usage/Models/UsageErrorBase.swift deleted file mode 100644 index c90576121..000000000 --- a/Sources/Usage/Models/UsageErrorBase.swift +++ /dev/null @@ -1,86 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -/// Error. -public struct UsageErrorBase: Codable, JSONEncodable { - public var message: String? - - public init(message: String? = nil) { - self.message = message - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case message - } - - public var additionalProperties: [String: AnyCodable] = [:] - - public subscript(key: String) -> AnyCodable? { - get { - if let value = additionalProperties[key] { - return value - } - return nil - } - - set { - self.additionalProperties[key] = newValue - } - } - - public init(from dictionary: [String: AnyCodable]) throws { - self.message = dictionary["message"]?.value as? String - - for (key, value) in dictionary { - switch key { - case "message": - continue - default: - self.additionalProperties[key] = value - } - } - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.message, forKey: .message) - var additionalPropertiesContainer = encoder.container(keyedBy: String.self) - try additionalPropertiesContainer.encodeMap(self.additionalProperties) - } - - // Decodable protocol methods - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - self.message = try container.decodeIfPresent(String.self, forKey: .message) - var nonAdditionalPropertyKeys = Set() - nonAdditionalPropertyKeys.insert("message") - let additionalPropertiesContainer = try decoder.container(keyedBy: String.self) - self.additionalProperties = try additionalPropertiesContainer.decodeMap( - AnyCodable.self, - excludedKeys: nonAdditionalPropertyKeys - ) - } -} - -extension UsageErrorBase: Equatable { - public static func ==(lhs: UsageErrorBase, rhs: UsageErrorBase) -> Bool { - lhs.message == rhs.message - && lhs.additionalProperties == rhs.additionalProperties - } -} - -extension UsageErrorBase: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.message?.hashValue) - hasher.combine(self.additionalProperties.hashValue) - } -} diff --git a/Sources/Usage/Models/UsageForbidden.swift b/Sources/Usage/Models/UsageForbidden.swift deleted file mode 100644 index 6deb4963b..000000000 --- a/Sources/Usage/Models/UsageForbidden.swift +++ /dev/null @@ -1,38 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public struct UsageForbidden: Codable, JSONEncodable { - public var error: ForbiddenError - - public init(error: ForbiddenError) { - self.error = error - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case error - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self.error, forKey: .error) - } -} - -extension UsageForbidden: Equatable { - public static func ==(lhs: UsageForbidden, rhs: UsageForbidden) -> Bool { - lhs.error == rhs.error - } -} - -extension UsageForbidden: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.error.hashValue) - } -} diff --git a/Sources/Usage/UsageClient.swift b/Sources/Usage/UsageClient.swift deleted file mode 100644 index 7f5d009c3..000000000 --- a/Sources/Usage/UsageClient.swift +++ /dev/null @@ -1,881 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -open class UsageClient { - private var configuration: UsageClientConfiguration - private var transporter: Transporter - - var appID: String { - self.configuration.appID - } - - public init(configuration: UsageClientConfiguration, transporter: Transporter) { - self.configuration = configuration - self.transporter = transporter - } - - public convenience init(configuration: UsageClientConfiguration) { - self.init(configuration: configuration, transporter: Transporter(configuration: configuration)) - } - - public convenience init(appID: String, apiKey: String) throws { - try self.init(configuration: UsageClientConfiguration(appID: appID, apiKey: apiKey)) - } - - open func setClientApiKey(apiKey: String) { - self.configuration.apiKey = apiKey - self.transporter.setClientApiKey(apiKey: apiKey) - } - - /// - parameter path: (path) Path of the endpoint, anything after \"/1\" must be specified. - /// - parameter parameters: (query) Query parameters to apply to the current query. (optional) - /// - returns: AnyCodable - @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) - open func customDelete( - path: String, - parameters: [String: AnyCodable]? = nil, - requestOptions: RequestOptions? = nil - ) async throws -> AnyCodable { - let response: Response = try await customDeleteWithHTTPInfo( - path: path, - parameters: parameters, - requestOptions: requestOptions - ) - - guard let body = response.body else { - throw AlgoliaError.missingData - } - - return body - } - - // This method allow you to send requests to the Algolia REST API. - // - // - // - parameter path: (path) Path of the endpoint, anything after \"/1\" must be specified. - // - // - parameter parameters: (query) Query parameters to apply to the current query. (optional) - // - returns: RequestBuilder - - open func customDeleteWithHTTPInfo( - path: String, - parameters: [String: AnyCodable]? = nil, - requestOptions userRequestOptions: RequestOptions? = nil - ) async throws -> Response { - guard !path.isEmpty else { - throw AlgoliaError.invalidArgument("path", "customDelete") - } - - var resourcePath = "/{path}" - let pathPreEscape = "\(APIHelper.mapValueToPathItem(path))" - resourcePath = resourcePath.replacingOccurrences( - of: "{path}", - with: pathPreEscape, - options: .literal, - range: nil - ) - let body: AnyCodable? = nil - let queryParameters: [String: AnyCodable]? = parameters - - let nillableHeaders: [String: Any?]? = nil - - let headers = APIHelper.rejectNilHeaders(nillableHeaders) - - return try await self.transporter.send( - method: "DELETE", - path: resourcePath, - data: body, - requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions - ) - } - - /// - parameter path: (path) Path of the endpoint, anything after \"/1\" must be specified. - /// - parameter parameters: (query) Query parameters to apply to the current query. (optional) - /// - returns: AnyCodable - @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) - open func customGet( - path: String, - parameters: [String: AnyCodable]? = nil, - requestOptions: RequestOptions? = nil - ) async throws -> AnyCodable { - let response: Response = try await customGetWithHTTPInfo( - path: path, - parameters: parameters, - requestOptions: requestOptions - ) - - guard let body = response.body else { - throw AlgoliaError.missingData - } - - return body - } - - // This method allow you to send requests to the Algolia REST API. - // - // - // - parameter path: (path) Path of the endpoint, anything after \"/1\" must be specified. - // - // - parameter parameters: (query) Query parameters to apply to the current query. (optional) - // - returns: RequestBuilder - - open func customGetWithHTTPInfo( - path: String, - parameters: [String: AnyCodable]? = nil, - requestOptions userRequestOptions: RequestOptions? = nil - ) async throws -> Response { - guard !path.isEmpty else { - throw AlgoliaError.invalidArgument("path", "customGet") - } - - var resourcePath = "/{path}" - let pathPreEscape = "\(APIHelper.mapValueToPathItem(path))" - resourcePath = resourcePath.replacingOccurrences( - of: "{path}", - with: pathPreEscape, - options: .literal, - range: nil - ) - let body: AnyCodable? = nil - let queryParameters: [String: AnyCodable]? = parameters - - let nillableHeaders: [String: Any?]? = nil - - let headers = APIHelper.rejectNilHeaders(nillableHeaders) - - return try await self.transporter.send( - method: "GET", - path: resourcePath, - data: body, - requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions - ) - } - - /// - parameter path: (path) Path of the endpoint, anything after \"/1\" must be specified. - /// - parameter parameters: (query) Query parameters to apply to the current query. (optional) - /// - parameter body: (body) Parameters to send with the custom request. (optional) - /// - returns: AnyCodable - @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) - open func customPost( - path: String, - parameters: [String: AnyCodable]? = nil, - body: Codable? = nil, - requestOptions: RequestOptions? = nil - ) async throws -> AnyCodable { - let response: Response = try await customPostWithHTTPInfo( - path: path, - parameters: parameters, - body: body, - requestOptions: requestOptions - ) - - guard let body = response.body else { - throw AlgoliaError.missingData - } - - return body - } - - // This method allow you to send requests to the Algolia REST API. - // - // - // - parameter path: (path) Path of the endpoint, anything after \"/1\" must be specified. - // - // - parameter parameters: (query) Query parameters to apply to the current query. (optional) - // - // - parameter body: (body) Parameters to send with the custom request. (optional) - // - returns: RequestBuilder - - open func customPostWithHTTPInfo( - path: String, - parameters: [String: AnyCodable]? = nil, - body: Codable? = nil, - requestOptions userRequestOptions: RequestOptions? = nil - ) async throws -> Response { - guard !path.isEmpty else { - throw AlgoliaError.invalidArgument("path", "customPost") - } - - var resourcePath = "/{path}" - let pathPreEscape = "\(APIHelper.mapValueToPathItem(path))" - resourcePath = resourcePath.replacingOccurrences( - of: "{path}", - with: pathPreEscape, - options: .literal, - range: nil - ) - let body = body - let queryParameters: [String: AnyCodable]? = parameters - - let nillableHeaders: [String: Any?]? = nil - - let headers = APIHelper.rejectNilHeaders(nillableHeaders) - - return try await self.transporter.send( - method: "POST", - path: resourcePath, - data: body ?? AnyCodable(), - requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions - ) - } - - /// - parameter path: (path) Path of the endpoint, anything after \"/1\" must be specified. - /// - parameter parameters: (query) Query parameters to apply to the current query. (optional) - /// - parameter body: (body) Parameters to send with the custom request. (optional) - /// - returns: AnyCodable - @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) - open func customPut( - path: String, - parameters: [String: AnyCodable]? = nil, - body: Codable? = nil, - requestOptions: RequestOptions? = nil - ) async throws -> AnyCodable { - let response: Response = try await customPutWithHTTPInfo( - path: path, - parameters: parameters, - body: body, - requestOptions: requestOptions - ) - - guard let body = response.body else { - throw AlgoliaError.missingData - } - - return body - } - - // This method allow you to send requests to the Algolia REST API. - // - // - // - parameter path: (path) Path of the endpoint, anything after \"/1\" must be specified. - // - // - parameter parameters: (query) Query parameters to apply to the current query. (optional) - // - // - parameter body: (body) Parameters to send with the custom request. (optional) - // - returns: RequestBuilder - - open func customPutWithHTTPInfo( - path: String, - parameters: [String: AnyCodable]? = nil, - body: Codable? = nil, - requestOptions userRequestOptions: RequestOptions? = nil - ) async throws -> Response { - guard !path.isEmpty else { - throw AlgoliaError.invalidArgument("path", "customPut") - } - - var resourcePath = "/{path}" - let pathPreEscape = "\(APIHelper.mapValueToPathItem(path))" - resourcePath = resourcePath.replacingOccurrences( - of: "{path}", - with: pathPreEscape, - options: .literal, - range: nil - ) - let body = body - let queryParameters: [String: AnyCodable]? = parameters - - let nillableHeaders: [String: Any?]? = nil - - let headers = APIHelper.rejectNilHeaders(nillableHeaders) - - return try await self.transporter.send( - method: "PUT", - path: resourcePath, - data: body ?? AnyCodable(), - requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions - ) - } - - /// - parameter statistic: (path) Usage statistics to retrieve. Use `*` to retrieve all usage metrics, otherwise - /// add - /// one or more of the following metrics, separated by a comma. **Search operations** - `search_operations`. All - /// search operations. - `total_search_operations`: Sum of all search operations. - `total_search_requests`: Sum of - /// all [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - /// The number of billed search requests is equal to this value minus `querysuggestions_total_search_requests`. - - /// `queries_operations`. Number of [single index search](/specs/search#tag/Search/operation/searchSingleIndex) - /// operations. - `multi_queries_operations`. Number of [multi-index - /// search](/specs/search#tag/Search/operation/search) operations. **ACL operations** - `acl_operations`. All ACL - /// operations. - `total_acl_operations`. Sum of all ACL operations. - `get_api_keys_operations`. Number of [list - /// API - /// keys](/specs/search#tag/Api-Keys/operation/listApiKeys) operations. - `get_api_key_operations`. Number of [get - /// API - /// key permission](/specs/search#tag/Api-Keys/operation/getApiKey) operations. - `add_api_key_operations`. Number - /// of - /// [create API key](/specs/search#tag/Api-Keys/operation/addApiKey) operations. - `update_api_key_operations`. - /// Number - /// of [update API key](/specs/search#tag/Api-Keys/operation/updateApiKey) operations. - - /// `delete_api_key_operations`. - /// Number of [delete API key](/specs/search#tag/Api-Keys/operation/deleteApiKey) operations. - - /// `list_api_key_operations`. Number of list index API keys operations. **Indexing operations** - - /// `indexing_operations`. All indexing operations. - `total_indexing_operations`. Sum of all indexing operations. - - /// `browse_operations`. Number of [browse index](/specs/search#tag/Search/operation/browse) operations. - - /// `clear_index_operations`. Number of [clear records](/specs/search#tag/Records/operation/clearObjects) - /// operations. - /// - `copy_move_operations`. Number of [copy or move index](/specs/search#tag/Indices/operation/operationIndex) - /// operations. - `delete_index_operations`. Number of [delete - /// index](/specs/search#tag/Indices/operation/deleteIndex) - /// operations. - `get_log_operations`. Number of [get logs](/specs/search#tag/Advanced/operation/getLogs) - /// operations. - /// - `get_settings_operations`. Number of [get settings](/specs/search#operation/getIndexUsage) operations. - - /// `set_settings_operations`. Number of [set settings](/specs/search#tag/Indices/operation/setSettings) operations. - /// - - /// `list_indices_operations`. Number of [list indices](/specs/search#tag/Indices/operation/listIndices) operations. - /// - - /// `wait_task_operations`. Number of [wait](/specs/search#tag/Indices/operation/getTask) operations. **Record - /// operations** - `record_operations`. All record operations. - `total_records_operations`. Sum of all record - /// operations. - `add_record_operations`. Number of [add or replace - /// record](/specs/search#tag/Records/operation/saveObject) operations. - `batch_operations`. Number of [batch - /// indexing](/specs/search#tag/Records/operation/multipleBatch) operations. - `delete_by_query_operations`. Number - /// of - /// [delete by query](/specs/search#tag/Records/operation/deleteBy) operations. - `delete_record_operations`. Number - /// of [delete record](/specs/search#tag/Records/operation/deleteObject) operations. - `get_record_operations`. - /// Number - /// of [get record](/specs/search#tag/Records/operation/getObject) operations. - `partial_update_record_operations`. - /// Number of [partially update records](/specs/search#tag/Records/operation/partialUpdateObject) operations. - - /// `update_record_operations`. Number of [add or replace record by - /// objectID](/specs/search#tag/Records/operation/addOrUpdateObject) operations. **Synonym operations** - - /// `synonym_operations`. All synonym operations. - `total_synonym_operations`. Sum of all synonym operations. - - /// `batch_synonym_operations`. Number of [save all synonyms](/specs/search#tag/Synonyms/operation/saveSynonyms) - /// operations. - `clear_synonym_operations`. Number of [clear - /// synonyms](/specs/search#tag/Synonyms/operation/clearSynonyms) operations. - `delete_synonym_operations`. Number - /// of - /// [delete synonym](/specs/search#tag/Synonyms/operation/deleteSynonym) operations. - `get_synonym_operations`. - /// Number of [get synonym](/specs/search#tag/Synonyms/operation/getSynonym) operations. - - /// `query_synonym_operations`. - /// Number of [search synonyms](/specs/search#tag/Synonyms/operation/searchSynonyms) operations. - - /// `update_synonym_operations`. Number of [save a synonym](/specs/search#tag/Synonyms/operation/saveSynonym) - /// operations. **Rule operations** - `rule_operations`. All rule operations. - `total_rules_operations`. Sum of - /// all - /// rule operations. - `batch_rules_operations`. Number of [batch - /// rules](/specs/search#tag/Rules/operation/saveRules) - /// operations. - `clear_rules_operations`. Number of [delete rule](/specs/search#tag/Rules/operation/deleteRule) - /// operations. - `delete_rules_operations`. Number of [clear rules](/specs/search#tag/Rules/operation/clearRules) - /// operations. - `get_rules_operations`. Number of [get rule](/specs/search#tag/Rules/operation/getRule) - /// operations. - /// - `save_rules_operations`. Number of [save rule](/specs/search#operation/getIndexUsage) operations. - - /// `search_rules_operations`. Number of [search rules](/specs/search#tag/Rules/operation/searchRules) operations. - /// **Total operations** - `total_recommend_requests`. Number of [Recommend - /// requests](https://www.algolia.com/doc/guides/algolia-ai/recommend/) - `total_write_operations`. Number of Write - /// operations - `total_read_operations`. Number of read operations - `total_operations`. Sum of all operations - /// **Total Query Suggestions operations** Query Suggestions operations are a subset of `total_search_operations`. - /// - - /// `querysuggestions_total_search_operations`. Number of Query Suggestions search operations. - - /// `querysuggestions_total_search_requests`. Number of Query Suggestions [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - /// - `querysuggestions_total_acl_operations`. Sum of all Query Suggestions [ACL operations](#acl-operations). - - /// `querysuggestions_total_indexing_operations`. Number of Query Suggestions [indexing - /// operations](#indexing-operations). - `querysuggestions_total_records_operations`. Number of Query Suggestions - /// [record operations](#record-operations). - `querysuggestions_total_synonym_operations`. Number of Query - /// Suggestions [synonym operations](#synonym-operations). - `querysuggestions_total_rules_operations`. Number of - /// Query Suggestions [Rule operations](#rule-operations). - `querysuggestions_total_write_operations`. Number of - /// Query Suggestions Write operations. - `querysuggestions_total_read_operations`. Number of Query Suggestions Read - /// operations. - `querysuggestions_total_operations`. Sum of all Query Suggestions operations. **Processing time** - /// - /// - `avg_processing_time`. Average processing time (in milliseconds). - `90p_processing_time`. 90th percentile of - /// processing time (in milliseconds). - `99p_processing_time`. 99th percentile of processing time (in - /// milliseconds). - /// - `queries_above_last_ms_processing_time`. Number of queries that take one or more seconds to process. - /// **Indices** - `records`. Number of records. - `data_size`. The size of the records (in bytes). - `file_size`. - /// The - /// size of the records _and_ index metadata (in bytes). **Maximum queries per second** - `max_qps`. [Maximum - /// queries per second](https://support.algolia.com/hc/en-us/articles/4406975224721) per server. - `region_max_qps`. - /// Maximum queries per second per region. - `total_max_qps`. Maximum queries per second across all servers. **Used - /// search capacity** The following capacities are reported in percent: - `used_search_capacity`. Maximum search - /// capacity used per server. - `avg_used_search_capacity`. Average search capacity used per server. - - /// `region_used_search_capacity`. Maximum search capacity used per region. - `region_avg_used_search_capacity`. - /// Average search capacity used per region. - `total_used_search_capacity`. Maximum search capacity used for all - /// servers. - `total_avg_used_search_capacity`. Average used search capacity for all servers. **Degraded queries** - /// - /// Check the impact of [degraded queries](https://support.algolia.com/hc/en-us/articles/4406981934481). - - /// `degraded_queries_ssd_used_queries_impacted`. Percentage of degraded queries due to the Algolia search engine - /// having to read from the server's SSD. - `degraded_queries_ssd_used_seconds_impacted`. Percentage of seconds - /// affected by `ssd_used` degraded queries. - `degraded_queries_max_capacity_queries_impacted`. Percentage of - /// degraded queries due to all search threads being used. - `degraded_queries_max_capacity_seconds_impacted`. - /// Percentage of seconds affected by `max_capacity` degraded queries. - /// - parameter indexName: (path) Name of the index on which to perform the operation. - /// - parameter startDate: (query) Start date of the period to analyze, in RFC 3339 format. - /// - parameter endDate: (query) End date of the period to analyze, in RFC 3339 format. - /// - parameter granularity: (query) Granularity of the aggregated metrics. - `hourly`: the maximum time range for - /// hourly metrics is 7 days. - `daily`: the maximum time range for daily metrics is 365 days. (optional) - /// - returns: IndexUsage - @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) - open func getIndexUsage( - statistic: Statistic, - indexName: String, - startDate: String, - endDate: String, - granularity: Granularity? = nil, - requestOptions: RequestOptions? = nil - ) async throws -> IndexUsage { - let response: Response = try await getIndexUsageWithHTTPInfo( - statistic: statistic, - indexName: indexName, - startDate: startDate, - endDate: endDate, - granularity: granularity, - requestOptions: requestOptions - ) - - guard let body = response.body else { - throw AlgoliaError.missingData - } - - return body - } - - // Retrieves the selected usage statistics for one index. - // - // - // - parameter statistic: (path) Usage statistics to retrieve. Use `*` to retrieve all usage metrics, otherwise add - // one or more of the following metrics, separated by a comma. **Search operations** - `search_operations`. All - // search operations. - `total_search_operations`: Sum of all search operations. - `total_search_requests`: Sum of - // all [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - // The number of billed search requests is equal to this value minus `querysuggestions_total_search_requests`. - - // `queries_operations`. Number of [single index search](/specs/search#tag/Search/operation/searchSingleIndex) - // operations. - `multi_queries_operations`. Number of [multi-index - // search](/specs/search#tag/Search/operation/search) operations. **ACL operations** - `acl_operations`. All ACL - // operations. - `total_acl_operations`. Sum of all ACL operations. - `get_api_keys_operations`. Number of [list API - // keys](/specs/search#tag/Api-Keys/operation/listApiKeys) operations. - `get_api_key_operations`. Number of [get - // API - // key permission](/specs/search#tag/Api-Keys/operation/getApiKey) operations. - `add_api_key_operations`. Number of - // [create API key](/specs/search#tag/Api-Keys/operation/addApiKey) operations. - `update_api_key_operations`. - // Number - // of [update API key](/specs/search#tag/Api-Keys/operation/updateApiKey) operations. - `delete_api_key_operations`. - // Number of [delete API key](/specs/search#tag/Api-Keys/operation/deleteApiKey) operations. - - // `list_api_key_operations`. Number of list index API keys operations. **Indexing operations** - - // `indexing_operations`. All indexing operations. - `total_indexing_operations`. Sum of all indexing operations. - - // `browse_operations`. Number of [browse index](/specs/search#tag/Search/operation/browse) operations. - - // `clear_index_operations`. Number of [clear records](/specs/search#tag/Records/operation/clearObjects) operations. - // - `copy_move_operations`. Number of [copy or move index](/specs/search#tag/Indices/operation/operationIndex) - // operations. - `delete_index_operations`. Number of [delete - // index](/specs/search#tag/Indices/operation/deleteIndex) - // operations. - `get_log_operations`. Number of [get logs](/specs/search#tag/Advanced/operation/getLogs) - // operations. - // - `get_settings_operations`. Number of [get settings](/specs/search#operation/getIndexUsage) operations. - - // `set_settings_operations`. Number of [set settings](/specs/search#tag/Indices/operation/setSettings) operations. - // - - // `list_indices_operations`. Number of [list indices](/specs/search#tag/Indices/operation/listIndices) operations. - // - - // `wait_task_operations`. Number of [wait](/specs/search#tag/Indices/operation/getTask) operations. **Record - // operations** - `record_operations`. All record operations. - `total_records_operations`. Sum of all record - // operations. - `add_record_operations`. Number of [add or replace - // record](/specs/search#tag/Records/operation/saveObject) operations. - `batch_operations`. Number of [batch - // indexing](/specs/search#tag/Records/operation/multipleBatch) operations. - `delete_by_query_operations`. Number - // of - // [delete by query](/specs/search#tag/Records/operation/deleteBy) operations. - `delete_record_operations`. Number - // of [delete record](/specs/search#tag/Records/operation/deleteObject) operations. - `get_record_operations`. - // Number - // of [get record](/specs/search#tag/Records/operation/getObject) operations. - `partial_update_record_operations`. - // Number of [partially update records](/specs/search#tag/Records/operation/partialUpdateObject) operations. - - // `update_record_operations`. Number of [add or replace record by - // objectID](/specs/search#tag/Records/operation/addOrUpdateObject) operations. **Synonym operations** - - // `synonym_operations`. All synonym operations. - `total_synonym_operations`. Sum of all synonym operations. - - // `batch_synonym_operations`. Number of [save all synonyms](/specs/search#tag/Synonyms/operation/saveSynonyms) - // operations. - `clear_synonym_operations`. Number of [clear - // synonyms](/specs/search#tag/Synonyms/operation/clearSynonyms) operations. - `delete_synonym_operations`. Number - // of - // [delete synonym](/specs/search#tag/Synonyms/operation/deleteSynonym) operations. - `get_synonym_operations`. - // Number of [get synonym](/specs/search#tag/Synonyms/operation/getSynonym) operations. - - // `query_synonym_operations`. - // Number of [search synonyms](/specs/search#tag/Synonyms/operation/searchSynonyms) operations. - - // `update_synonym_operations`. Number of [save a synonym](/specs/search#tag/Synonyms/operation/saveSynonym) - // operations. **Rule operations** - `rule_operations`. All rule operations. - `total_rules_operations`. Sum of - // all - // rule operations. - `batch_rules_operations`. Number of [batch rules](/specs/search#tag/Rules/operation/saveRules) - // operations. - `clear_rules_operations`. Number of [delete rule](/specs/search#tag/Rules/operation/deleteRule) - // operations. - `delete_rules_operations`. Number of [clear rules](/specs/search#tag/Rules/operation/clearRules) - // operations. - `get_rules_operations`. Number of [get rule](/specs/search#tag/Rules/operation/getRule) operations. - // - `save_rules_operations`. Number of [save rule](/specs/search#operation/getIndexUsage) operations. - - // `search_rules_operations`. Number of [search rules](/specs/search#tag/Rules/operation/searchRules) operations. - // **Total operations** - `total_recommend_requests`. Number of [Recommend - // requests](https://www.algolia.com/doc/guides/algolia-ai/recommend/) - `total_write_operations`. Number of Write - // operations - `total_read_operations`. Number of read operations - `total_operations`. Sum of all operations - // **Total Query Suggestions operations** Query Suggestions operations are a subset of `total_search_operations`. - // - - // `querysuggestions_total_search_operations`. Number of Query Suggestions search operations. - - // `querysuggestions_total_search_requests`. Number of Query Suggestions [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - // - `querysuggestions_total_acl_operations`. Sum of all Query Suggestions [ACL operations](#acl-operations). - - // `querysuggestions_total_indexing_operations`. Number of Query Suggestions [indexing - // operations](#indexing-operations). - `querysuggestions_total_records_operations`. Number of Query Suggestions - // [record operations](#record-operations). - `querysuggestions_total_synonym_operations`. Number of Query - // Suggestions [synonym operations](#synonym-operations). - `querysuggestions_total_rules_operations`. Number of - // Query Suggestions [Rule operations](#rule-operations). - `querysuggestions_total_write_operations`. Number of - // Query Suggestions Write operations. - `querysuggestions_total_read_operations`. Number of Query Suggestions Read - // operations. - `querysuggestions_total_operations`. Sum of all Query Suggestions operations. **Processing time** - // - `avg_processing_time`. Average processing time (in milliseconds). - `90p_processing_time`. 90th percentile of - // processing time (in milliseconds). - `99p_processing_time`. 99th percentile of processing time (in milliseconds). - // - `queries_above_last_ms_processing_time`. Number of queries that take one or more seconds to process. - // **Indices** - `records`. Number of records. - `data_size`. The size of the records (in bytes). - `file_size`. - // The - // size of the records _and_ index metadata (in bytes). **Maximum queries per second** - `max_qps`. [Maximum - // queries per second](https://support.algolia.com/hc/en-us/articles/4406975224721) per server. - `region_max_qps`. - // Maximum queries per second per region. - `total_max_qps`. Maximum queries per second across all servers. **Used - // search capacity** The following capacities are reported in percent: - `used_search_capacity`. Maximum search - // capacity used per server. - `avg_used_search_capacity`. Average search capacity used per server. - - // `region_used_search_capacity`. Maximum search capacity used per region. - `region_avg_used_search_capacity`. - // Average search capacity used per region. - `total_used_search_capacity`. Maximum search capacity used for all - // servers. - `total_avg_used_search_capacity`. Average used search capacity for all servers. **Degraded queries** - // Check the impact of [degraded queries](https://support.algolia.com/hc/en-us/articles/4406981934481). - - // `degraded_queries_ssd_used_queries_impacted`. Percentage of degraded queries due to the Algolia search engine - // having to read from the server's SSD. - `degraded_queries_ssd_used_seconds_impacted`. Percentage of seconds - // affected by `ssd_used` degraded queries. - `degraded_queries_max_capacity_queries_impacted`. Percentage of - // degraded queries due to all search threads being used. - `degraded_queries_max_capacity_seconds_impacted`. - // Percentage of seconds affected by `max_capacity` degraded queries. - // - // - parameter indexName: (path) Name of the index on which to perform the operation. - // - // - parameter startDate: (query) Start date of the period to analyze, in RFC 3339 format. - // - // - parameter endDate: (query) End date of the period to analyze, in RFC 3339 format. - // - // - parameter granularity: (query) Granularity of the aggregated metrics. - `hourly`: the maximum time range for - // hourly metrics is 7 days. - `daily`: the maximum time range for daily metrics is 365 days. (optional) - // - returns: RequestBuilder - - open func getIndexUsageWithHTTPInfo( - statistic: Statistic, - indexName: String, - startDate: String, - endDate: String, - granularity: Granularity? = nil, - requestOptions userRequestOptions: RequestOptions? = nil - ) async throws -> Response { - guard !indexName.isEmpty else { - throw AlgoliaError.invalidArgument("indexName", "getIndexUsage") - } - - guard !startDate.isEmpty else { - throw AlgoliaError.invalidArgument("startDate", "getIndexUsage") - } - - guard !endDate.isEmpty else { - throw AlgoliaError.invalidArgument("endDate", "getIndexUsage") - } - - var resourcePath = "/1/usage/{statistic}/{indexName}" - let statisticPreEscape = "\(APIHelper.mapValueToPathItem(statistic))" - let statisticPostEscape = statisticPreEscape - .addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? "" - resourcePath = resourcePath.replacingOccurrences( - of: "{statistic}", - with: statisticPostEscape, - options: .literal, - range: nil - ) - let indexNamePreEscape = "\(APIHelper.mapValueToPathItem(indexName))" - let indexNamePostEscape = indexNamePreEscape - .addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? "" - resourcePath = resourcePath.replacingOccurrences( - of: "{indexName}", - with: indexNamePostEscape, - options: .literal, - range: nil - ) - let body: AnyCodable? = nil - let queryParameters: [String: Any?] = [ - "startDate": startDate.encodeToJSON(), - "endDate": endDate.encodeToJSON(), - "granularity": granularity?.encodeToJSON(), - ] - - let nillableHeaders: [String: Any?]? = nil - - let headers = APIHelper.rejectNilHeaders(nillableHeaders) - - return try await self.transporter.send( - method: "GET", - path: resourcePath, - data: body, - requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions - ) - } - - /// - parameter statistic: (path) Usage statistics to retrieve. Use `*` to retrieve all usage metrics, otherwise - /// add - /// one or more of the following metrics, separated by a comma. **Search operations** - `search_operations`. All - /// search operations. - `total_search_operations`: Sum of all search operations. - `total_search_requests`: Sum of - /// all [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - /// The number of billed search requests is equal to this value minus `querysuggestions_total_search_requests`. - - /// `queries_operations`. Number of [single index search](/specs/search#tag/Search/operation/searchSingleIndex) - /// operations. - `multi_queries_operations`. Number of [multi-index - /// search](/specs/search#tag/Search/operation/search) operations. **ACL operations** - `acl_operations`. All ACL - /// operations. - `total_acl_operations`. Sum of all ACL operations. - `get_api_keys_operations`. Number of [list - /// API - /// keys](/specs/search#tag/Api-Keys/operation/listApiKeys) operations. - `get_api_key_operations`. Number of [get - /// API - /// key permission](/specs/search#tag/Api-Keys/operation/getApiKey) operations. - `add_api_key_operations`. Number - /// of - /// [create API key](/specs/search#tag/Api-Keys/operation/addApiKey) operations. - `update_api_key_operations`. - /// Number - /// of [update API key](/specs/search#tag/Api-Keys/operation/updateApiKey) operations. - - /// `delete_api_key_operations`. - /// Number of [delete API key](/specs/search#tag/Api-Keys/operation/deleteApiKey) operations. - - /// `list_api_key_operations`. Number of list index API keys operations. **Indexing operations** - - /// `indexing_operations`. All indexing operations. - `total_indexing_operations`. Sum of all indexing operations. - - /// `browse_operations`. Number of [browse index](/specs/search#tag/Search/operation/browse) operations. - - /// `clear_index_operations`. Number of [clear records](/specs/search#tag/Records/operation/clearObjects) - /// operations. - /// - `copy_move_operations`. Number of [copy or move index](/specs/search#tag/Indices/operation/operationIndex) - /// operations. - `delete_index_operations`. Number of [delete - /// index](/specs/search#tag/Indices/operation/deleteIndex) - /// operations. - `get_log_operations`. Number of [get logs](/specs/search#tag/Advanced/operation/getLogs) - /// operations. - /// - `get_settings_operations`. Number of [get settings](/specs/search#operation/getIndexUsage) operations. - - /// `set_settings_operations`. Number of [set settings](/specs/search#tag/Indices/operation/setSettings) operations. - /// - - /// `list_indices_operations`. Number of [list indices](/specs/search#tag/Indices/operation/listIndices) operations. - /// - - /// `wait_task_operations`. Number of [wait](/specs/search#tag/Indices/operation/getTask) operations. **Record - /// operations** - `record_operations`. All record operations. - `total_records_operations`. Sum of all record - /// operations. - `add_record_operations`. Number of [add or replace - /// record](/specs/search#tag/Records/operation/saveObject) operations. - `batch_operations`. Number of [batch - /// indexing](/specs/search#tag/Records/operation/multipleBatch) operations. - `delete_by_query_operations`. Number - /// of - /// [delete by query](/specs/search#tag/Records/operation/deleteBy) operations. - `delete_record_operations`. Number - /// of [delete record](/specs/search#tag/Records/operation/deleteObject) operations. - `get_record_operations`. - /// Number - /// of [get record](/specs/search#tag/Records/operation/getObject) operations. - `partial_update_record_operations`. - /// Number of [partially update records](/specs/search#tag/Records/operation/partialUpdateObject) operations. - - /// `update_record_operations`. Number of [add or replace record by - /// objectID](/specs/search#tag/Records/operation/addOrUpdateObject) operations. **Synonym operations** - - /// `synonym_operations`. All synonym operations. - `total_synonym_operations`. Sum of all synonym operations. - - /// `batch_synonym_operations`. Number of [save all synonyms](/specs/search#tag/Synonyms/operation/saveSynonyms) - /// operations. - `clear_synonym_operations`. Number of [clear - /// synonyms](/specs/search#tag/Synonyms/operation/clearSynonyms) operations. - `delete_synonym_operations`. Number - /// of - /// [delete synonym](/specs/search#tag/Synonyms/operation/deleteSynonym) operations. - `get_synonym_operations`. - /// Number of [get synonym](/specs/search#tag/Synonyms/operation/getSynonym) operations. - - /// `query_synonym_operations`. - /// Number of [search synonyms](/specs/search#tag/Synonyms/operation/searchSynonyms) operations. - - /// `update_synonym_operations`. Number of [save a synonym](/specs/search#tag/Synonyms/operation/saveSynonym) - /// operations. **Rule operations** - `rule_operations`. All rule operations. - `total_rules_operations`. Sum of - /// all - /// rule operations. - `batch_rules_operations`. Number of [batch - /// rules](/specs/search#tag/Rules/operation/saveRules) - /// operations. - `clear_rules_operations`. Number of [delete rule](/specs/search#tag/Rules/operation/deleteRule) - /// operations. - `delete_rules_operations`. Number of [clear rules](/specs/search#tag/Rules/operation/clearRules) - /// operations. - `get_rules_operations`. Number of [get rule](/specs/search#tag/Rules/operation/getRule) - /// operations. - /// - `save_rules_operations`. Number of [save rule](/specs/search#operation/getIndexUsage) operations. - - /// `search_rules_operations`. Number of [search rules](/specs/search#tag/Rules/operation/searchRules) operations. - /// **Total operations** - `total_recommend_requests`. Number of [Recommend - /// requests](https://www.algolia.com/doc/guides/algolia-ai/recommend/) - `total_write_operations`. Number of Write - /// operations - `total_read_operations`. Number of read operations - `total_operations`. Sum of all operations - /// **Total Query Suggestions operations** Query Suggestions operations are a subset of `total_search_operations`. - /// - - /// `querysuggestions_total_search_operations`. Number of Query Suggestions search operations. - - /// `querysuggestions_total_search_requests`. Number of Query Suggestions [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - /// - `querysuggestions_total_acl_operations`. Sum of all Query Suggestions [ACL operations](#acl-operations). - - /// `querysuggestions_total_indexing_operations`. Number of Query Suggestions [indexing - /// operations](#indexing-operations). - `querysuggestions_total_records_operations`. Number of Query Suggestions - /// [record operations](#record-operations). - `querysuggestions_total_synonym_operations`. Number of Query - /// Suggestions [synonym operations](#synonym-operations). - `querysuggestions_total_rules_operations`. Number of - /// Query Suggestions [Rule operations](#rule-operations). - `querysuggestions_total_write_operations`. Number of - /// Query Suggestions Write operations. - `querysuggestions_total_read_operations`. Number of Query Suggestions Read - /// operations. - `querysuggestions_total_operations`. Sum of all Query Suggestions operations. **Processing time** - /// - /// - `avg_processing_time`. Average processing time (in milliseconds). - `90p_processing_time`. 90th percentile of - /// processing time (in milliseconds). - `99p_processing_time`. 99th percentile of processing time (in - /// milliseconds). - /// - `queries_above_last_ms_processing_time`. Number of queries that take one or more seconds to process. - /// **Indices** - `records`. Number of records. - `data_size`. The size of the records (in bytes). - `file_size`. - /// The - /// size of the records _and_ index metadata (in bytes). **Maximum queries per second** - `max_qps`. [Maximum - /// queries per second](https://support.algolia.com/hc/en-us/articles/4406975224721) per server. - `region_max_qps`. - /// Maximum queries per second per region. - `total_max_qps`. Maximum queries per second across all servers. **Used - /// search capacity** The following capacities are reported in percent: - `used_search_capacity`. Maximum search - /// capacity used per server. - `avg_used_search_capacity`. Average search capacity used per server. - - /// `region_used_search_capacity`. Maximum search capacity used per region. - `region_avg_used_search_capacity`. - /// Average search capacity used per region. - `total_used_search_capacity`. Maximum search capacity used for all - /// servers. - `total_avg_used_search_capacity`. Average used search capacity for all servers. **Degraded queries** - /// - /// Check the impact of [degraded queries](https://support.algolia.com/hc/en-us/articles/4406981934481). - - /// `degraded_queries_ssd_used_queries_impacted`. Percentage of degraded queries due to the Algolia search engine - /// having to read from the server's SSD. - `degraded_queries_ssd_used_seconds_impacted`. Percentage of seconds - /// affected by `ssd_used` degraded queries. - `degraded_queries_max_capacity_queries_impacted`. Percentage of - /// degraded queries due to all search threads being used. - `degraded_queries_max_capacity_seconds_impacted`. - /// Percentage of seconds affected by `max_capacity` degraded queries. - /// - parameter startDate: (query) Start date of the period to analyze, in RFC 3339 format. - /// - parameter endDate: (query) End date of the period to analyze, in RFC 3339 format. - /// - parameter granularity: (query) Granularity of the aggregated metrics. - `hourly`: the maximum time range for - /// hourly metrics is 7 days. - `daily`: the maximum time range for daily metrics is 365 days. (optional) - /// - returns: IndexUsage - @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) - open func getUsage( - statistic: Statistic, - startDate: String, - endDate: String, - granularity: Granularity? = nil, - requestOptions: RequestOptions? = nil - ) async throws -> IndexUsage { - let response: Response = try await getUsageWithHTTPInfo( - statistic: statistic, - startDate: startDate, - endDate: endDate, - granularity: granularity, - requestOptions: requestOptions - ) - - guard let body = response.body else { - throw AlgoliaError.missingData - } - - return body - } - - // Retrieves usage statistics evaluated over a specified period. - // - // - // - parameter statistic: (path) Usage statistics to retrieve. Use `*` to retrieve all usage metrics, otherwise add - // one or more of the following metrics, separated by a comma. **Search operations** - `search_operations`. All - // search operations. - `total_search_operations`: Sum of all search operations. - `total_search_requests`: Sum of - // all [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - // The number of billed search requests is equal to this value minus `querysuggestions_total_search_requests`. - - // `queries_operations`. Number of [single index search](/specs/search#tag/Search/operation/searchSingleIndex) - // operations. - `multi_queries_operations`. Number of [multi-index - // search](/specs/search#tag/Search/operation/search) operations. **ACL operations** - `acl_operations`. All ACL - // operations. - `total_acl_operations`. Sum of all ACL operations. - `get_api_keys_operations`. Number of [list API - // keys](/specs/search#tag/Api-Keys/operation/listApiKeys) operations. - `get_api_key_operations`. Number of [get - // API - // key permission](/specs/search#tag/Api-Keys/operation/getApiKey) operations. - `add_api_key_operations`. Number of - // [create API key](/specs/search#tag/Api-Keys/operation/addApiKey) operations. - `update_api_key_operations`. - // Number - // of [update API key](/specs/search#tag/Api-Keys/operation/updateApiKey) operations. - `delete_api_key_operations`. - // Number of [delete API key](/specs/search#tag/Api-Keys/operation/deleteApiKey) operations. - - // `list_api_key_operations`. Number of list index API keys operations. **Indexing operations** - - // `indexing_operations`. All indexing operations. - `total_indexing_operations`. Sum of all indexing operations. - - // `browse_operations`. Number of [browse index](/specs/search#tag/Search/operation/browse) operations. - - // `clear_index_operations`. Number of [clear records](/specs/search#tag/Records/operation/clearObjects) operations. - // - `copy_move_operations`. Number of [copy or move index](/specs/search#tag/Indices/operation/operationIndex) - // operations. - `delete_index_operations`. Number of [delete - // index](/specs/search#tag/Indices/operation/deleteIndex) - // operations. - `get_log_operations`. Number of [get logs](/specs/search#tag/Advanced/operation/getLogs) - // operations. - // - `get_settings_operations`. Number of [get settings](/specs/search#operation/getIndexUsage) operations. - - // `set_settings_operations`. Number of [set settings](/specs/search#tag/Indices/operation/setSettings) operations. - // - - // `list_indices_operations`. Number of [list indices](/specs/search#tag/Indices/operation/listIndices) operations. - // - - // `wait_task_operations`. Number of [wait](/specs/search#tag/Indices/operation/getTask) operations. **Record - // operations** - `record_operations`. All record operations. - `total_records_operations`. Sum of all record - // operations. - `add_record_operations`. Number of [add or replace - // record](/specs/search#tag/Records/operation/saveObject) operations. - `batch_operations`. Number of [batch - // indexing](/specs/search#tag/Records/operation/multipleBatch) operations. - `delete_by_query_operations`. Number - // of - // [delete by query](/specs/search#tag/Records/operation/deleteBy) operations. - `delete_record_operations`. Number - // of [delete record](/specs/search#tag/Records/operation/deleteObject) operations. - `get_record_operations`. - // Number - // of [get record](/specs/search#tag/Records/operation/getObject) operations. - `partial_update_record_operations`. - // Number of [partially update records](/specs/search#tag/Records/operation/partialUpdateObject) operations. - - // `update_record_operations`. Number of [add or replace record by - // objectID](/specs/search#tag/Records/operation/addOrUpdateObject) operations. **Synonym operations** - - // `synonym_operations`. All synonym operations. - `total_synonym_operations`. Sum of all synonym operations. - - // `batch_synonym_operations`. Number of [save all synonyms](/specs/search#tag/Synonyms/operation/saveSynonyms) - // operations. - `clear_synonym_operations`. Number of [clear - // synonyms](/specs/search#tag/Synonyms/operation/clearSynonyms) operations. - `delete_synonym_operations`. Number - // of - // [delete synonym](/specs/search#tag/Synonyms/operation/deleteSynonym) operations. - `get_synonym_operations`. - // Number of [get synonym](/specs/search#tag/Synonyms/operation/getSynonym) operations. - - // `query_synonym_operations`. - // Number of [search synonyms](/specs/search#tag/Synonyms/operation/searchSynonyms) operations. - - // `update_synonym_operations`. Number of [save a synonym](/specs/search#tag/Synonyms/operation/saveSynonym) - // operations. **Rule operations** - `rule_operations`. All rule operations. - `total_rules_operations`. Sum of - // all - // rule operations. - `batch_rules_operations`. Number of [batch rules](/specs/search#tag/Rules/operation/saveRules) - // operations. - `clear_rules_operations`. Number of [delete rule](/specs/search#tag/Rules/operation/deleteRule) - // operations. - `delete_rules_operations`. Number of [clear rules](/specs/search#tag/Rules/operation/clearRules) - // operations. - `get_rules_operations`. Number of [get rule](/specs/search#tag/Rules/operation/getRule) operations. - // - `save_rules_operations`. Number of [save rule](/specs/search#operation/getIndexUsage) operations. - - // `search_rules_operations`. Number of [search rules](/specs/search#tag/Rules/operation/searchRules) operations. - // **Total operations** - `total_recommend_requests`. Number of [Recommend - // requests](https://www.algolia.com/doc/guides/algolia-ai/recommend/) - `total_write_operations`. Number of Write - // operations - `total_read_operations`. Number of read operations - `total_operations`. Sum of all operations - // **Total Query Suggestions operations** Query Suggestions operations are a subset of `total_search_operations`. - // - - // `querysuggestions_total_search_operations`. Number of Query Suggestions search operations. - - // `querysuggestions_total_search_requests`. Number of Query Suggestions [search requests](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-). - // - `querysuggestions_total_acl_operations`. Sum of all Query Suggestions [ACL operations](#acl-operations). - - // `querysuggestions_total_indexing_operations`. Number of Query Suggestions [indexing - // operations](#indexing-operations). - `querysuggestions_total_records_operations`. Number of Query Suggestions - // [record operations](#record-operations). - `querysuggestions_total_synonym_operations`. Number of Query - // Suggestions [synonym operations](#synonym-operations). - `querysuggestions_total_rules_operations`. Number of - // Query Suggestions [Rule operations](#rule-operations). - `querysuggestions_total_write_operations`. Number of - // Query Suggestions Write operations. - `querysuggestions_total_read_operations`. Number of Query Suggestions Read - // operations. - `querysuggestions_total_operations`. Sum of all Query Suggestions operations. **Processing time** - // - `avg_processing_time`. Average processing time (in milliseconds). - `90p_processing_time`. 90th percentile of - // processing time (in milliseconds). - `99p_processing_time`. 99th percentile of processing time (in milliseconds). - // - `queries_above_last_ms_processing_time`. Number of queries that take one or more seconds to process. - // **Indices** - `records`. Number of records. - `data_size`. The size of the records (in bytes). - `file_size`. - // The - // size of the records _and_ index metadata (in bytes). **Maximum queries per second** - `max_qps`. [Maximum - // queries per second](https://support.algolia.com/hc/en-us/articles/4406975224721) per server. - `region_max_qps`. - // Maximum queries per second per region. - `total_max_qps`. Maximum queries per second across all servers. **Used - // search capacity** The following capacities are reported in percent: - `used_search_capacity`. Maximum search - // capacity used per server. - `avg_used_search_capacity`. Average search capacity used per server. - - // `region_used_search_capacity`. Maximum search capacity used per region. - `region_avg_used_search_capacity`. - // Average search capacity used per region. - `total_used_search_capacity`. Maximum search capacity used for all - // servers. - `total_avg_used_search_capacity`. Average used search capacity for all servers. **Degraded queries** - // Check the impact of [degraded queries](https://support.algolia.com/hc/en-us/articles/4406981934481). - - // `degraded_queries_ssd_used_queries_impacted`. Percentage of degraded queries due to the Algolia search engine - // having to read from the server's SSD. - `degraded_queries_ssd_used_seconds_impacted`. Percentage of seconds - // affected by `ssd_used` degraded queries. - `degraded_queries_max_capacity_queries_impacted`. Percentage of - // degraded queries due to all search threads being used. - `degraded_queries_max_capacity_seconds_impacted`. - // Percentage of seconds affected by `max_capacity` degraded queries. - // - // - parameter startDate: (query) Start date of the period to analyze, in RFC 3339 format. - // - // - parameter endDate: (query) End date of the period to analyze, in RFC 3339 format. - // - // - parameter granularity: (query) Granularity of the aggregated metrics. - `hourly`: the maximum time range for - // hourly metrics is 7 days. - `daily`: the maximum time range for daily metrics is 365 days. (optional) - // - returns: RequestBuilder - - open func getUsageWithHTTPInfo( - statistic: Statistic, - startDate: String, - endDate: String, - granularity: Granularity? = nil, - requestOptions userRequestOptions: RequestOptions? = nil - ) async throws -> Response { - guard !startDate.isEmpty else { - throw AlgoliaError.invalidArgument("startDate", "getUsage") - } - - guard !endDate.isEmpty else { - throw AlgoliaError.invalidArgument("endDate", "getUsage") - } - - var resourcePath = "/1/usage/{statistic}" - let statisticPreEscape = "\(APIHelper.mapValueToPathItem(statistic))" - let statisticPostEscape = statisticPreEscape - .addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? "" - resourcePath = resourcePath.replacingOccurrences( - of: "{statistic}", - with: statisticPostEscape, - options: .literal, - range: nil - ) - let body: AnyCodable? = nil - let queryParameters: [String: Any?] = [ - "startDate": startDate.encodeToJSON(), - "endDate": endDate.encodeToJSON(), - "granularity": granularity?.encodeToJSON(), - ] - - let nillableHeaders: [String: Any?]? = nil - - let headers = APIHelper.rejectNilHeaders(nillableHeaders) - - return try await self.transporter.send( - method: "GET", - path: resourcePath, - data: body, - requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions - ) - } -} diff --git a/Sources/Usage/UsageClientConfiguration.swift b/Sources/Usage/UsageClientConfiguration.swift deleted file mode 100644 index 3d6aa6876..000000000 --- a/Sources/Usage/UsageClientConfiguration.swift +++ /dev/null @@ -1,59 +0,0 @@ -// 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. - -import Foundation -#if canImport(Core) - import Core -#endif - -public struct UsageClientConfiguration: BaseConfiguration, Credentials { - public let appID: String - public var apiKey: String - public var writeTimeout: TimeInterval - public var readTimeout: TimeInterval - public var logLevel: LogLevel - public var defaultHeaders: [String: String]? - public var hosts: [RetryableHost] - public let compression: CompressionAlgorithm - - init( - appID: String, - apiKey: String, - writeTimeout: TimeInterval = DefaultConfiguration.default.writeTimeout, - readTimeout: TimeInterval = DefaultConfiguration.default.readTimeout, - logLevel: LogLevel = DefaultConfiguration.default.logLevel, - defaultHeaders: [String: String]? = DefaultConfiguration.default.defaultHeaders, - hosts: [RetryableHost]? = nil - ) throws { - guard !appID.isEmpty else { - throw AlgoliaError.invalidCredentials("appId") - } - - guard !apiKey.isEmpty else { - throw AlgoliaError.invalidCredentials("apiKey") - } - - self.appID = appID - self.apiKey = apiKey - self.writeTimeout = writeTimeout - self.readTimeout = readTimeout - self.logLevel = logLevel - self.defaultHeaders = [ - "X-Algolia-Application-Id": appID, - "X-Algolia-API-Key": apiKey, - "Content-Type": "application/json", - ].merging(defaultHeaders ?? [:]) { _, new in new } - self.compression = .none - - UserAgentController.append(UserAgent(title: "Usage", version: Version.current.description)) - - guard let hosts else { - self.hosts = [ - .init(url: URL(string: "https://usage.algolia.com")!), - ] - return - } - - self.hosts = hosts - } -}