Files
influx-cli/internal/ping.go
Daniel Moran 73dc5ef63b feat(api): improve codegen outputs (#41)
* Use `[]byte` for generated request bodies when the source schema has `format: byte`
* Gzip-compress request bodies when `Content-Encoding: gzip` is set
* Require that all models returned as error conditions in our API implement the `error` interface
* Move the implementation for `api.HealthCheck` out of `ping.go` and into `api/error.go`


Co-authored-by: William Baker <55118525+wbaker85@users.noreply.github.com>
2021-04-26 10:10:45 -04:00

22 lines
444 B
Go

package internal
import (
"context"
"github.com/influxdata/influx-cli/v2/internal/api"
)
// Ping checks the health of a remote InfluxDB instance.
func (c *CLI) Ping(ctx context.Context, client api.HealthApi) error {
req := client.GetHealth(ctx)
if c.TraceId != "" {
req = req.ZapTraceSpan(c.TraceId)
}
if _, _, err := client.GetHealthExecute(req); err != nil {
return err
}
_, err := c.StdIO.Write([]byte("OK\n"))
return err
}