LEFT | RIGHT |
(no file at all) | |
| 1 /* |
| 2 Copyright 2013 Google Inc |
| 3 |
| 4 Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 you may not use this file except in compliance with the License. |
| 6 You may obtain a copy of the License at |
| 7 |
| 8 http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
| 10 Unless required by applicable law or agreed to in writing, software |
| 11 distributed under the License is distributed on an "AS IS" BASIS, |
| 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 See the License for the specific language governing permissions and |
| 14 limitations under the License. |
| 15 */ |
| 16 |
| 17 using System; |
| 18 using System.Collections.Generic; |
| 19 using System.Net.Http; |
| 20 using System.Threading.Tasks; |
| 21 |
| 22 namespace Google.Apis.NuGet.Publisher.Discovery |
| 23 { |
| 24 /// <summary>The discovery service which returns all the APIs.</summary> |
| 25 public class DiscoveryService |
| 26 { |
| 27 /// <summary>Returns all the APIs which supported by the discovery servi
ce in the given URI.</summary> |
| 28 public async Task<IEnumerable<DiscoveryItem>> GetApis(Uri discoveryUri) |
| 29 { |
| 30 using (var client = new HttpClient()) |
| 31 { |
| 32 // change X-User-Ip to get only external APIs |
| 33 client.DefaultRequestHeaders.Add("X-User-Ip", "0.0.0.0"); |
| 34 var apis = await client.GetStringAsync(discoveryUri); |
| 35 var doc = Newtonsoft.Json.JsonConvert.DeserializeObject<Discover
yDoc>(apis); |
| 36 return doc.Items; |
| 37 } |
| 38 } |
| 39 } |
| 40 } |
LEFT | RIGHT |