Skip to content

Commit

Permalink
feat(specs): add /schedule endpoint (#3350)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
  • Loading branch information
febeck and millotp authored Aug 20, 2024
1 parent 9d62976 commit d53060d
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 0 deletions.
10 changes: 10 additions & 0 deletions specs/abtesting/common/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ abTestID:
description: Unique A/B test identifier.
example: 224

abTestScheduleID:
type: integer
description: Unique scheduled A/B test identifier.
example: 224

endAt:
type: string
description: End date and time of the A/B test, in RFC 3339 format.
Expand All @@ -33,6 +38,11 @@ updatedAt:
description: Date and time when the A/B test was last updated, in RFC 3339 format.
example: 2023-06-15T15:06:44.400601Z

scheduledAt:
type: string
description: Date and time when the A/B test is scheduled to start, in RFC 3339 format.
example: 2023-06-15T15:06:44.400601Z

name:
type: string
description: A/B test name.
Expand Down
8 changes: 8 additions & 0 deletions specs/abtesting/common/schemas/ScheduleABTestResponse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ScheduleABTestResponse:
type: object
additionalProperties: false
properties:
abTestScheduleID:
$ref: '../parameters.yml#/abTestScheduleID'
required:
- abTestScheduleID
58 changes: 58 additions & 0 deletions specs/abtesting/paths/scheduleABTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
post:
tags:
- abtest
operationId: scheduleABTest
x-acl:
- editSettings
summary: Schedule an A/B test
description: |
Schedule an A/B test to be started at a later time.
requestBody:
required: true
content:
application/json:
schema:
title: scheduleABTestsRequest
type: object
additionalProperties: false
properties:
name:
$ref: '../common/parameters.yml#/name'
variants:
type: array
description: A/B test variants.
minItems: 2
maxItems: 2
items:
$ref: '../common/schemas/AddABTestsVariant.yml#/AddABTestsVariant'
scheduledAt:
$ref: '../common/parameters.yml#/scheduledAt'
endAt:
$ref: '../common/parameters.yml#/endAt'
required:
- name
- variants
- scheduledAt
- endAt
responses:
'200':
description: OK
headers:
x-ratelimit-limit:
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-limit'
x-ratelimit-remaining:
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-remaining'
x-ratelimit-reset:
$ref: '../../common/responses/rateLimit.yml#/x-ratelimit-reset'
content:
application/json:
schema:
$ref: '../common/schemas/ScheduleABTestResponse.yml#/ScheduleABTestResponse'
'400':
$ref: '../../common/responses/BadRequest.yml'
'402':
$ref: '../../common/responses/FeatureNotEnabled.yml'
'403':
$ref: '../../common/responses/MethodNotAllowed.yml'
'404':
$ref: '../../common/responses/IndexNotFound.yml'
2 changes: 2 additions & 0 deletions specs/abtesting/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ paths:
$ref: 'paths/abtest.yml'
/2/abtests/{id}/stop:
$ref: 'paths/stopABTest.yml'
/2/abtests/schedule:
$ref: 'paths/scheduleABTest.yml'
39 changes: 39 additions & 0 deletions tests/CTS/requests/abtesting/scheduleABTest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[
{
"testName": "scheduleABTest with minimal parameters",
"parameters": {
"endAt": "2022-12-31T00:00:00.000Z",
"scheduledAt": "2022-11-31T00:00:00.000Z",
"name": "myABTest",
"variants": [
{
"index": "AB_TEST_1",
"trafficPercentage": 30
},
{
"index": "AB_TEST_2",
"trafficPercentage": 50
}
]
},
"request": {
"path": "/2/abtests/schedule",
"method": "POST",
"body": {
"endAt": "2022-12-31T00:00:00.000Z",
"scheduledAt": "2022-11-31T00:00:00.000Z",
"name": "myABTest",
"variants": [
{
"index": "AB_TEST_1",
"trafficPercentage": 30
},
{
"index": "AB_TEST_2",
"trafficPercentage": 50
}
]
}
}
}
]

0 comments on commit d53060d

Please sign in to comment.