/// <summary> /// Saves name and context changes to this instance asynchronously /// </summary> public Task SaveAsync() { var customMetricItem = new CustomMetricItem() { Name = Name, Context = Context }; string requestJson = JsonSerializer.Serialize(customMetricItem); var content = new StringContent(requestJson, Encoding.UTF8, "application/json"); return(_proKnow.Requestor.PutAsync($"/metrics/custom/{Id}", null, content)); }
/// <summary> /// Creates a custom metric asynchronously /// </summary> /// <param name="name">The name</param> /// <param name="context">The context</param> /// <param name="type">The type</param> /// <param name="enumValues">The enum values if type is enum</param> /// <returns>The created custom metric</returns> public async Task <CustomMetricItem> CreateAsync(string name, string context, string type, string[] enumValues = null) { var customMetricItem = new CustomMetricItem() { Name = name, Context = context, Type = new CustomMetricType(type, enumValues) }; string requestJson = JsonSerializer.Serialize(customMetricItem); var content = new StringContent(requestJson, Encoding.UTF8, "application/json"); string responseJson = await _proKnow.Requestor.PostAsync("/metrics/custom", null, content); _cache = null; customMetricItem = JsonSerializer.Deserialize <CustomMetricItem>(responseJson); customMetricItem.PostProcessSerialization(_proKnow); return(customMetricItem); }