Open ghost opened 5 years ago
I've done some code. It works for me.
For Methods:
public PointCollection GetPoints(int MetricId)
{
return GetItemsReq<PointCollection, PointData>("metrics/" + MetricId + "/points");
}
public PointData NewPoint(int MetricId, int value)
{
var Request = new RestRequest("metrics/" + MetricId + "/points").AddJsonBody(new
{
value = value
});
var Response = Rest.Post<AddPointResonse>(Request);
if (Response.ResponseStatus == ResponseStatus.Completed)
{
var metricResponse = Response.Data;
if (metricResponse != null)
{
return metricResponse.Data;
}
}
return null;
}
public bool DeletePoint(int MetricId, int pointId)
{
return DeleteReq("metrics/" + MetricId + "/points/", pointId);
}
For Types:
public class PointCollection : GeneralCollectionResponse<PointData>{ }
public class AddPointResonse : GeneralSimpleResponse<PointData>{ }
public class PointData : ICachetItem
{
public int value { get; set; }
public int counter { get; set; }
public int metric_id { get; set; }
public DateTime created_at { get; set; }
public DateTime updated_at { get; set; }
public long CalculatedValue { get; set; }
public int Id { get; set; }
}
Commit 85a88300d891c3b325a77c49cb19ac0ff3856db9 adds the capability to Get metric points, and other things. Commit 5b5a1168c8214b1af4827d4905096b4a5de5a1c8 adds the capability to Add metric points, and other things. Commit 667e6d49fd3a3abcca27b515c0b7b3e97152b9dc adds the capability to Delete metric points.
Great, it's now supporting all Cachet features, isn't it?
A few features are missing but they can be implement easily, the most important requests are there. I'll implement them when I get the time.
I see @michalblaha has done quite a lot of work, is it possible to combine those two repositories?
michalblaha/Cachet.NET
@lhy0403 Since the other repo is forked - a pull request would be a great way to merge the repos.
Well I chose not to do so was because of the mismatch of the code styles. At that time I didn't have enough time to solve the merge conflict as well... Unfortunately.
I didn't find an API for adding or removing point(s) form a metric. Any thought of adding one?