|
| 1 | +/** 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. */ |
| 2 | +package com.algolia.client.api |
| 3 | + |
| 4 | +import com.algolia.client.configuration.* |
| 5 | +import com.algolia.client.exception.* |
| 6 | +import com.algolia.client.extensions.internal.* |
| 7 | +import com.algolia.client.model.abtestingv3.* |
| 8 | +import com.algolia.client.transport.* |
| 9 | +import com.algolia.client.transport.internal.* |
| 10 | +import kotlinx.serialization.json.* |
| 11 | +import kotlin.time.Duration.Companion.milliseconds |
| 12 | + |
| 13 | +public class AbtestingV3Client( |
| 14 | + override val appId: String, |
| 15 | + override var apiKey: String, |
| 16 | + public val region: String? = null, |
| 17 | + override val options: ClientOptions = ClientOptions(), |
| 18 | +) : ApiClient { |
| 19 | + |
| 20 | + init { |
| 21 | + require(appId.isNotBlank()) { "`appId` is missing." } |
| 22 | + require(apiKey.isNotBlank()) { "`apiKey` is missing." } |
| 23 | + } |
| 24 | + |
| 25 | + override val requester: Requester = requesterOf(clientName = "AbtestingV3", appId = appId, apiKey = apiKey, connectTimeout = 2000.milliseconds, readTimeout = 5000.milliseconds, writeTimeout = 30000.milliseconds, options = options) { |
| 26 | + val allowedRegions = listOf("de", "us") |
| 27 | + require(region == null || region in allowedRegions) { "`region` must be one of the following: ${allowedRegions.joinToString()}" } |
| 28 | + val url = if (region == null) "analytics.algolia.com" else "analytics.$region.algolia.com" |
| 29 | + listOf(Host(url)) |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * Creates a new A/B test. |
| 34 | + * |
| 35 | + * Required API Key ACLs: |
| 36 | + * - editSettings |
| 37 | + * @param addABTestsRequest |
| 38 | + * @param requestOptions additional request configuration. |
| 39 | + */ |
| 40 | + public suspend fun addABTests(addABTestsRequest: AddABTestsRequest, requestOptions: RequestOptions? = null): ABTestResponse { |
| 41 | + val requestConfig = RequestConfig( |
| 42 | + method = RequestMethod.POST, |
| 43 | + path = listOf("3", "abtests"), |
| 44 | + body = addABTestsRequest, |
| 45 | + ) |
| 46 | + return requester.execute( |
| 47 | + requestConfig = requestConfig, |
| 48 | + requestOptions = requestOptions, |
| 49 | + ) |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * This method lets you send requests to the Algolia REST API. |
| 54 | + * @param path Path of the endpoint, for example `1/newFeature`. |
| 55 | + * @param parameters Query parameters to apply to the current query. |
| 56 | + * @param requestOptions additional request configuration. |
| 57 | + */ |
| 58 | + public suspend fun customDelete(path: String, parameters: Map<kotlin.String, Any>? = null, requestOptions: RequestOptions? = null): JsonObject { |
| 59 | + require(path.isNotBlank()) { "Parameter `path` is required when calling `customDelete`." } |
| 60 | + val requestConfig = RequestConfig( |
| 61 | + method = RequestMethod.DELETE, |
| 62 | + path = "/{path}".replace("{path}", path), |
| 63 | + query = buildMap { |
| 64 | + parameters?.let { putAll(it) } |
| 65 | + }, |
| 66 | + ) |
| 67 | + return requester.execute( |
| 68 | + requestConfig = requestConfig, |
| 69 | + requestOptions = requestOptions, |
| 70 | + ) |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * This method lets you send requests to the Algolia REST API. |
| 75 | + * @param path Path of the endpoint, for example `1/newFeature`. |
| 76 | + * @param parameters Query parameters to apply to the current query. |
| 77 | + * @param requestOptions additional request configuration. |
| 78 | + */ |
| 79 | + public suspend fun customGet(path: String, parameters: Map<kotlin.String, Any>? = null, requestOptions: RequestOptions? = null): JsonObject { |
| 80 | + require(path.isNotBlank()) { "Parameter `path` is required when calling `customGet`." } |
| 81 | + val requestConfig = RequestConfig( |
| 82 | + method = RequestMethod.GET, |
| 83 | + path = "/{path}".replace("{path}", path), |
| 84 | + query = buildMap { |
| 85 | + parameters?.let { putAll(it) } |
| 86 | + }, |
| 87 | + ) |
| 88 | + return requester.execute( |
| 89 | + requestConfig = requestConfig, |
| 90 | + requestOptions = requestOptions, |
| 91 | + ) |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * This method lets you send requests to the Algolia REST API. |
| 96 | + * @param path Path of the endpoint, for example `1/newFeature`. |
| 97 | + * @param parameters Query parameters to apply to the current query. |
| 98 | + * @param body Parameters to send with the custom request. |
| 99 | + * @param requestOptions additional request configuration. |
| 100 | + */ |
| 101 | + public suspend fun customPost(path: String, parameters: Map<kotlin.String, Any>? = null, body: JsonObject? = null, requestOptions: RequestOptions? = null): JsonObject { |
| 102 | + require(path.isNotBlank()) { "Parameter `path` is required when calling `customPost`." } |
| 103 | + val requestConfig = RequestConfig( |
| 104 | + method = RequestMethod.POST, |
| 105 | + path = "/{path}".replace("{path}", path), |
| 106 | + query = buildMap { |
| 107 | + parameters?.let { putAll(it) } |
| 108 | + }, |
| 109 | + body = body, |
| 110 | + ) |
| 111 | + return requester.execute( |
| 112 | + requestConfig = requestConfig, |
| 113 | + requestOptions = requestOptions, |
| 114 | + ) |
| 115 | + } |
| 116 | + |
| 117 | + /** |
| 118 | + * This method lets you send requests to the Algolia REST API. |
| 119 | + * @param path Path of the endpoint, for example `1/newFeature`. |
| 120 | + * @param parameters Query parameters to apply to the current query. |
| 121 | + * @param body Parameters to send with the custom request. |
| 122 | + * @param requestOptions additional request configuration. |
| 123 | + */ |
| 124 | + public suspend fun customPut(path: String, parameters: Map<kotlin.String, Any>? = null, body: JsonObject? = null, requestOptions: RequestOptions? = null): JsonObject { |
| 125 | + require(path.isNotBlank()) { "Parameter `path` is required when calling `customPut`." } |
| 126 | + val requestConfig = RequestConfig( |
| 127 | + method = RequestMethod.PUT, |
| 128 | + path = "/{path}".replace("{path}", path), |
| 129 | + query = buildMap { |
| 130 | + parameters?.let { putAll(it) } |
| 131 | + }, |
| 132 | + body = body, |
| 133 | + ) |
| 134 | + return requester.execute( |
| 135 | + requestConfig = requestConfig, |
| 136 | + requestOptions = requestOptions, |
| 137 | + ) |
| 138 | + } |
| 139 | + |
| 140 | + /** |
| 141 | + * Deletes an A/B test by its ID. |
| 142 | + * |
| 143 | + * Required API Key ACLs: |
| 144 | + * - editSettings |
| 145 | + * @param id Unique A/B test identifier. |
| 146 | + * @param requestOptions additional request configuration. |
| 147 | + */ |
| 148 | + public suspend fun deleteABTest(id: Int, requestOptions: RequestOptions? = null): ABTestResponse { |
| 149 | + val requestConfig = RequestConfig( |
| 150 | + method = RequestMethod.DELETE, |
| 151 | + path = listOf("3", "abtests", "$id"), |
| 152 | + ) |
| 153 | + return requester.execute( |
| 154 | + requestConfig = requestConfig, |
| 155 | + requestOptions = requestOptions, |
| 156 | + ) |
| 157 | + } |
| 158 | + |
| 159 | + /** |
| 160 | + * Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of an A/B test based on historical traffic. |
| 161 | + * |
| 162 | + * Required API Key ACLs: |
| 163 | + * - analytics |
| 164 | + * @param estimateABTestRequest |
| 165 | + * @param requestOptions additional request configuration. |
| 166 | + */ |
| 167 | + public suspend fun estimateABTest(estimateABTestRequest: EstimateABTestRequest, requestOptions: RequestOptions? = null): EstimateABTestResponse { |
| 168 | + val requestConfig = RequestConfig( |
| 169 | + method = RequestMethod.POST, |
| 170 | + path = listOf("3", "abtests", "estimate"), |
| 171 | + body = estimateABTestRequest, |
| 172 | + ) |
| 173 | + return requester.execute( |
| 174 | + requestConfig = requestConfig, |
| 175 | + requestOptions = requestOptions, |
| 176 | + ) |
| 177 | + } |
| 178 | + |
| 179 | + /** |
| 180 | + * Retrieves the details for an A/B test by its ID. |
| 181 | + * |
| 182 | + * Required API Key ACLs: |
| 183 | + * - analytics |
| 184 | + * @param id Unique A/B test identifier. |
| 185 | + * @param requestOptions additional request configuration. |
| 186 | + */ |
| 187 | + public suspend fun getABTest(id: Int, requestOptions: RequestOptions? = null): ABTest { |
| 188 | + val requestConfig = RequestConfig( |
| 189 | + method = RequestMethod.GET, |
| 190 | + path = listOf("3", "abtests", "$id"), |
| 191 | + ) |
| 192 | + return requester.execute( |
| 193 | + requestConfig = requestConfig, |
| 194 | + requestOptions = requestOptions, |
| 195 | + ) |
| 196 | + } |
| 197 | + |
| 198 | + /** |
| 199 | + * Retrieves timeseries for an A/B test by its ID. |
| 200 | + * |
| 201 | + * Required API Key ACLs: |
| 202 | + * - analytics |
| 203 | + * @param id Unique A/B test identifier. |
| 204 | + * @param startDate Start date of the period to analyze, in `YYYY-MM-DD` format. |
| 205 | + * @param endDate End date of the period to analyze, in `YYYY-MM-DD` format. |
| 206 | + * @param metric List of metrics to retrieve. If not specified, all metrics are returned. |
| 207 | + * @param requestOptions additional request configuration. |
| 208 | + */ |
| 209 | + public suspend fun getTimeseries(id: Int, startDate: String? = null, endDate: String? = null, metric: List<MetricName>? = null, requestOptions: RequestOptions? = null): Timeseries { |
| 210 | + val requestConfig = RequestConfig( |
| 211 | + method = RequestMethod.GET, |
| 212 | + path = listOf("3", "abtests", "$id", "timeseries"), |
| 213 | + query = buildMap { |
| 214 | + startDate?.let { put("startDate", it) } |
| 215 | + endDate?.let { put("endDate", it) } |
| 216 | + metric?.let { put("metric", it.joinToString(",")) } |
| 217 | + }, |
| 218 | + ) |
| 219 | + return requester.execute( |
| 220 | + requestConfig = requestConfig, |
| 221 | + requestOptions = requestOptions, |
| 222 | + ) |
| 223 | + } |
| 224 | + |
| 225 | + /** |
| 226 | + * Lists all A/B tests you configured for this application. |
| 227 | + * |
| 228 | + * Required API Key ACLs: |
| 229 | + * - analytics |
| 230 | + * @param offset Position of the first item to return. (default to 0) |
| 231 | + * @param limit Number of items to return. (default to 10) |
| 232 | + * @param indexPrefix Index name prefix. Only A/B tests for indices starting with this string are included in the response. |
| 233 | + * @param indexSuffix Index name suffix. Only A/B tests for indices ending with this string are included in the response. |
| 234 | + * @param direction Sort order for A/B tests by start date. Use 'asc' for ascending or 'desc' for descending. Active A/B tests are always listed first. |
| 235 | + * @param requestOptions additional request configuration. |
| 236 | + */ |
| 237 | + public suspend fun listABTests(offset: Int? = null, limit: Int? = null, indexPrefix: String? = null, indexSuffix: String? = null, direction: Direction? = null, requestOptions: RequestOptions? = null): ListABTestsResponse { |
| 238 | + val requestConfig = RequestConfig( |
| 239 | + method = RequestMethod.GET, |
| 240 | + path = listOf("3", "abtests"), |
| 241 | + query = buildMap { |
| 242 | + offset?.let { put("offset", it) } |
| 243 | + limit?.let { put("limit", it) } |
| 244 | + indexPrefix?.let { put("indexPrefix", it) } |
| 245 | + indexSuffix?.let { put("indexSuffix", it) } |
| 246 | + direction?.let { put("direction", it) } |
| 247 | + }, |
| 248 | + ) |
| 249 | + return requester.execute( |
| 250 | + requestConfig = requestConfig, |
| 251 | + requestOptions = requestOptions, |
| 252 | + ) |
| 253 | + } |
| 254 | + |
| 255 | + /** |
| 256 | + * Schedule an A/B test to be started at a later time. |
| 257 | + * |
| 258 | + * Required API Key ACLs: |
| 259 | + * - editSettings |
| 260 | + * @param scheduleABTestsRequest |
| 261 | + * @param requestOptions additional request configuration. |
| 262 | + */ |
| 263 | + public suspend fun scheduleABTest(scheduleABTestsRequest: ScheduleABTestsRequest, requestOptions: RequestOptions? = null): ScheduleABTestResponse { |
| 264 | + val requestConfig = RequestConfig( |
| 265 | + method = RequestMethod.POST, |
| 266 | + path = listOf("3", "abtests", "schedule"), |
| 267 | + body = scheduleABTestsRequest, |
| 268 | + ) |
| 269 | + return requester.execute( |
| 270 | + requestConfig = requestConfig, |
| 271 | + requestOptions = requestOptions, |
| 272 | + ) |
| 273 | + } |
| 274 | + |
| 275 | + /** |
| 276 | + * Stops an A/B test by its ID. You can't restart stopped A/B tests. |
| 277 | + * |
| 278 | + * Required API Key ACLs: |
| 279 | + * - editSettings |
| 280 | + * @param id Unique A/B test identifier. |
| 281 | + * @param requestOptions additional request configuration. |
| 282 | + */ |
| 283 | + public suspend fun stopABTest(id: Int, requestOptions: RequestOptions? = null): ABTestResponse { |
| 284 | + val requestConfig = RequestConfig( |
| 285 | + method = RequestMethod.POST, |
| 286 | + path = listOf("3", "abtests", "$id", "stop"), |
| 287 | + ) |
| 288 | + return requester.execute( |
| 289 | + requestConfig = requestConfig, |
| 290 | + requestOptions = requestOptions, |
| 291 | + ) |
| 292 | + } |
| 293 | +} |
0 commit comments