public async Task CreateUser() { var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var api = new IO.Swagger.Api.UsersApi(client); var body = new UserRequestCreateUserSwagger() { Users = new CreateUserInfo() { Active = true, Admin = false, // DisplayName = "Three, User", LocalUserName = "******", Password = "******" } }; api.CreateUser(body.Users.LocalUserName, body); }
/// <summary> /// Create new user /// </summary> /// <param name="userName">user name</param> /// <param name="body"></param> /// <returns></returns> public void CreateUser(string userName, UserRequestCreateUserSwagger body) { // verify the required parameter 'userName' is set if (userName == null) { throw new ApiException(400, "Missing required parameter 'userName' when calling CreateUser"); } var path = "/users/{userName}"; path = path.Replace("{format}", "json"); path = path.Replace("{" + "userName" + "}", ApiClient.ParameterToString(userName)); var queryParams = new Dictionary <String, String>(); var headerParams = new Dictionary <String, String>(); var formParams = new Dictionary <String, String>(); var fileParams = new Dictionary <String, FileParameter>(); String postBody = null; postBody = ApiClient.Serialize(body); // http body (model) parameter // authentication setting, if any String[] authSettings = new String[] { }; // make the HTTP request IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling CreateUser: "******"Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage); } return; }