/// <summary>
        /// Starts an existing experiment for a title.
        /// </summary>
        public async Task <PlayFabResult <EmptyResponse> > StartExperimentAsync(StartExperimentRequest request, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            await new PlayFabUtil.SynchronizationContextRemover();

            var requestContext  = request?.AuthenticationContext ?? authenticationContext;
            var requestSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if (requestContext.EntityToken == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method");
            }

            var httpResult = await PlayFabHttp.DoPost("/Experimentation/StartExperiment", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                PlayFabSettings.GlobalErrorHandler?.Invoke(error);
                return(new PlayFabResult <EmptyResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <EmptyResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <EmptyResponse> {
                Result = result, CustomData = customData
            });
        }
        public override Task <StartExperimentReply> StartExperiment(StartExperimentRequest request, ServerCallContext context)
        {
            bool success = ExperimentSessionManager.StartExperiment(request.NumRandomIterations, request.NumGuidedIterations);
            StartExperimentReply reply = new StartExperimentReply();

            reply.Success = success;
            return(Task.FromResult(reply));
        }
Example #3
0
        /// <summary>
        /// Starts running an experiment from the specified experiment template.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the StartExperiment service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the StartExperiment service method, as returned by FIS.</returns>
        /// <exception cref="Amazon.FIS.Model.ConflictException">
        /// The request could not be processed because of a conflict.
        /// </exception>
        /// <exception cref="Amazon.FIS.Model.ResourceNotFoundException">
        /// The specified resource cannot be found.
        /// </exception>
        /// <exception cref="Amazon.FIS.Model.ServiceQuotaExceededException">
        /// You have exceeded your service quota.
        /// </exception>
        /// <exception cref="Amazon.FIS.Model.ValidationException">
        /// The specified input is not valid, or fails to satisfy the constraints for the request.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/fis-2020-12-01/StartExperiment">REST API Reference for StartExperiment Operation</seealso>
        public virtual Task <StartExperimentResponse> StartExperimentAsync(StartExperimentRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = StartExperimentRequestMarshaller.Instance;
            options.ResponseUnmarshaller = StartExperimentResponseUnmarshaller.Instance;

            return(InvokeAsync <StartExperimentResponse>(request, options, cancellationToken));
        }
Example #4
0
        internal virtual StartExperimentResponse StartExperiment(StartExperimentRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = StartExperimentRequestMarshaller.Instance;
            options.ResponseUnmarshaller = StartExperimentResponseUnmarshaller.Instance;

            return(Invoke <StartExperimentResponse>(request, options));
        }
Example #5
0
        /// <summary>
        /// Starts an existing experiment for a title.
        /// </summary>
        public void StartExperiment(StartExperimentRequest request, Action <EmptyResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null)
        {
            var context      = (request == null ? null : request.AuthenticationContext) ?? authenticationContext;
            var callSettings = apiSettings ?? PlayFabSettings.staticSettings;

            if (!context.IsEntityLoggedIn())
            {
                throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn, "Must be logged in to call this method");
            }
            PlayFabHttp.MakeApiCall("/Experimentation/StartExperiment", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this);
        }
Example #6
0
 /// <summary>Snippet for StartExperiment</summary>
 public void StartExperimentRequestObject()
 {
     // Snippet: StartExperiment(StartExperimentRequest, CallSettings)
     // Create client
     ExperimentsClient experimentsClient = ExperimentsClient.Create();
     // Initialize request argument(s)
     StartExperimentRequest request = new StartExperimentRequest
     {
         ExperimentName = ExperimentName.FromProjectLocationAgentEnvironmentExperiment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[EXPERIMENT]"),
     };
     // Make the request
     Experiment response = experimentsClient.StartExperiment(request);
     // End snippet
 }
Example #7
0
        /// <summary>Snippet for StartExperimentAsync</summary>
        public async Task StartExperimentRequestObjectAsync()
        {
            // Snippet: StartExperimentAsync(StartExperimentRequest, CallSettings)
            // Additional: StartExperimentAsync(StartExperimentRequest, CancellationToken)
            // Create client
            ExperimentsClient experimentsClient = await ExperimentsClient.CreateAsync();

            // Initialize request argument(s)
            StartExperimentRequest request = new StartExperimentRequest
            {
                ExperimentName = ExperimentName.FromProjectLocationAgentEnvironmentExperiment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[EXPERIMENT]"),
            };
            // Make the request
            Experiment response = await experimentsClient.StartExperimentAsync(request);

            // End snippet
        }