2018-10-02 16:00:29 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
"context"
|
2019-10-07 17:45:27 +00:00
|
|
|
"net/http"
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2019-11-06 18:16:52 +00:00
|
|
|
"github.com/go-chi/chi"
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
"github.com/influxdata/httprouter"
|
2020-04-03 17:39:20 +00:00
|
|
|
"github.com/influxdata/influxdb/v2"
|
|
|
|
"github.com/influxdata/influxdb/v2/authorizer"
|
|
|
|
"github.com/influxdata/influxdb/v2/chronograf/server"
|
2020-04-20 16:55:23 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/dbrp"
|
2020-04-03 17:39:20 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/http/metric"
|
2020-08-14 19:37:30 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/influxql"
|
2020-04-30 15:29:43 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/kit/feature"
|
2021-04-07 18:42:55 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/kit/platform"
|
|
|
|
"github.com/influxdata/influxdb/v2/kit/platform/errors"
|
2020-04-03 17:39:20 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/kit/prom"
|
|
|
|
kithttp "github.com/influxdata/influxdb/v2/kit/transport/http"
|
|
|
|
"github.com/influxdata/influxdb/v2/query"
|
2021-04-07 18:42:55 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/query/fluxlang"
|
2020-04-03 17:39:20 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/storage"
|
2021-04-07 18:42:55 +00:00
|
|
|
"github.com/influxdata/influxdb/v2/task/taskmodel"
|
2019-04-10 21:08:22 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
2018-10-02 16:00:29 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
// APIHandler is a collection of all the service handlers.
|
|
|
|
type APIHandler struct {
|
2019-12-09 23:54:16 +00:00
|
|
|
chi.Router
|
2018-10-02 16:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// APIBackend is all services and associated parameters required to construct
|
|
|
|
// an APIHandler.
|
|
|
|
type APIBackend struct {
|
2019-06-27 01:33:20 +00:00
|
|
|
AssetsPath string // if empty then assets are served from bindata.
|
|
|
|
Logger *zap.Logger
|
2021-03-30 18:10:02 +00:00
|
|
|
errors.HTTPErrorHandler
|
2019-05-15 17:16:47 +00:00
|
|
|
SessionRenewDisabled bool
|
2020-01-10 16:00:37 +00:00
|
|
|
// MaxBatchSizeBytes is the maximum number of bytes which can be written
|
|
|
|
// in a single points batch
|
|
|
|
MaxBatchSizeBytes int64
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2020-01-14 16:13:40 +00:00
|
|
|
// WriteParserMaxBytes specifies the maximum number of bytes that may be allocated when processing a single
|
|
|
|
// write request. A value of zero specifies there is no limit.
|
|
|
|
WriteParserMaxBytes int
|
|
|
|
|
|
|
|
// WriteParserMaxLines specifies the maximum number of lines that may be parsed when processing a single
|
|
|
|
// write request. A value of zero specifies there is no limit.
|
|
|
|
WriteParserMaxLines int
|
|
|
|
|
|
|
|
// WriteParserMaxValues specifies the maximum number of values that may be parsed when processing a single
|
|
|
|
// write request. A value of zero specifies there is no limit.
|
|
|
|
WriteParserMaxValues int
|
|
|
|
|
2019-01-17 13:36:49 +00:00
|
|
|
NewBucketService func(*influxdb.Source) (influxdb.BucketService, error)
|
|
|
|
NewQueryService func(*influxdb.Source) (query.ProxyQueryService, error)
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2019-04-10 21:08:22 +00:00
|
|
|
WriteEventRecorder metric.EventRecorder
|
|
|
|
QueryEventRecorder metric.EventRecorder
|
|
|
|
|
2020-05-06 15:15:25 +00:00
|
|
|
AlgoWProxy FeatureProxyHandler
|
|
|
|
|
2018-11-02 18:21:14 +00:00
|
|
|
PointsWriter storage.PointsWriter
|
2019-04-09 10:05:42 +00:00
|
|
|
DeleteService influxdb.DeleteService
|
2020-01-21 22:22:45 +00:00
|
|
|
BackupService influxdb.BackupService
|
2021-06-02 23:07:53 +00:00
|
|
|
SqlBackupRestoreService influxdb.SqlBackupRestoreService
|
2021-06-04 13:26:17 +00:00
|
|
|
BucketManifestWriter influxdb.BucketManifestWriter
|
2020-10-29 22:43:02 +00:00
|
|
|
RestoreService influxdb.RestoreService
|
2019-01-17 13:36:49 +00:00
|
|
|
AuthorizationService influxdb.AuthorizationService
|
2021-04-28 19:41:44 +00:00
|
|
|
AuthorizationV1Service influxdb.AuthorizationService
|
|
|
|
PasswordV1Service influxdb.PasswordsService
|
2020-10-30 17:07:42 +00:00
|
|
|
AuthorizerV1 influxdb.AuthorizerV1
|
2020-08-03 22:17:37 +00:00
|
|
|
OnboardingService influxdb.OnboardingService
|
2020-04-20 16:55:23 +00:00
|
|
|
DBRPService influxdb.DBRPMappingServiceV2
|
2019-01-17 13:36:49 +00:00
|
|
|
BucketService influxdb.BucketService
|
|
|
|
SessionService influxdb.SessionService
|
|
|
|
UserService influxdb.UserService
|
|
|
|
OrganizationService influxdb.OrganizationService
|
|
|
|
UserResourceMappingService influxdb.UserResourceMappingService
|
|
|
|
LabelService influxdb.LabelService
|
|
|
|
DashboardService influxdb.DashboardService
|
|
|
|
DashboardOperationLogService influxdb.DashboardOperationLogService
|
|
|
|
BucketOperationLogService influxdb.BucketOperationLogService
|
|
|
|
UserOperationLogService influxdb.UserOperationLogService
|
|
|
|
OrganizationOperationLogService influxdb.OrganizationOperationLogService
|
|
|
|
SourceService influxdb.SourceService
|
2019-02-14 20:32:54 +00:00
|
|
|
VariableService influxdb.VariableService
|
2019-02-19 23:47:19 +00:00
|
|
|
PasswordsService influxdb.PasswordsService
|
2019-02-22 17:11:41 +00:00
|
|
|
InfluxQLService query.ProxyQueryService
|
2020-08-14 19:37:30 +00:00
|
|
|
InfluxqldService influxql.ProxyQueryService
|
2019-02-22 17:11:41 +00:00
|
|
|
FluxService query.ProxyQueryService
|
2021-04-07 18:42:55 +00:00
|
|
|
FluxLanguageService fluxlang.FluxLanguageService
|
|
|
|
TaskService taskmodel.TaskService
|
2019-07-25 10:30:25 +00:00
|
|
|
CheckService influxdb.CheckService
|
2019-01-17 13:36:49 +00:00
|
|
|
TelegrafService influxdb.TelegrafConfigStore
|
|
|
|
ScraperTargetStoreService influxdb.ScraperTargetStoreService
|
|
|
|
SecretService influxdb.SecretService
|
|
|
|
LookupService influxdb.LookupService
|
2018-11-02 18:21:14 +00:00
|
|
|
ChronografService *server.Service
|
2020-10-27 11:45:05 +00:00
|
|
|
OrgLookupService authorizer.OrgIDResolver
|
2019-03-04 17:41:24 +00:00
|
|
|
DocumentService influxdb.DocumentService
|
2019-07-24 21:53:53 +00:00
|
|
|
NotificationRuleStore influxdb.NotificationRuleStore
|
2019-08-08 21:59:03 +00:00
|
|
|
NotificationEndpointService influxdb.NotificationEndpointService
|
2020-04-30 15:29:43 +00:00
|
|
|
Flagger feature.Flagger
|
2020-05-06 15:13:17 +00:00
|
|
|
FlagsHandler http.Handler
|
2018-10-02 16:00:29 +00:00
|
|
|
}
|
|
|
|
|
2019-04-10 21:08:22 +00:00
|
|
|
// PrometheusCollectors exposes the prometheus collectors associated with an APIBackend.
|
|
|
|
func (b *APIBackend) PrometheusCollectors() []prometheus.Collector {
|
|
|
|
var cs []prometheus.Collector
|
|
|
|
|
|
|
|
if pc, ok := b.WriteEventRecorder.(prom.PrometheusCollector); ok {
|
|
|
|
cs = append(cs, pc.PrometheusCollectors()...)
|
|
|
|
}
|
|
|
|
|
|
|
|
if pc, ok := b.QueryEventRecorder.(prom.PrometheusCollector); ok {
|
|
|
|
cs = append(cs, pc.PrometheusCollectors()...)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cs
|
|
|
|
}
|
|
|
|
|
2019-11-05 22:08:30 +00:00
|
|
|
// APIHandlerOptFn is a functional input param to set parameters on
|
|
|
|
// the APIHandler.
|
2019-12-09 23:54:16 +00:00
|
|
|
type APIHandlerOptFn func(chi.Router)
|
2019-11-05 22:08:30 +00:00
|
|
|
|
|
|
|
// WithResourceHandler registers a resource handler on the APIHandler.
|
2020-02-03 19:07:43 +00:00
|
|
|
func WithResourceHandler(resHandler kithttp.ResourceHandler) APIHandlerOptFn {
|
2019-12-09 23:54:16 +00:00
|
|
|
return func(h chi.Router) {
|
|
|
|
h.Mount(resHandler.Prefix(), resHandler)
|
2019-11-05 22:08:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-02 16:00:29 +00:00
|
|
|
// NewAPIHandler constructs all api handlers beneath it and returns an APIHandler
|
2019-11-05 22:08:30 +00:00
|
|
|
func NewAPIHandler(b *APIBackend, opts ...APIHandlerOptFn) *APIHandler {
|
2019-06-27 01:33:20 +00:00
|
|
|
h := &APIHandler{
|
2020-06-15 23:50:29 +00:00
|
|
|
Router: NewBaseChiRouter(kithttp.NewAPI(kithttp.WithLog(b.Logger))),
|
2019-11-05 22:08:30 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 18:39:38 +00:00
|
|
|
b.UserResourceMappingService = authorizer.NewURMService(b.OrgLookupService, b.UserResourceMappingService)
|
|
|
|
|
2019-12-09 23:54:16 +00:00
|
|
|
h.Mount("/api/v2", serveLinksHandler(b.HTTPErrorHandler))
|
2019-03-04 17:41:24 +00:00
|
|
|
|
2019-12-09 23:54:16 +00:00
|
|
|
checkBackend := NewCheckBackend(b.Logger.With(zap.String("handler", "check")), b)
|
|
|
|
checkBackend.CheckService = authorizer.NewCheckService(b.CheckService,
|
|
|
|
b.UserResourceMappingService, b.OrganizationService)
|
|
|
|
h.Mount(prefixChecks, NewCheckHandler(b.Logger, checkBackend))
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2019-12-09 23:54:16 +00:00
|
|
|
h.Mount(prefixChronograf, NewChronografHandler(b.ChronografService, b.HTTPErrorHandler))
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2019-12-09 23:54:16 +00:00
|
|
|
deleteBackend := NewDeleteBackend(b.Logger.With(zap.String("handler", "delete")), b)
|
|
|
|
h.Mount(prefixDelete, NewDeleteHandler(b.Logger, deleteBackend))
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2020-11-09 11:50:48 +00:00
|
|
|
documentBackend := NewDocumentBackend(b.Logger.With(zap.String("handler", "document")), b)
|
|
|
|
documentBackend.DocumentService = authorizer.NewDocumentService(b.DocumentService)
|
|
|
|
h.Mount(prefixDocuments, NewDocumentHandler(documentBackend))
|
|
|
|
|
2019-12-09 23:54:16 +00:00
|
|
|
fluxBackend := NewFluxBackend(b.Logger.With(zap.String("handler", "query")), b)
|
|
|
|
h.Mount(prefixQuery, NewFluxHandler(b.Logger, fluxBackend))
|
|
|
|
|
|
|
|
notificationEndpointBackend := NewNotificationEndpointBackend(b.Logger.With(zap.String("handler", "notificationEndpoint")), b)
|
|
|
|
notificationEndpointBackend.NotificationEndpointService = authorizer.NewNotificationEndpointService(b.NotificationEndpointService,
|
|
|
|
b.UserResourceMappingService, b.OrganizationService)
|
|
|
|
h.Mount(prefixNotificationEndpoints, NewNotificationEndpointHandler(notificationEndpointBackend.Logger(), notificationEndpointBackend))
|
|
|
|
|
|
|
|
notificationRuleBackend := NewNotificationRuleBackend(b.Logger.With(zap.String("handler", "notification_rule")), b)
|
|
|
|
notificationRuleBackend.NotificationRuleStore = authorizer.NewNotificationRuleStore(b.NotificationRuleStore,
|
|
|
|
b.UserResourceMappingService, b.OrganizationService)
|
|
|
|
h.Mount(prefixNotificationRules, NewNotificationRuleHandler(b.Logger, notificationRuleBackend))
|
|
|
|
|
2019-12-04 23:10:23 +00:00
|
|
|
scraperBackend := NewScraperBackend(b.Logger.With(zap.String("handler", "scraper")), b)
|
2019-04-12 16:45:48 +00:00
|
|
|
scraperBackend.ScraperStorageService = authorizer.NewScraperTargetStoreService(b.ScraperTargetStoreService,
|
|
|
|
b.UserResourceMappingService,
|
|
|
|
b.OrganizationService)
|
2019-12-09 23:54:16 +00:00
|
|
|
h.Mount(prefixTargets, NewScraperHandler(b.Logger, scraperBackend))
|
|
|
|
|
2019-12-04 23:10:23 +00:00
|
|
|
sourceBackend := NewSourceBackend(b.Logger.With(zap.String("handler", "source")), b)
|
2019-01-16 12:57:33 +00:00
|
|
|
sourceBackend.SourceService = authorizer.NewSourceService(b.SourceService)
|
2020-08-04 13:37:14 +00:00
|
|
|
sourceBackend.BucketService = authorizer.NewBucketService(b.BucketService)
|
2019-12-09 23:54:16 +00:00
|
|
|
h.Mount(prefixSources, NewSourceHandler(b.Logger, sourceBackend))
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2019-12-09 23:54:16 +00:00
|
|
|
h.Mount("/api/v2/swagger.json", newSwaggerLoader(b.Logger.With(zap.String("service", "swagger-loader")), b.HTTPErrorHandler))
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2020-02-25 20:59:59 +00:00
|
|
|
taskLogger := b.Logger.With(zap.String("handler", "bucket"))
|
|
|
|
taskBackend := NewTaskBackend(taskLogger, b)
|
|
|
|
taskBackend.TaskService = authorizer.NewTaskService(taskLogger, b.TaskService)
|
2019-12-09 23:54:16 +00:00
|
|
|
taskHandler := NewTaskHandler(b.Logger, taskBackend)
|
|
|
|
h.Mount(prefixTasks, taskHandler)
|
2018-10-02 16:00:29 +00:00
|
|
|
|
2019-12-04 23:10:23 +00:00
|
|
|
telegrafBackend := NewTelegrafBackend(b.Logger.With(zap.String("handler", "telegraf")), b)
|
2019-01-16 15:48:17 +00:00
|
|
|
telegrafBackend.TelegrafService = authorizer.NewTelegrafConfigService(b.TelegrafService, b.UserResourceMappingService)
|
2019-12-17 23:53:19 +00:00
|
|
|
h.Mount(prefixTelegrafPlugins, NewTelegrafHandler(b.Logger, telegrafBackend))
|
2019-12-09 23:54:16 +00:00
|
|
|
h.Mount(prefixTelegraf, NewTelegrafHandler(b.Logger, telegrafBackend))
|
2018-10-24 15:13:30 +00:00
|
|
|
|
2020-05-06 15:13:17 +00:00
|
|
|
h.Mount("/api/v2/flags", b.FlagsHandler)
|
2020-04-22 16:23:17 +00:00
|
|
|
|
2019-12-09 23:54:16 +00:00
|
|
|
variableBackend := NewVariableBackend(b.Logger.With(zap.String("handler", "variable")), b)
|
|
|
|
variableBackend.VariableService = authorizer.NewVariableService(b.VariableService)
|
|
|
|
h.Mount(prefixVariables, NewVariableHandler(b.Logger, variableBackend))
|
2019-07-25 10:30:25 +00:00
|
|
|
|
2020-01-21 22:22:45 +00:00
|
|
|
backupBackend := NewBackupBackend(b)
|
|
|
|
backupBackend.BackupService = authorizer.NewBackupService(backupBackend.BackupService)
|
2021-06-02 23:07:53 +00:00
|
|
|
backupBackend.SqlBackupRestoreService = authorizer.NewSqlBackupRestoreService(backupBackend.SqlBackupRestoreService)
|
2020-01-21 22:22:45 +00:00
|
|
|
h.Mount(prefixBackup, NewBackupHandler(backupBackend))
|
|
|
|
|
2020-10-29 22:43:02 +00:00
|
|
|
restoreBackend := NewRestoreBackend(b)
|
|
|
|
restoreBackend.RestoreService = authorizer.NewRestoreService(restoreBackend.RestoreService)
|
2021-06-02 23:07:53 +00:00
|
|
|
restoreBackend.SqlBackupRestoreService = authorizer.NewSqlBackupRestoreService(restoreBackend.SqlBackupRestoreService)
|
2020-10-29 22:43:02 +00:00
|
|
|
h.Mount(prefixRestore, NewRestoreHandler(restoreBackend))
|
|
|
|
|
2020-06-02 15:39:29 +00:00
|
|
|
h.Mount(dbrp.PrefixDBRP, dbrp.NewHTTPHandler(b.Logger, b.DBRPService, b.OrganizationService))
|
2020-04-20 16:55:23 +00:00
|
|
|
|
2019-12-04 23:10:23 +00:00
|
|
|
writeBackend := NewWriteBackend(b.Logger.With(zap.String("handler", "write")), b)
|
2020-01-14 16:13:40 +00:00
|
|
|
h.Mount(prefixWrite, NewWriteHandler(b.Logger, writeBackend,
|
|
|
|
WithMaxBatchSizeBytes(b.MaxBatchSizeBytes),
|
2020-07-23 17:28:57 +00:00
|
|
|
//WithParserOptions(
|
|
|
|
// models.WithParserMaxBytes(b.WriteParserMaxBytes),
|
|
|
|
// models.WithParserMaxLines(b.WriteParserMaxLines),
|
|
|
|
// models.WithParserMaxValues(b.WriteParserMaxValues),
|
|
|
|
//),
|
2020-01-14 16:13:40 +00:00
|
|
|
))
|
2019-02-07 22:03:42 +00:00
|
|
|
|
2019-12-09 23:54:16 +00:00
|
|
|
for _, o := range opts {
|
|
|
|
o(h)
|
|
|
|
}
|
2018-10-02 16:00:29 +00:00
|
|
|
return h
|
|
|
|
}
|
|
|
|
|
|
|
|
var apiLinks = map[string]interface{}{
|
2018-12-20 21:25:53 +00:00
|
|
|
// when adding new links, please take care to keep this list alphabetical
|
|
|
|
// as this makes it easier to verify values against the swagger document.
|
2018-10-24 09:10:26 +00:00
|
|
|
"authorizations": "/api/v2/authorizations",
|
2020-01-21 22:22:45 +00:00
|
|
|
"backup": "/api/v2/backup",
|
2018-10-24 09:10:26 +00:00
|
|
|
"buckets": "/api/v2/buckets",
|
2018-12-20 21:25:53 +00:00
|
|
|
"dashboards": "/api/v2/dashboards",
|
|
|
|
"external": map[string]string{
|
|
|
|
"statusFeed": "https://www.influxdata.com/feed/json",
|
|
|
|
},
|
2020-04-30 15:29:43 +00:00
|
|
|
"flags": "/api/v2/flags",
|
2019-08-08 21:59:03 +00:00
|
|
|
"labels": "/api/v2/labels",
|
|
|
|
"variables": "/api/v2/variables",
|
|
|
|
"me": "/api/v2/me",
|
|
|
|
"notificationRules": "/api/v2/notificationRules",
|
|
|
|
"notificationEndpoints": "/api/v2/notificationEndpoints",
|
|
|
|
"orgs": "/api/v2/orgs",
|
2018-10-04 18:21:53 +00:00
|
|
|
"query": map[string]string{
|
|
|
|
"self": "/api/v2/query",
|
|
|
|
"ast": "/api/v2/query/ast",
|
2018-12-05 18:13:26 +00:00
|
|
|
"analyze": "/api/v2/query/analyze",
|
2018-10-04 18:21:53 +00:00
|
|
|
"suggestions": "/api/v2/query/suggestions",
|
2018-10-02 16:00:29 +00:00
|
|
|
},
|
2020-10-29 22:43:02 +00:00
|
|
|
"restore": "/api/v2/restore",
|
2019-01-18 15:38:28 +00:00
|
|
|
"setup": "/api/v2/setup",
|
|
|
|
"signin": "/api/v2/signin",
|
|
|
|
"signout": "/api/v2/signout",
|
|
|
|
"sources": "/api/v2/sources",
|
|
|
|
"scrapers": "/api/v2/scrapers",
|
2019-01-22 17:16:27 +00:00
|
|
|
"swagger": "/api/v2/swagger.json",
|
2018-10-02 16:00:29 +00:00
|
|
|
"system": map[string]string{
|
|
|
|
"metrics": "/metrics",
|
|
|
|
"debug": "/debug/pprof",
|
2018-10-04 18:21:53 +00:00
|
|
|
"health": "/health",
|
2018-10-02 16:00:29 +00:00
|
|
|
},
|
2018-12-20 21:25:53 +00:00
|
|
|
"tasks": "/api/v2/tasks",
|
2019-07-25 10:30:25 +00:00
|
|
|
"checks": "/api/v2/checks",
|
2018-12-20 21:25:53 +00:00
|
|
|
"telegrafs": "/api/v2/telegrafs",
|
2019-12-17 23:53:19 +00:00
|
|
|
"plugins": "/api/v2/telegraf/plugins",
|
2018-12-20 21:25:53 +00:00
|
|
|
"users": "/api/v2/users",
|
|
|
|
"write": "/api/v2/write",
|
2019-04-09 10:05:42 +00:00
|
|
|
"delete": "/api/v2/delete",
|
2018-10-02 16:00:29 +00:00
|
|
|
}
|
|
|
|
|
2021-03-30 18:10:02 +00:00
|
|
|
func serveLinksHandler(errorHandler errors.HTTPErrorHandler) http.Handler {
|
2019-12-09 23:54:16 +00:00
|
|
|
fn := func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := r.Context()
|
|
|
|
if err := encodeResponse(ctx, w, http.StatusOK, apiLinks); err != nil {
|
|
|
|
errorHandler.HandleHTTPError(ctx, err, w)
|
|
|
|
}
|
2018-10-10 17:06:29 +00:00
|
|
|
}
|
2019-12-09 23:54:16 +00:00
|
|
|
return http.HandlerFunc(fn)
|
2018-10-02 16:00:29 +00:00
|
|
|
}
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
|
2021-03-30 18:10:02 +00:00
|
|
|
func decodeIDFromCtx(ctx context.Context, name string) (platform.ID, error) {
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
params := httprouter.ParamsFromContext(ctx)
|
|
|
|
idStr := params.ByName(name)
|
|
|
|
|
|
|
|
if idStr == "" {
|
2021-03-30 18:10:02 +00:00
|
|
|
return 0, &errors.Error{
|
|
|
|
Code: errors.EInvalid,
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
Msg: "url missing " + name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-30 18:10:02 +00:00
|
|
|
var i platform.ID
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
if err := i.DecodeFromString(idStr); err != nil {
|
2021-03-30 18:10:02 +00:00
|
|
|
return 0, &errors.Error{
|
|
|
|
Code: errors.EInvalid,
|
refactor(kv): delete deprecated kv service code
This includes removal of a lot of kv.Service responsibilities. However,
it does not finish the re-wiring. It removes documents, telegrafs,
notification rules + endpoints, checks, orgs, users, buckets, passwords,
urms, labels and authorizations. There are some oustanding pieces that
are needed to get kv service compiling (dashboard service urm
dependency). Then all the call sites for kv service need updating and
the new implementations of telegraf and notification rules + endpoints
needed installing (along with any necessary migrations).
2020-10-20 13:25:36 +00:00
|
|
|
Err: err,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i, nil
|
|
|
|
}
|