public async Task <CMSAgentPoolListModel> GetAgentPools(CMSAuthCredentialModel authCredential) { CMSAgentPoolListModel result = new CMSAgentPoolListModel(); var response = await _httpProxyService.GetAsync($"/_apis/distributedtask/pools", authCredential); if (!response.IsSuccessStatusCode || response.StatusCode == System.Net.HttpStatusCode.NonAuthoritativeInformation) { if (response.StatusCode == System.Net.HttpStatusCode.NonAuthoritativeInformation) { result.Fail($"Code: {response.StatusCode}, Reason: The credentials are not correct"); return(result); } result.Fail($"Code: {response.StatusCode}, Reason: {await response.Content.ReadAsStringAsync()}"); return(result); } var agentoPoolResult = await response.MapTo <CMSAgentPoolListModel>(); result.Items = agentoPoolResult.Items.Where(x => x.Size > 0).Select(x => new CMSAgentPoolListItemModel() { Id = x.Id, Name = x.Name, IsHosted = x.IsHosted }).ToList(); return(result); }
public async Task <CMSAgentPoolListModel> GetAgentPools(CMSAuthCredentialModel authCredential) { authCredential.Url = $"https://{_fakeAccountServiceOptions.Value.AccountId}.visualstudio.com"; authCredential.Type = "Basic"; authCredential.AccessToken = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _fakeAccountServiceOptions.Value.AccessSecret))); CMSAgentPoolListModel result = new CMSAgentPoolListModel(); var response = await _httpProxyService.GetAsync($"/_apis/distributedtask/pools", authCredential); if (!response.IsSuccessStatusCode || response.StatusCode == System.Net.HttpStatusCode.NonAuthoritativeInformation) { if (response.StatusCode == System.Net.HttpStatusCode.NonAuthoritativeInformation) { result.Fail($"Code: {response.StatusCode}, Reason: The credentials are not correct"); return(result); } result.Fail($"Code: {response.StatusCode}, Reason: {await response.Content.ReadAsStringAsync()}"); return(result); } var agentoPoolResult = await response.MapTo <CMSAgentPoolListModel>(); result.Items = agentoPoolResult.Items.Where(x => x.Size > 0).Select(x => new CMSAgentPoolListItemModel() { Id = x.Id, Name = x.Name }).ToList(); return(result); }