public ActionResult <object> Get(string handlerName)
        {
            string authToken = new SensuAuthenticationController().GetAuthenticationToken();
            var    client    = new RestClient(URL);

            client.AddDefaultHeader("Authorization", "Bearer " + authToken);
            var request  = new RestRequest(handlerName, Method.GET);
            var response = client.Execute(request);

            return(this.Content(response.Content, "application/json"));
        }
Exemple #2
0
        public ActionResult <object> GetEntities(string entityName)
        {
            RestClient client = new RestClient(URL + "/" + entityName);

            string authToken = new SensuAuthenticationController().GetAuthenticationToken();

            client.AddDefaultHeader("Authorization", "Bearer " + authToken);
            var request  = new RestRequest("", Method.GET);
            var response = client.Execute(request);

            return(response.Content);
        }
        public ActionResult <object> DeleteHandler([FromBody] string name)
        {
            RestClient client = new RestClient(URL + "/" + name);

            string authToken = new SensuAuthenticationController().GetAuthenticationToken();

            client.AddDefaultHeader("Authorization", "Bearer " + authToken);

            var request  = new RestRequest("", Method.DELETE);
            var response = client.Execute(request);

            return(response.Content);
        }
        public ActionResult <object> PostHandler([FromBody] object handler)
        {
            var strHandler = JsonConvert.SerializeObject(handler);

            RestClient client = new RestClient(URL);

            string authToken = new SensuAuthenticationController().GetAuthenticationToken();

            client.AddDefaultHeader("Authorization", "Bearer " + authToken);

            var request = new RestRequest("", Method.POST);

            request.AddJsonBody(strHandler);
            var response = client.Execute(request);

            return(response.Content);
        }
        public ActionResult <object> PutHandler([FromBody] object handler)
        {
            var     jsonHandler = JsonConvert.SerializeObject(handler);
            JObject jsonObj     = JObject.Parse(jsonHandler);
            JToken  jtok        = jsonObj.SelectToken("metadata.name");

            var nameStr = jtok.ToString();

            RestClient client = new RestClient(URL + "/" + nameStr);

            string authToken = new SensuAuthenticationController().GetAuthenticationToken();

            client.AddDefaultHeader("Authorization", "Bearer " + authToken);

            var request = new RestRequest("", Method.PUT);

            request.AddJsonBody(jsonHandler);
            var response = client.Execute(request);

            return(response.Content);
        }