public async Task UpdateUserClusterPriviledge() { //https://community.cloudera.com/t5/Support-Questions/REST-API-to-assign-Sandbox-roles-to-Ambari-users/td-p/107627 //does not look like this is part of the API/json //[{ // "PrivilegeInfo": { // "permission_name": "SERVICE.OPERATOR", // "principal_name": "testuser", // "principal_type": "USER" // } //}] //' https://<ambari_host>:8080/api/v1/clusters/<cluster_name>/privileges //permission_name could be one of the below: //CLUSTER.ADMINISTRATOR //CLUSTER.OPERATOR //SERVICE.ADMINISTRATOR //SERVICE.OPERATOR //CLUSTER.USER //principal_type could be either: USER or GROUP var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var api = new IO.Swagger.Api.ClustersApi(client); var body = new ClusterPrivilegeUpdateUserRequestSwagger() { new ClusterPrivilegeInfoRequestSwagger() { PrivilegeInfo = new ClusterPrivilegeInfoRequest() { permission_name = "CLUSTER.USER", principal_name = "user3", principal_type = "USER" } } }; api.UpdateUserClusterPriviledge(ClusterName, body); }
public void UpdateUserClusterPriviledge(string clusterName, ClusterPrivilegeUpdateUserRequestSwagger body) { // verify the required parameter 'clusterName' is set if (clusterName == null) { throw new ApiException(400, "Missing required parameter 'clusterName' when calling CreateCluster"); } var path = "/clusters/{clusterName}/privileges"; path = path.Replace("{format}", "json"); path = path.Replace("{" + "clusterName" + "}", ApiClient.ParameterToString(clusterName)); 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 CreateCluster: " + response.Content, response.Content); } else if (((int)response.StatusCode) == 0) { throw new ApiException((int)response.StatusCode, "Error calling CreateCluster: " + response.ErrorMessage, response.ErrorMessage); } return; }