Example #1
0
        public State Get(StateRequest request = null)
        {
            HttpRequest httpRequest = new HttpRequest(_clusterUri.Uri);
            httpRequest.ChangeUriPath("_cluster", "state");

            if(request != null)
            {
                httpRequest.AddToQueryString(StateRequest.LOCAL, request.Local.ToString(), defaultValue: false.ToString());
                httpRequest.AddToQueryString(StateRequest.FILTER_BLOCKS, request.FilterBlocks.ToString(), defaultValue: false.ToString());
                httpRequest.AddToQueryString(StateRequest.FILTER_INDICES, request.FilterIndices.ToString(), defaultValue: false.ToString());
                httpRequest.AddToQueryString(StateRequest.FILTER_METADATA, request.FilterMetaData.ToString(), defaultValue: false.ToString());
                httpRequest.AddToQueryString(StateRequest.FILTER_NODES, request.FilterNodes.ToString(), defaultValue: false.ToString());
                httpRequest.AddToQueryString(StateRequest.FILTER_ROUTING_TABLE, request.FilterRouting.ToString(), defaultValue: false.ToString());
            }

            HttpResponse response = _httpLayer.Get(httpRequest);
            if (response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                throw new ElasticRequestException(httpRequest, response);
            }

            return JsonConvert.DeserializeObject<State>(response.Body);
        }