Exemplo n.º 1
0
        public async Task <T> PostAsync <T>(string url, object body) where T : new()
        {
            _client.BaseUrl = new Uri(url);
            var request = new RestSharp.Serializers.Newtonsoft.Json.RestRequest();

            request.AddJsonBody(body);
            return(await _client.PostAsync <T>(request));
        }
        //https://docs.azuredatabricks.net/api/latest/clusters.html#start
        public async Task <DatabricksClusterStartResponse> ClustersStartAsync(string clusterId)
        {
            var request = new RestSharp.Serializers.Newtonsoft.Json.RestRequest("api/2.0/clusters/start", Method.POST);

            request.AddHeader("Authorization", $"Basic {_authHeader}");
            request.AddJsonBody(new { cluster_id = clusterId });

            var response = await _client.ExecuteTaskAsync <DatabricksClusterStartResponse>(request);

            var dbResponse = JsonConvert.DeserializeObject <DatabricksClusterStartResponse>(response.Content);

            return(dbResponse);
        }