/// <summary> /// Updates the feature state if allowed. /// </summary> /// <exception cref="IO.FeatureHub.SSE.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="sdkUrl">The SDK key for the environment and service account</param> /// <param name="featureKey">The key you wish to update/action</param> /// <param name="featureStateUpdate"> (optional)</param> /// <returns>ApiResponse of object</returns> public IO.FeatureHub.SSE.Client.ApiResponse <object> SetFeatureStateWithHttpInfo(string sdkUrl, string featureKey, FeatureStateUpdate featureStateUpdate = default(FeatureStateUpdate)) { // verify the required parameter 'sdkUrl' is set if (sdkUrl == null) { throw new IO.FeatureHub.SSE.Client.ApiException(400, "Missing required parameter 'sdkUrl' when calling FeatureServiceApi->SetFeatureState"); } // verify the required parameter 'featureKey' is set if (featureKey == null) { throw new IO.FeatureHub.SSE.Client.ApiException(400, "Missing required parameter 'featureKey' when calling FeatureServiceApi->SetFeatureState"); } IO.FeatureHub.SSE.Client.RequestOptions localVarRequestOptions = new IO.FeatureHub.SSE.Client.RequestOptions(); String[] _contentTypes = new String[] { "application/json" }; // to determine the Accept header String[] _accepts = new String[] { "application/json" }; var localVarContentType = IO.FeatureHub.SSE.Client.ClientUtils.SelectHeaderContentType(_contentTypes); if (localVarContentType != null) { localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); } var localVarAccept = IO.FeatureHub.SSE.Client.ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } localVarRequestOptions.PathParameters.Add("sdkUrl", IO.FeatureHub.SSE.Client.ClientUtils.ParameterToString(sdkUrl)); // path parameter localVarRequestOptions.PathParameters.Add("featureKey", IO.FeatureHub.SSE.Client.ClientUtils.ParameterToString(featureKey)); // path parameter localVarRequestOptions.Data = featureStateUpdate; // make the HTTP request var localVarResponse = this.Client.Put <object>("/features/{sdkUrl}/{featureKey}", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("SetFeatureState", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
/// <summary> /// Requests all features for this sdkurl and disconnects /// </summary> /// <exception cref="IO.FeatureHub.SSE.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="sdkUrl">The SDK urls</param> /// <returns>ApiResponse of List<Model.Environment></returns> public IO.FeatureHub.SSE.Client.ApiResponse <List <Model.Environment> > GetFeatureStatesWithHttpInfo(List <string> sdkUrl) { // verify the required parameter 'sdkUrl' is set if (sdkUrl == null) { throw new IO.FeatureHub.SSE.Client.ApiException(400, "Missing required parameter 'sdkUrl' when calling FeatureServiceApi->GetFeatureStates"); } IO.FeatureHub.SSE.Client.RequestOptions localVarRequestOptions = new IO.FeatureHub.SSE.Client.RequestOptions(); String[] _contentTypes = new String[] { }; // to determine the Accept header String[] _accepts = new String[] { "application/json" }; var localVarContentType = IO.FeatureHub.SSE.Client.ClientUtils.SelectHeaderContentType(_contentTypes); if (localVarContentType != null) { localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); } var localVarAccept = IO.FeatureHub.SSE.Client.ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } localVarRequestOptions.QueryParameters.Add(IO.FeatureHub.SSE.Client.ClientUtils.ParameterToMultiMap("multi", "sdkUrl", sdkUrl)); // make the HTTP request var localVarResponse = this.Client.Get <List <Model.Environment> >("/features/", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("GetFeatureStates", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
/// <summary> /// Updates the feature state if allowed. /// </summary> /// <exception cref="IO.FeatureHub.SSE.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="sdkUrl">The SDK key for the Model.Environment and service account</param> /// <param name="featureKey">The key you wish to update/action</param> /// <param name="featureStateUpdate"></param> /// <returns>Task of ApiResponse (object)</returns> public async System.Threading.Tasks.Task <IO.FeatureHub.SSE.Client.ApiResponse <object> > SetFeatureStateAsyncWithHttpInfo(string sdkUrl, string featureKey, FeatureStateUpdate featureStateUpdate) { // verify the required parameter 'sdkUrl' is set if (sdkUrl == null) { throw new IO.FeatureHub.SSE.Client.ApiException(400, "Missing required parameter 'sdkUrl' when calling FeatureServiceApi->SetFeatureState"); } // verify the required parameter 'featureKey' is set if (featureKey == null) { throw new IO.FeatureHub.SSE.Client.ApiException(400, "Missing required parameter 'featureKey' when calling FeatureServiceApi->SetFeatureState"); } // verify the required parameter 'featureStateUpdate' is set if (featureStateUpdate == null) { throw new IO.FeatureHub.SSE.Client.ApiException(400, "Missing required parameter 'featureStateUpdate' when calling FeatureServiceApi->SetFeatureState"); } IO.FeatureHub.SSE.Client.RequestOptions localVarRequestOptions = new IO.FeatureHub.SSE.Client.RequestOptions(); String[] _contentTypes = new String[] { "application/json" }; // to determine the Accept header String[] _accepts = new String[] { "application/json" }; foreach (var _contentType in _contentTypes) { localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType); } foreach (var _accept in _accepts) { localVarRequestOptions.HeaderParameters.Add("Accept", _accept); } localVarRequestOptions.PathParameters.Add("sdkUrl", IO.FeatureHub.SSE.Client.ClientUtils.ParameterToString(sdkUrl)); // path parameter localVarRequestOptions.PathParameters.Add("featureKey", IO.FeatureHub.SSE.Client.ClientUtils.ParameterToString(featureKey)); // path parameter localVarRequestOptions.Data = featureStateUpdate; // make the HTTP request var localVarResponse = await this.AsynchronousClient.PutAsync <object>("/features/{sdkUrl}/{featureKey}", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("SetFeatureState", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
/// <summary> /// Make a HTTP PATCH request (synchronous). /// </summary> /// <param name="path">The target path (or resource).</param> /// <param name="options">The additional request options.</param> /// <param name="configuration">A per-request configuration object. It is assumed that any merge with /// GlobalConfiguration has been done before calling this method.</param> /// <returns>A Task containing ApiResponse</returns> public ApiResponse <T> Patch <T>(string path, RequestOptions options, IReadableConfiguration configuration = null) { var config = configuration ?? GlobalConfiguration.Instance; return(Exec <T>(NewRequest(HttpMethod.Patch, path, options, config), config)); }
/// <summary> /// Make a HTTP HEAD request (async). /// </summary> /// <param name="path">The target path (or resource).</param> /// <param name="options">The additional request options.</param> /// <param name="configuration">A per-request configuration object. It is assumed that any merge with /// GlobalConfiguration has been done before calling this method.</param> /// <returns>A Task containing ApiResponse</returns> public Task <ApiResponse <T> > HeadAsync <T>(string path, RequestOptions options, IReadableConfiguration configuration = null) { var config = configuration ?? GlobalConfiguration.Instance; return(ExecAsync <T>(NewRequest(HttpMethod.Head, path, options, config), config)); }
/// <summary> /// Provides all logic for constructing a new RestSharp <see cref="RestRequest"/>. /// At this point, all information for querying the service is known. Here, it is simply /// mapped into the RestSharp request. /// </summary> /// <param name="method">The http verb.</param> /// <param name="path">The target path (or resource).</param> /// <param name="options">The additional request options.</param> /// <param name="configuration">A per-request configuration object. It is assumed that any merge with /// GlobalConfiguration has been done before calling this method.</param> /// <returns>[private] A new RestRequest instance.</returns> /// <exception cref="ArgumentNullException"></exception> private RestRequest NewRequest( HttpMethod method, String path, RequestOptions options, IReadableConfiguration configuration) { if (path == null) { throw new ArgumentNullException("path"); } if (options == null) { throw new ArgumentNullException("options"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } RestRequest request = new RestRequest(Method(method)) { Resource = path, JsonSerializer = new CustomJsonCodec(configuration) }; if (options.PathParameters != null) { foreach (var pathParam in options.PathParameters) { request.AddParameter(pathParam.Key, pathParam.Value, ParameterType.UrlSegment); } } if (options.QueryParameters != null) { foreach (var queryParam in options.QueryParameters) { foreach (var value in queryParam.Value) { request.AddQueryParameter(queryParam.Key, value); } } } if (configuration.DefaultHeaders != null) { foreach (var headerParam in configuration.DefaultHeaders) { request.AddHeader(headerParam.Key, headerParam.Value); } } if (options.HeaderParameters != null) { foreach (var headerParam in options.HeaderParameters) { foreach (var value in headerParam.Value) { request.AddHeader(headerParam.Key, value); } } } if (options.FormParameters != null) { foreach (var formParam in options.FormParameters) { request.AddParameter(formParam.Key, formParam.Value); } } if (options.Data != null) { if (options.HeaderParameters != null) { var contentTypes = options.HeaderParameters["Content-Type"]; if (contentTypes == null || contentTypes.Any(header => header.Contains("application/json"))) { request.RequestFormat = DataFormat.Json; } else { // TODO: Generated client user should add additional handlers. RestSharp only supports XML and JSON, with XML as default. } } else { // Here, we'll assume JSON APIs are more common. XML can be forced by adding produces/consumes to openapi spec explicitly. request.RequestFormat = DataFormat.Json; } request.AddJsonBody(options.Data); } if (options.FileParameters != null) { foreach (var fileParam in options.FileParameters) { var bytes = ClientUtils.ReadAsBytes(fileParam.Value); var fileStream = fileParam.Value as FileStream; if (fileStream != null) { request.Files.Add(FileParameter.Create(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name))); } else { request.Files.Add(FileParameter.Create(fileParam.Key, bytes, "no_file_name_provided")); } } } if (options.Cookies != null && options.Cookies.Count > 0) { foreach (var cookie in options.Cookies) { request.AddCookie(cookie.Name, cookie.Value); } } return(request); }