using CPMeta.Models; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; namespace CPMeta { public class CPMeta { public static int Port { get; set; } = 9000; public static int TimeOut { get; set; } = 3000; public CPMeta() { RestAPI.TimeOut = TimeOut; } public static async Task HealthCheck(string host) { Guid guid = Guid.NewGuid(); string url = $"https://{host}:{Port}/CPMeta/Health/health"; var res = await RestAPI.GetAsync(url, guid); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"Response: {res} (Trace Guid:{guid})"); Console.ForegroundColor = ConsoleColor.White; return res; } public static async Task SetWbmsMetaAsync(string host, Request_SetWbmsMeta request) { Guid guid = Guid.NewGuid(); string url = $"https://{host}:{Port}/CPMeta/SetWbmsMeta"; Response_SetWbmsMeta res = await RestAPI.PostAsync(url, request, guid); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"Response: {JsonConvert.SerializeObject(res, Formatting.Indented)} (Trace Guid:{guid})"); Console.ForegroundColor = ConsoleColor.White; return res; } public static async Task GetWbmsMetaByProductId(string host, string productID, int shardID = 1) { Guid guid = Guid.NewGuid(); string url = $"https://{host}:{Port}/CPMeta/GetWbmsMetaByProductID?"; url += $"ProductID={productID}&"; url += $"ShardID={shardID}"; Response_GetWbmsMeta res = await RestAPI.GetAsync(url, guid); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine($"Response: {JsonConvert.SerializeObject(res, Formatting.Indented)} (Trace Guid: {guid})"); Console.ForegroundColor = ConsoleColor.White; return res; } public static async Task GetWbmsMetaByMacAddress(string host, string macAddress, int shardID = 1) { Guid guid = Guid.NewGuid(); string url = $"https://{host}:{Port}/CPMeta/GetWbmsMetaByMacAddress?"; url += $"MacAddress={macAddress}&"; url += $"ShardID={shardID}"; Response_GetWbmsMeta res = await RestAPI.GetAsync(url, guid); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine($"Response: {JsonConvert.SerializeObject(res, Formatting.Indented)} (Trace Guid: {guid})"); Console.ForegroundColor = ConsoleColor.White; return res; } } }