Correlations: change casing of *UID properties (#52836)

* Correlations: change casing of *UID properties

* add link to correlations HTTP API
This commit is contained in:
Giordano Ricci
2022-07-27 07:01:46 +01:00
committed by GitHub
parent 0235fc136c
commit 4b2144fe40
13 changed files with 119 additions and 118 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"github.com/grafana/grafana/pkg/services/correlations"
)
// swagger:route POST /datasources/uid/{uid}/correlations correlations createCorrelation
// swagger:route POST /datasources/uid/{sourceUID}/correlations correlations createCorrelation
//
// Add correlation.
//
@@ -23,7 +23,7 @@ type CreateCorrelationParams struct {
Body correlations.CreateCorrelationCommand `json:"body"`
// in:path
// required:true
SourceUID string `json:"uid"`
SourceUID string `json:"sourceUID"`
}
//swagger:response createCorrelationResponse
+3 -3
View File
@@ -19,10 +19,10 @@ type Correlation struct {
UID string `json:"uid" xorm:"pk 'uid'"`
// UID of the data source the correlation originates from
// example:d0oxYRg4z
SourceUID string `json:"sourceUid" xorm:"pk 'source_uid'"`
SourceUID string `json:"sourceUID" xorm:"pk 'source_uid'"`
// UID of the data source the correlation points to
// example:PE1C5CBDA0504A6A3
TargetUID string `json:"targetUid" xorm:"target_uid"`
TargetUID string `json:"targetUID" xorm:"target_uid"`
// Label identifying the correlation
// example: My Label
Label string `json:"label" xorm:"label"`
@@ -48,7 +48,7 @@ type CreateCorrelationCommand struct {
SkipReadOnlyCheck bool `json:"-"`
// Target data source UID to which the correlation is created
// example:PE1C5CBDA0504A6A3
TargetUID string `json:"targetUid" binding:"Required"`
TargetUID string `json:"targetUID" binding:"Required"`
// Optional label identifying the correlation
// example: My label
Label string `json:"label"`
@@ -309,7 +309,7 @@ func validateDatasource(t *testing.T, dsCfg *configs) {
require.Equal(t, ds.Version, 10)
require.Equal(t, []map[string]interface{}{{
"targetUid": "a target",
"targetUID": "a target",
"label": "a label",
"description": "a description",
}}, ds.Correlations)
@@ -135,14 +135,14 @@ func (dc *DatasourceProvisioner) applyChanges(ctx context.Context, configPath st
}
func makeCreateCorrelationCommand(correlation map[string]interface{}, SourceUid string, OrgId int64) (correlations.CreateCorrelationCommand, error) {
targetUid, ok := correlation["targetUid"].(string)
targetUID, ok := correlation["targetUID"].(string)
if !ok {
return correlations.CreateCorrelationCommand{}, fmt.Errorf("correlation missing targetUid")
return correlations.CreateCorrelationCommand{}, fmt.Errorf("correlation missing targetUID")
}
return correlations.CreateCorrelationCommand{
SourceUID: SourceUid,
TargetUID: targetUid,
TargetUID: targetUID,
Label: correlation["label"].(string),
Description: correlation["description"].(string),
OrgId: OrgId,
@@ -13,7 +13,7 @@ datasources:
withCredentials: true
isDefault: true
correlations:
- targetUid: a target
- targetUID: a target
label: a label
description: a description
jsonData:
@@ -7,9 +7,9 @@ datasources:
access: proxy
url: http://localhost:8080
correlations:
- targetUid: graphite
- targetUID: graphite
label: a label
description: a description
- targetUid: graphite
- targetUID: graphite
label: a second label
description: a second description
@@ -11,7 +11,7 @@ datasources:
with_credentials: true
is_default: true
correlations:
- targetUid: a target
- targetUID: a target
label: a label
description: a description
json_data:
@@ -125,7 +125,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
res := ctx.Post(PostParams{
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", "nonexistent-ds-uid"),
body: fmt.Sprintf(`{
"targetUid": "%s"
"targetUID": "%s"
}`, writableDs),
user: adminUser,
})
@@ -148,7 +148,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
res := ctx.Post(PostParams{
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", writableDs),
body: `{
"targetUid": "nonexistent-uid-uid"
"targetUID": "nonexistent-uid-uid"
}`,
user: adminUser,
})
@@ -171,7 +171,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
res := ctx.Post(PostParams{
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", readOnlyDS),
body: fmt.Sprintf(`{
"targetUid": "%s"
"targetUID": "%s"
}`, readOnlyDS),
user: adminUser,
})
@@ -194,7 +194,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
res := ctx.Post(PostParams{
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", writableDs),
body: fmt.Sprintf(`{
"targetUid": "%s"
"targetUID": "%s"
}`, readOnlyDS),
user: adminUser,
})
@@ -222,7 +222,7 @@ func TestIntegrationCreateCorrelation(t *testing.T) {
res := ctx.Post(PostParams{
url: fmt.Sprintf("/api/datasources/uid/%s/correlations", writableDs),
body: fmt.Sprintf(`{
"targetUid": "%s",
"targetUID": "%s",
"description": "%s",
"label": "%s"
}`, writableDs, description, label),