diff --git a/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/Nimbus.kt b/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/Nimbus.kt index 423a2079a9e..51773e6bc97 100644 --- a/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/Nimbus.kt +++ b/components/service/nimbus/src/main/java/mozilla/components/service/nimbus/Nimbus.kt @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +@file:Suppress("TooManyFunctions") + package mozilla.components.service.nimbus import android.content.Context @@ -26,6 +28,7 @@ import mozilla.components.support.base.utils.NamedThreadFactory import mozilla.components.support.locale.getLocaleTag import org.mozilla.experiments.nimbus.AppContext import org.mozilla.experiments.nimbus.AvailableRandomizationUnits +import org.mozilla.experiments.nimbus.Branch import org.mozilla.experiments.nimbus.EnrolledExperiment import org.mozilla.experiments.nimbus.EnrollmentChangeEvent import org.mozilla.experiments.nimbus.EnrollmentChangeEventType @@ -63,6 +66,15 @@ interface NimbusApi : Observable { @AnyThread fun getExperimentBranch(experimentId: String): String? = null + /** + * Get the list of experiment branches for the given experiment + * + * @param experimentId The string experiment-id or "slug" for which to retrieve the branch + * + * @return A list of [Branch]s + */ + fun getExperimentBranches(experimentId: String): List? = listOf() + /** * Refreshes the experiments from the endpoint. Should be called at least once after * initialization @@ -279,6 +291,11 @@ class Nimbus( return nimbus.getExperimentBranch(experimentId) } + @WorkerThread + override fun getExperimentBranches(experimentId: String): List? = withCatchAll { + nimbus.getExperimentBranches(experimentId) + } + override fun updateExperiments() { fetchScope.launch { fetchExperimentsOnThisThread() diff --git a/docs/changelog.md b/docs/changelog.md index a7c53c4d2c5..4834e4b26b7 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -15,6 +15,9 @@ permalink: /changelog/ * **feature-downloads**: * 🚒 Bug fixed [issue #9964](https://github.com/mozilla-mobile/android-components/issues/9964) - Downloads notification strings are not localized. +* **service-nimbus** + * Added `getExperimentBranches` method to `Nimbus` for retrieving a list of experiment branches for a given experiment. [issue #9895](https://github.com/mozilla-mobile/android-components/issues/9895) + # 74.0.0 * [Commits](https://github.com/mozilla-mobile/android-components/compare/v73.0.0...v74.0.0)