syntax = "proto3";

package wix.abtest.v2;
option java_package = "com.wixpress.abtest.v2";

import "google/api/annotations.proto";
import "google/protobuf/field_mask.proto";
import "wix/api/annotations.proto";
import "wix/api/callback.proto";
import "wix/api/entity.proto";
import "wix/api/permissions.proto";
import "wix/api/validations.proto";
import "wix/common/query.proto";
import "wix/http/field_mask.proto";
import "wix/abtest/v2/experiment_results.proto";
import "wix/abtest/v2/experiments_properties_thin.proto";
import "wix/abtest/v2/experiment_properties.proto";
import "wix/abtest/v2/experiment_support_kpis.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";

/**
  Manages Experiments
 */
service WixABService {
    option (.wix.api.service_maturity) = ALPHA;
    option (.wix.api.service_exposure) = PRIVATE;
    option (.wix.api.service_entity).message = "wix.abtest.v2.ExperimentProperties";

    /**
      Get an Experiment by id
     */
    rpc GetExperimentProperties (GetExperimentRequest) returns (GetExperimentPropertiesResponse) {
        option (google.api.http).get = "/v2/per_experiment/properties/{experiment_id}";
        option (.wix.api.permission).name = "WIXER.EXPERIMENT_READ";
        option (.wix.api.required) = "GetExperimentRequest.experiment_id";
    }

    rpc GetExperimentResults (GetExperimentRequest) returns (GetExperimentResultsResponse) {
        option (google.api.http).get = "/v2/per_experiment/results/{experiment_id}";
        option (.wix.api.permission).name = "WIXER.EXPERIMENT_READ";
        option (.wix.api.required) = "GetExperimentRequest.experiment_id";
    }

    rpc GetAllExperiments (GetAllExperimentsRequest) returns (GetAllExperimentsResponse) {
        option (google.api.http).get = "/v2/all_experiments/{get_only_terminated}";
        option (.wix.api.permission).name = "WIXER.EXPERIMENT_READ";
    }

    rpc GetSupportKPIs (GetExperimentRequest) returns (GetSupportKPIsResponse) {
        option (google.api.http).get = "/v2/per_experiment/support_kpis/{experiment_id}";
        option (.wix.api.permission).name = "WIXER.EXPERIMENT_READ";
        option (.wix.api.required) = "GetExperimentRequest.experiment_id";
    }
}

message GetExperimentRequest {
    string experiment_id = 1; // Id of the Experiment to retrieve
}

message GetAllExperimentsRequest {
    google.protobuf.BoolValue get_only_terminated = 1; // getting only terminated experiments
}


message GetExperimentPropertiesResponse {
    ExperimentProperties experiment_properties = 1; // The retrieved Experiment data
}

message GetExperimentResultsResponse {
    repeated ExperimentResults experiment_results = 1; // The retrieved Experiment data

}

message GetAllExperimentsResponse {
    repeated ExperimentResultsThin all_experiment = 1; // The retrieved Experiment
}

message GetSupportKPIsResponse {
    repeated ExperimentSupportKPIs experiment_support_kpis = 1; // The retrieved Experiment
}