Ejemplo n.º 1
0
        public async Task <ListView <string> > GetServiceList(int pageNo, int pageSize, string groupName, AbstractSelector selector)
        {
            var paramters = new Dictionary <string, string>()
            {
                { CommonParams.NAMESPACE_ID, namespaceId },
                { CommonParams.GROUP_NAME, groupName },
                { "pageNo", pageNo.ToString() },
                { "pageSize", pageSize.ToString() },
            };

            if (selector != null && selector.Type.Equals("label"))
            {
                paramters["selector"] = selector.ToJsonString();
            }

            var result = await ReqApi(UtilAndComs.NacosUrlBase + "/service/list", paramters, HttpMethod.Get);

            var json  = Newtonsoft.Json.Linq.JObject.Parse(result);
            var count = json.GetValue("count")?.ToObject <int>() ?? 0;
            var data  = json.GetValue("doms")?.ToObject <List <string> >() ?? new List <string>();

            ListView <string> listView = new ListView <string>(count, data);

            return(listView);
        }
Ejemplo n.º 2
0
        public async Task <ListView <string> > GetServiceList(int pageNo, int pageSize, string groupName, AbstractSelector selector)
        {
            var request = new ServiceListRequest(namespaceId, groupName, pageNo, pageSize);

            if (selector != null && selector.Type.Equals("label"))
            {
                request.Selector = selector.ToJsonString();
            }

            var response = await RequestToServer <ServiceListResponse>(request);

            var result = new ListView <string>(response.Count, response.ServiceNames);

            return(result);
        }
Ejemplo n.º 3
0
        public async Task UpdateService(Service service, AbstractSelector selector)
        {
            _logger?.LogInformation("[UPDATE-SERVICE] {0} updating service : {1} ", namespaceId, service);

            var paramters = new Dictionary <string, string>()
            {
                { CommonParams.NAMESPACE_ID, namespaceId },
                { CommonParams.SERVICE_NAME, service.Name },
                { CommonParams.GROUP_NAME, service.GroupName },
                { "protectThreshold", service.ProtectThreshold.ToString() },
                { "metadata", service.Metadata.ToJsonString() },
                { "selector", selector.ToJsonString() },
            };

            await ReqApi(UtilAndComs.NacosUrlService, paramters, HttpMethod.Put);
        }
Ejemplo n.º 4
0
        public async Task CreateService(Service service, AbstractSelector selector)
        {
            _logger?.LogInformation("[CREATE-SERVICE] {0} creating service : {1} ", namespaceId, service);

            var paramters = new Dictionary <string, string>()
            {
                { CommonParams.NAMESPACE_ID, namespaceId },
                { CommonParams.SERVICE_NAME, service.Name },
                { CommonParams.GROUP_NAME, service.GroupName },
                { CommonParams.PROTECT_THRESHOLD_PARAM, service.ProtectThreshold.ToString() },
                { CommonParams.META_PARAM, service.Metadata.ToJsonString() },
                { CommonParams.SELECTOR_PARAM, selector.ToJsonString() },
            };

            await ReqApi(UtilAndComs.NacosUrlService, paramters, HttpMethod.Post).ConfigureAwait(false);
        }