Skip to content

Commit

Permalink
ref: move metrics types from types.go >> api_metrics.go
Browse files Browse the repository at this point in the history
ref: update metrics schema with required fields
  • Loading branch information
HannesKimara committed Oct 26, 2021
1 parent 5b91502 commit a751481
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
21 changes: 21 additions & 0 deletions api_metrics.go
Expand Up @@ -8,6 +8,27 @@ import (
"net/url"
)

// Metric describes the Blockfrost usage metrics
type Metric struct {
// Sum of all calls for a particular day
Calls int `json:"calls"`

// Starting time of the call count interval (ends midnight UTC) in UNIX time
Time int `json:"time"`
}

// MetricsEndpoint
type MetricsEndpoint struct {
// Sum of all calls for a particular day and endpoint
Calls int `json:"calls"`

// Endpoint parent name
Endpoint string `json:"endpoint"`

// Starting time of the call count interval (ends midnight UTC) in UNIX time
Time int `json:"time"`
}

// Metrics returns the history of your Blockfrost usage metrics in the past 30 days.
func (c *apiClient) Metrics(ctx context.Context) (mes []Metric, err error) {
requestUrl, err := url.Parse(fmt.Sprintf("%s/%s", c.server, resourceMetrics))
Expand Down
4 changes: 2 additions & 2 deletions api_metrics_test.go
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/blockfrost/blockfrost-go"
)

func TestResourceMetrics(t *testing.T) {
func TestResourceMetricsIntegration(t *testing.T) {
t.Parallel()
api := blockfrost.NewAPIClient(
blockfrost.APIClientOptions{},
Expand All @@ -23,7 +23,7 @@ func TestResourceMetrics(t *testing.T) {
}
}

func TestResourceMetricsEndpoints(t *testing.T) {
func TestResourceMetricsEndpointsIntegration(t *testing.T) {
t.Parallel()
api := blockfrost.NewAPIClient(
blockfrost.APIClientOptions{},
Expand Down
21 changes: 0 additions & 21 deletions types.go
Expand Up @@ -89,27 +89,6 @@ type HealthClock struct {
ServerTime int64 `json:"server_time,omitempty"`
}

// Metric describes the Blockfrost usage metrics
type Metric struct {
// Sum of all calls for a particular day
Calls int `json:"calls,omitempty"`

// Starting time of the call count interval (ends midnight UTC) in UNIX time
Time int `json:"time,omitempty"`
}

// MetricsEndpoint
type MetricsEndpoint struct {
// Sum of all calls for a particular day and endpoint
Calls int `json:"calls,omitempty"`

// Endpoint parent name
Endpoint string `json:"endpoint,omitempty"`

// Starting time of the call count interval (ends midnight UTC) in UNIX time
Time int `json:"time,omitempty"`
}

// Block defines content of a block
type Block struct {
Time int `json:"time,omitempty"`
Expand Down

0 comments on commit a751481

Please sign in to comment.