public async Task GetActions() { var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var api = new IO.Swagger.Api.ActionsApi(client); var actions = api.ActionServiceGetActionDefinitions("*", null, null, null, null); Trace.WriteLine(JsonConvert.SerializeObject(actions, Formatting.Indented)); }
public async Task GetUserUserPrivileges() { var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var api = new IO.Swagger.Api.UsersApi(client); var result = api.UserPrivilegeServiceGetPrivileges(UserName, "*", null, null, null, null); Trace.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented)); }
public async Task GetUsers() { var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var api = new IO.Swagger.Api.UsersApi(client); var users = api.GetUsers("*", null, null, null, null); Assert.IsTrue(users.Count > 0); }
public async Task GetUserClusterPriviledge() { //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 var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var request = new RestSharp.RestRequest($"clusters/{ClusterNetworkName}/privileges", Method.GET); var sz = await client.RestClient.ExecuteGetAsync <string>(request); }
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 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); }