/// <summary> /// Create an API key for a specific user Requires the User Admin Role. /// </summary> /// <exception cref="mantle.lib.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="request"> (optional)</param> /// <returns>Task of ApiResponse</returns> public async System.Threading.Tasks.Task <ApiResponse <Object> > ApiKeysPostAsyncWithHttpInfo(CreateApiKeyRequest request = null) { var localVarPath = "./apikeys"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json-patch+json", "application/json", "text/json", "application/_*+json" }; String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { }; String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (request != null && request.GetType() != typeof(byte[])) { localVarPostBody = Configuration.ApiClient.Serialize(request); // http body (model) parameter } else { localVarPostBody = request; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("ApiKeysPost", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), null)); }
/// <summary> /// Create an API key for a specific user Requires the User Admin Role. /// </summary> /// <exception cref="mantle.lib.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="xApiKey"></param> /// <param name="request"> (optional)</param> /// <returns>ApiResponse of Object(void)</returns> public ApiResponse <Object> CreateApiKeyWithHttpInfo(string xApiKey, CreateApiKeyRequest request = null) { // verify the required parameter 'xApiKey' is set if (xApiKey == null) { throw new ApiException(400, "Missing required parameter 'xApiKey' when calling ApiKeysApi->CreateApiKey"); } var localVarPath = "/apikeys"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json-patch+json", "application/json", "text/json", "application/_*+json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (xApiKey != null) { localVarHeaderParams.Add("x-api-key", this.Configuration.ApiClient.ParameterToString(xApiKey)); // header parameter } if (request != null && request.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(request); // http body (model) parameter } else { localVarPostBody = request; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("CreateApiKey", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null)); }