API: Make Swagger specification more consistent (#50576)

* Fix swagger generation targer using mac

Validate using the swagger binarry instead of the docker container

* API: Make swagger specification more consistent

Fix operation parameter ordering
This commit is contained in:
Sofia Papagiannaki 2022-06-14 13:35:22 +03:00 committed by GitHub
parent f87927c82e
commit 7418a80264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 1674 additions and 399 deletions

View File

@ -68,7 +68,7 @@ ensure_go-swagger_mac:
-x "github.com/prometheus/alertmanager" \
-i pkg/api/docs/tags.json
swagger-api-spec-mac: gen-go --swagger-api-spec-mac $(MERGED_SPEC_TARGET) validate-api-spec
swagger-api-spec-mac: gen-go --swagger-api-spec-mac $(MERGED_SPEC_TARGET) validate-api-spec-mac
validate-api-spec: $(MERGED_SPEC_TARGET) ## Validate API spec
docker run --rm -it \
@ -79,6 +79,9 @@ validate-api-spec: $(MERGED_SPEC_TARGET) ## Validate API spec
-w $$(pwd)/pkg/api/docs quay.io/goswagger/swagger:$(SWAGGER_TAG) \
validate /grafana/$(<)
validate-api-spec-mac: $(MERGED_SPEC_TARGET) ## Validate API spec
swagger validate $(<)
clean-api-spec:
rm $(SPEC_TARGET) $(MERGED_SPEC_TARGET)

View File

@ -45,7 +45,7 @@ import (
// 500: internalServerError
// swagger:parameters pauseAllAlerts
type PauseAllAlertsParam struct {
type PauseAllAlertsParams struct {
// in:body
// required:true
Body dtos.PauseAllAlertsCommand `json:"body"`

View File

@ -61,8 +61,15 @@ package definitions
// 500: internalServerError
// swagger:parameters getLDAPUser
type UserNameParam struct {
type GetLDAPUserParams struct {
// in:path
// required:true
UserID string `json:"user_name"`
UserName string `json:"user_name"`
}
// swagger:parameters syncLDAPUser
type SyncLDAPUserParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}

View File

@ -183,17 +183,75 @@ import (
// 500: internalServerError
// swagger:parameters setPassword
type SetPasswordParam struct {
type SetPasswordParams struct {
// in:body
// required:true
Body dtos.AdminUpdateUserPasswordForm `json:"body"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters revokeAuthToken revokeSignedINAuthTokenCmd
type RevokeAuthTokenParam struct {
// swagger:parameters deleteUser
type DeleteUserParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters enableUser
type EnableUserParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters disableUser
type DisableUserParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters getUserQuota
type GetUserQuotaParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters updateUserQuota
type UpdateUserQuotaParams struct {
// in:path
// required:true
QuotaTarget string `json:"quota_target"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters getAuthTokens
type GetAuthTokensParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters logoutUser
type LogoutUserParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters revokeAuthToken
type RevokeAuthTokenParams struct {
// in:body
// required:true
Body models.RevokeAuthTokenCmd `json:"body"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters createUser
@ -203,13 +261,6 @@ type CreateUserParam struct {
Body dtos.AdminCreateUserForm `json:"body"`
}
// swagger:parameters updateUserQuota updateOrgQuota
type TargeQuotaParam struct {
// in:path
// required:true
QuotaTarget string `json:"quota_target"`
}
// swagger:parameters updateUserQuota
type UpdateUserQuotaParam struct {
// in:body
@ -218,10 +269,13 @@ type UpdateUserQuotaParam struct {
}
// swagger:parameters setPermissions
type SetPermissionsParam struct {
type SetPermissionsParams struct {
// in:body
// required:true
Body dtos.AdminUpdateUserPermissionsForm `json:"body"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:response createUserResponse

View File

@ -113,8 +113,15 @@ import (
// 401: unauthorisedError
// 500: internalServerError
// swagger:parameters getAnnotation updateAnnotation patchAnnotation deleteAnnotation
type AnnotationIDParam struct {
// swagger:parameters getAnnotation
type GetAnnotationParams struct {
// in:path
// required:true
AnnotationID string `json:"annotation_id"`
}
// swagger:parameters deleteAnnotation
type DeleteAnnotationParams struct {
// in:path
// required:true
AnnotationID string `json:"annotation_id"`
@ -206,6 +213,9 @@ type CreateGraphiteAnnotationParams struct {
// swagger:parameters updateAnnotation
type UpdateAnnotationParams struct {
// in:path
// required:true
AnnotationID string `json:"annotation_id"`
// in:body
// required:true
Body dtos.UpdateAnnotationsCmd `json:"body"`
@ -213,6 +223,9 @@ type UpdateAnnotationParams struct {
// swagger:parameters patchAnnotation
type PatchAnnotationParams struct {
// in:path
// required:true
AnnotationID string `json:"annotation_id"`
// in:body
// required:true
Body dtos.PatchAnnotationsCmd `json:"body"`

View File

@ -101,7 +101,21 @@ import (
// 422: unprocessableEntityError
// 500: internalServerError
// swagger:parameters getDashboardByUID deleteDashboardByUID getDashboardPermissionsWithUid postDashboardPermissionsWithUid getDashboardVersionByUID
// swagger:parameters getDashboardByUID
type GetDashboardByUIDParams struct {
// in:path
// required:true
UID string `json:"uid"`
}
// swagger:parameters deleteDashboardByUID
type DeleteDashboardByUIDParams struct {
// in:path
// required:true
UID string `json:"uid"`
}
// swagger:parameters getDashboardPermissionsWithUid postDashboardPermissionsWithUid getDashboardVersionByUID
// swagger:parameters getDashboardVersionsByUID restoreDashboardVersionByUID
type UID struct {
// in:path

View File

@ -63,11 +63,30 @@ import (
// 404: notFoundError
// 500: internalServerError
// swagger:parameters postDashboardPermissions updateFolderPermissions postDashboardPermissionsWithUid
type PostDashboardPermissionsParam struct {
// swagger:parameters getDashboardPermissions
type GetDashboardPermissionsParams struct {
// in:path
DashboardID int64
}
// swagger:parameters postDashboardPermissions
type PostDashboardPermissionsParams struct {
// in:body
// required:true
Body dtos.UpdateDashboardAclCommand
// in:path
DashboardID int64
}
// swagger:parameters postDashboardPermissionsWithUid
type PostDashboardPermissionsWithUIDParams struct {
// in:body
// required:true
Body dtos.UpdateDashboardAclCommand
// in:path
// required:true
// description: The dashboard UID
UID string `json:"uid"`
}
// swagger:response getDashboardPermissionsResponse

View File

@ -84,7 +84,7 @@ import (
// 500: internalServerError
// swagger:parameters getDashboardVersions getDashboardVersion restoreDashboardVersion
// swagger:parameters getDashboardPermissions postDashboardPermissions
// swagger:parameters getDashboardPermissions
// swagger:parameters renderReportPDF
type DashboardIdParam struct {
// in:path

View File

@ -333,7 +333,7 @@ import (
// 404: notFoundError
// 500: internalServerError
// swagger:parameters updateDatasourceByID deleteDatasourceByID getDatasourceByID datasourceProxyGETcalls datasourceProxyPOSTcalls datasourceProxyDELETEcalls
// swagger:parameters updateDatasourceByID datasourceProxyDELETEcalls
// swagger:parameters checkDatasourceHealthByID fetchDatasourceResourcesByID
type DatasourceID struct {
// in:path
@ -341,7 +341,31 @@ type DatasourceID struct {
DatasourceID string `json:"id"`
}
// swagger:parameters updateDatasourceByUID deleteDatasourceByUID getDatasourceByUID datasourceProxyGETByUIDcalls datasourceProxyPOSTByUIDcalls datasourceProxyDELETEByUIDcalls
// swagger:parameters deleteDatasourceByID
type DeleteDatasourceByIDParams struct {
// in:path
// required:true
DatasourceID string `json:"id"`
}
// swagger:parameters getDatasourceByID
type GetDatasourceByIDParams struct {
// in:path
// required:true
DatasourceID string `json:"id"`
}
// swagger:parameters datasourceProxyGETcalls
type DatasourceProxyGETcallsParams struct {
// in:path
// required:true
DatasourceProxyRoute string `json:"datasource_proxy_route"`
// in:path
// required:true
DatasourceID string `json:"id"`
}
// swagger:parameters datasourceProxyDELETEByUIDcalls
// swagger:parameters checkDatasourceHealth fetchDatasourceResources
type DatasourceUID struct {
// in:path
@ -349,15 +373,53 @@ type DatasourceUID struct {
DatasourceUID string `json:"uid"`
}
// swagger:parameters getDatasourceByName deleteDatasourceByName getDatasourceIdByName
type DatasourceName struct {
// swagger:parameters deleteDatasourceByUID
type DeleteDatasourceByUIDParams struct {
// in:path
// required:true
DatasourceUID string `json:"uid"`
}
// swagger:parameters getDatasourceByUID
type GetDatasourceByUIDParams struct {
// in:path
// required:true
DatasourceUID string `json:"uid"`
}
// swagger:parameters datasourceProxyGETByUIDcalls
type DatasourceProxyGETByUIDcallsParams struct {
// in:path
// required:true
DatasourceProxyRoute string `json:"datasource_proxy_route"`
// in:path
// required:true
DatasourceUID string `json:"uid"`
}
// swagger:parameters getDatasourceByName
type GetDatasourceByNameParams struct {
// in:path
// required:true
DatasourceName string `json:"name"`
}
// swagger:parameters datasourceProxyGETcalls datasourceProxyPOSTcalls datasourceProxyDELETEcalls datasourceProxyGETByUIDcalls
// swagger:parameters datasourceProxyPOSTByUIDcalls datasourceProxyDELETEByUIDcalls
// swagger:parameters deleteDatasourceByName
type DeleteDatasourceByNameParams struct {
// in:path
// required:true
DatasourceName string `json:"name"`
}
// swagger:parameters getDatasourceIdByName
type GetDatasourceIdByNameParams struct {
// in:path
// required:true
DatasourceName string `json:"name"`
}
// swagger:parameters datasourceProxyDELETEcalls
// swagger:parameters datasourceProxyDELETEByUIDcalls
// swagger:parameters fetchDatasourceResources fetchDatasourceResourcesByID
type DatasourceProxyRouteParam struct {
// in:path
@ -366,24 +428,56 @@ type DatasourceProxyRouteParam struct {
}
// swagger:parameters datasourceProxyPOSTcalls
type DatasourceProxyParam struct {
type DatasourceProxyPOSTcallsParams struct {
// in:body
// required:true
DatasourceProxyParam interface{}
// in:path
// required:true
DatasourceProxyRoute string `json:"datasource_proxy_route"`
// in:path
// required:true
DatasourceID string `json:"id"`
}
// swagger:parameters datasourceProxyPOSTByUIDcalls
type DatasourceProxyPOSTByUIDcallsParams struct {
// in:body
// required:true
DatasourceProxyParam interface{}
// in:path
// required:true
DatasourceProxyRoute string `json:"datasource_proxy_route"`
// in:path
// required:true
DatasourceUID string `json:"uid"`
}
// swagger:parameters addDatasource
type AddDatasourceParam struct {
type AddDatasourceParams struct {
// in:body
// required:true
Body models.AddDataSourceCommand
}
// swagger:parameters updateDatasourceByID updateDatasourceByUID
type UpdateDatasource struct {
// swagger:parameters updateDatasourceByID
type UpdateDatasourceParams struct {
// in:body
// required:true
Body models.UpdateDataSourceCommand
// in:path
// required:true
DatasourceID string `json:"id"`
}
// swagger:parameters updateDatasourceByUID
type UpdateDatasourceByUIDParams struct {
// in:body
// required:true
Body models.UpdateDataSourceCommand
// in:path
// required:true
DatasourceUID string `json:"uid"`
}
// swagger:response getDatasourcesResponse

View File

@ -95,13 +95,23 @@ type GetFoldersParams struct {
}
// swagger:parameters getFolderByUID updateFolder deleteFolder
// swagger:parameters getFolderPermissions updateFolderPermissions
// swagger:parameters getFolderPermissions
type FolderUIDParam struct {
// in:path
// required:true
FolderUID string `json:"folder_uid"`
}
// swagger:parameters updateFolderPermissions
type PostDashboardPermissionsParam struct {
// in:path
// required:true
FolderUID string `json:"folder_uid"`
// in:body
// required:true
Body dtos.UpdateDashboardAclCommand
}
// swagger:parameters getFolderByID
type FolderIDParam struct {
// in:path

View File

@ -108,7 +108,7 @@ import (
// 404: notFoundError
// 500: internalServerError
// swagger:route PUT /alert-notifications/uid/{notification_channel_uid} legacy_alerts_notification_channels updateAlertNotificationChannelBYUID
// swagger:route PUT /alert-notifications/uid/{notification_channel_uid} legacy_alerts_notification_channels updateAlertNotificationChannelByUID
//
// Update notification channel by UID.
//
@ -134,46 +134,66 @@ import (
// 404: notFoundError
// 500: internalServerError
// swagger:parameters updateAlertNotificationChannel getAlertNotificationChannelByID deleteAlertNotificationChannel
type NotificationIDParam struct {
// swagger:parameters deleteAlertNotificationChannel
type DeleteAlertNotificationChannelParams struct {
// in:path
// required:true
NotificationID int64 `json:"notification_channel_id"`
}
// swagger:parameters getAlertNotificationChannelByUID updateAlertNotificationChannelBYUID deleteAlertNotificationChannelByUID
type NotificationUIDParam struct {
// swagger:parameters getAlertNotificationChannelByID
type GetAlertNotificationChannelByIDParams struct {
// in:path
// required:true
NotificationID int64 `json:"notification_channel_id"`
}
// swagger:parameters deleteAlertNotificationChannelByUID
type DeleteAlertNotificationChannelByUIDParams struct {
// in:path
// required:true
NotificationUID string `json:"notification_channel_uid"`
}
// swagger:parameters getAlertNotificationChannelByUID
type GetAlertNotificationChannelByUIDParams struct {
// in:path
// required:true
NotificationUID string `json:"notification_channel_uid"`
}
// swagger:parameters notificationChannelTest
type NotificationChannelTestParam struct {
type NotificationChannelTestParams struct {
// in:body
// required:true
Body dtos.NotificationTestCommand `json:"body"`
}
// swagger:parameters createAlertNotificationChannel
type CreateAlertNotificationChannelParam struct {
type CreateAlertNotificationChannelParams struct {
// in:body
// required:true
Body models.CreateAlertNotificationCommand `json:"body"`
}
// swagger:parameters updateAlertNotificationChannel
type UpdateAlertNotificationChannelParam struct {
type UpdateAlertNotificationChannelParams struct {
// in:body
// required:true
Body models.UpdateAlertNotificationCommand `json:"body"`
// in:path
// required:true
NotificationID int64 `json:"notification_channel_id"`
}
// swagger:parameters updateAlertNotificationChannelBYUID
type UpdateAlertNotificationChannelBYUIDParam struct {
// swagger:parameters updateAlertNotificationChannelByUID
type UpdateAlertNotificationChannelBYUIDParams struct {
// in:body
// required:true
Body models.UpdateAlertNotificationWithUidCommand `json:"body"`
// in:path
// required:true
NotificationUID string `json:"notification_channel_uid"`
}
// swagger:response getAlertNotificationChannelsResponse

View File

@ -58,15 +58,18 @@ import (
// 400: badRequestError
// 500: internalServerError
// swagger:parameters getAlertByID pauseAlert
type AlertIDParam struct {
// swagger:parameters getAlertByID
type GetAlertByIDParams struct {
// in:path
// required:true
AlertID string `json:"alert_id"`
}
// swagger:parameters pauseAlert
type PauseAlertParam struct {
type PauseAlertParams struct {
// in:path
// required:true
AlertID string `json:"alert_id"`
// in:body
// required:true
Body dtos.PauseAlertCommand `json:"body"`
@ -122,13 +125,13 @@ type GetAlertsParams struct {
}
// swagger:parameters testAlert
type TestAlertParam struct {
type TestAlertParams struct {
// in:body
Body dtos.AlertTestCommand `json:"body"`
}
// swagger:parameters getDashboardStates
type GetDashboardStatesParam struct {
type GetDashboardStatesParams struct {
// in:query
// required: true
DashboardID int64 `json:"dashboardId"`

View File

@ -97,15 +97,36 @@ import (
// 404: notFoundError
// 500: internalServerError
// swagger:parameters getLibraryElementByUID getLibraryElementConnections updateLibraryElement deleteLibraryElementByUID
// swagger:parameters getLibraryElementByUID getLibraryElementConnections
type LibraryElementByUID struct {
// in:path
// required:true
UID string `json:"library_element_uid"`
}
// swagger:parameters getLibraryElementByUID
type GetLibraryElementByUIDParams struct {
// in:path
// required:true
UID string `json:"library_element_uid"`
}
// swagger:parameters GetLibraryElementConnectionsParams
type GetLibraryElementConnectionsParams struct {
// in:path
// required:true
UID string `json:"library_element_uid"`
}
// swagger:parameters deleteLibraryElementByUID
type DeleteLibraryElementByUIDParams struct {
// in:path
// required:true
UID string `json:"library_element_uid"`
}
// swagger:parameters getLibraryElementByName
type LibraryElementByName struct {
type LibraryElementByNameParams struct {
// in:path
// required:true
Name string `json:"library_element_name"`
@ -158,7 +179,7 @@ type GetLibraryElementsParams struct {
}
// swagger:parameters createLibraryElement
type CreateLibraryElementParam struct {
type CreateLibraryElementParams struct {
// in:body
// required:true
Body libraryelements.CreateLibraryElementCommand `json:"body"`
@ -169,6 +190,9 @@ type UpdateLibraryElementParam struct {
// in:body
// required:true
Body libraryelements.PatchLibraryElementCommand `json:"body"`
// in:path
// required:true
UID string `json:"library_element_uid"`
}
// swagger:response getLibraryElementsResponse

View File

@ -108,29 +108,39 @@ import (
// 403: forbiddenError
// 500: internalServerError
// swagger:parameters updateOrgAddress adminUpdateOrgAddress
type UpdateOrgAddressParam struct {
// swagger:parameters updateOrgAddress
type UpdateOrgAddressParams struct {
// in:body
// required:true
Body dtos.UpdateOrgAddressForm `json:"body"`
}
// swagger:parameters updateOrgUser adminUpdateOrgUser
type UpdateOrgUserParam struct {
// swagger:parameters updateOrgUser
type UpdateOrgUserParams struct {
// in:body
// required:true
Body models.UpdateOrgUserCommand `json:"body"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters updateOrg adminUpdateOrg
type UpdateOrgParam struct {
// swagger:parameters deleteOrgUser
type DeleteOrgUserParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters updateOrg
type UpdateOrgParams struct {
// in:body
// required:true
Body dtos.UpdateOrgForm `json:"body"`
}
// swagger:parameters addOrgUser adminAddOrgUser
type AddOrgUserParam struct {
// swagger:parameters addOrgUser
type AddOrgUserParams struct {
// in:body
// required:true
Body models.AddOrgUserCommand `json:"body"`

View File

@ -39,14 +39,14 @@ import (
// 500: internalServerError
// swagger:parameters addInvite
type AddInviteParam struct {
type AddInviteParams struct {
// in:body
// required:true
Body dtos.AddInviteForm `json:"body"`
}
// swagger:parameters revokeInvite
type RevokeInviteParam struct {
type RevokeInviteParams struct {
// in:path
// required:true
Code string `json:"invitation_code"`

View File

@ -1,5 +1,7 @@
package definitions
import "github.com/grafana/grafana/pkg/api/dtos"
// swagger:route GET /org/preferences org_preferences getOrgPreferences
//
// Get Current Org Prefs.
@ -31,3 +33,10 @@ package definitions
// 401: unauthorisedError
// 403: forbiddenError
// 500: internalServerError
// swagger:parameters updateOrgPreferences
type UpdateOrgPreferencesParams struct {
// in:body
// required:true
Body dtos.UpdatePrefsCmd `json:"body"`
}

View File

@ -1,6 +1,9 @@
package definitions
import "github.com/grafana/grafana/pkg/models"
import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/models"
)
// swagger:route GET /orgs/{org_id} orgs getOrgByID
//
@ -183,10 +186,82 @@ import "github.com/grafana/grafana/pkg/models"
// 404: notFoundError
// 500: internalServerError
// swagger:parameters getOrgByID adminUpdateOrg adminUpdateOrgAddress adminDeleteOrg adminGetOrgUsers
// swagger:parameters adminAddOrgUser adminUpdateOrgUser adminDeleteOrgUser
// swagger:parameters getOrgQuota updateOrgQuota userSetUsingOrg
type OrgIDParam struct {
// swagger:parameters getOrgQuota
type GetOrgQuotaParams struct {
// in:path
// required:true
OrgID int64 `json:"org_id"`
}
// swagger:parameters adminUpdateOrgAddress
type AdminUpdateOrgAddressParams struct {
// in:body
// required:true
Body dtos.UpdateOrgAddressForm `json:"body"`
// in:path
// required:true
OrgID int64 `json:"org_id"`
}
// swagger:parameters adminUpdateOrgUser
type AdminUpdateOrgUserParams struct {
// in:body
// required:true
Body models.UpdateOrgUserCommand `json:"body"`
// in:path
// required:true
OrgID int64 `json:"org_id"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters getOrgByID
type GetOrgByIDParams struct {
// in:path
// required:true
OrgID int64 `json:"org_id"`
}
// swagger:parameters adminDeleteOrgUser
type AdminDeleteOrgUserParams struct {
// in:path
// required:true
OrgID int64 `json:"org_id"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters adminDeleteOrg
type AdminDeleteOrgParams struct {
// in:path
// required:true
OrgID int64 `json:"org_id"`
}
// swagger:parameters adminGetOrgUsers
type AdminGetOrgUsersParams struct {
// in:path
// required:true
OrgID int64 `json:"org_id"`
}
// swagger:parameters adminUpdateOrg
type AdminUpdateOrgParams struct {
// in:body
// required:true
Body dtos.UpdateOrgForm `json:"body"`
// in:path
// required:true
OrgID int64 `json:"org_id"`
}
// swagger:parameters adminAddOrgUser
type AdminAddOrgUserParams struct {
// in:body
// required:true
Body models.AddOrgUserCommand `json:"body"`
// in:path
// required:true
OrgID int64 `json:"org_id"`
@ -206,7 +281,7 @@ type CreateOrgParam struct {
Body models.CreateOrgCommand `json:"body"`
}
// swagger:parameters searchOrg searchTeams
// swagger:parameters searchOrg
type SearchOrgParams struct {
// in:query
// required:false
@ -229,6 +304,12 @@ type UpdateOrgQuotaParam struct {
// in:body
// required:true
Body models.UpdateOrgQuotaCmd `json:"body"`
// in:path
// required:true
QuotaTarget string `json:"quota_target"`
// in:path
// required:true
OrgID int64 `json:"org_id"`
}
// swagger:response createOrgResponse

View File

@ -19,7 +19,7 @@ import "github.com/grafana/grafana/pkg/models"
// 500: internalServerError
// swagger:parameters search
type SearchParameters struct {
type SearchParams struct {
// Search Query
// in:query
// required: false

View File

@ -65,7 +65,7 @@ import (
// 401: unauthorisedError
// swagger:parameters createSnapshot
type CreateSnapshotParam struct {
type CreateSnapshotParams struct {
// in:body
// required:true
Body models.CreateDashboardSnapshotCommand `json:"body"`
@ -82,14 +82,20 @@ type GetSnapshotsParams struct {
Limit int64 `json:"limit"`
}
// swagger:parameters getSnapshotByKey deleteSnapshotByKey
type SnapshotByKeyParam struct {
// swagger:parameters getSnapshotByKey
type SnapshotByKeyParams struct {
// in:path
Key string `json:"key"`
}
// swagger:parameters deleteSnapshotByKey
type DeleteSnapshotByKeyParams struct {
// in:path
Key string `json:"key"`
}
// swagger:parameters deleteSnapshotByDeleteKey
type DeleteSnapshotByDeleteKeyParam struct {
type DeleteSnapshotByDeleteKeyParams struct {
// in:path
DeleteKey string `json:"deleteKey"`
}

View File

@ -1,6 +1,9 @@
package definitions
import "github.com/grafana/grafana/pkg/models"
import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/models"
)
// swagger:route GET /teams/search teams searchTeams
//
@ -120,33 +123,97 @@ import "github.com/grafana/grafana/pkg/models"
// 401: unauthorisedError
// 500: internalServerError
// swagger:parameters getTeam updateTeam deleteTeamByID getTeamMembers addTeamMember updateTeamMember
// swagger:parameters removeTeamMember getTeamPreferences updateTeamPreferences
type TeamIDParam struct {
// swagger:parameters updateTeamPreferences
type UpdateTeamPreferencesParams struct {
// in:path
// required:true
TeamID string `json:"team_id"`
// in:body
// required:true
Body dtos.UpdatePrefsCmd `json:"body"`
}
// swagger:parameters getTeam
type GetTeamParams struct {
// in:path
// required:true
TeamID string `json:"team_id"`
}
// swagger:parameters deleteTeamByID
type DeleteTeamByIDParams struct {
// in:path
// required:true
TeamID string `json:"team_id"`
}
// swagger:parameters getTeamMembers
type GetTeamMembersParams struct {
// in:path
// required:true
TeamID string `json:"team_id"`
}
// swagger:parameters getTeamPreferences
type GetTeamPreferencesParams struct {
// in:path
// required:true
TeamID string `json:"team_id"`
}
// swagger:parameters removeTeamMember
type RemoveTeamMemberParams struct {
// in:path
// required:true
TeamID string `json:"team_id"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters searchTeams
type SearchTeamsParams struct {
// in:query
// required:false
// default: 1
Page int `json:"page"`
// Number of items per page
// The totalCount field in the response can be used for pagination list E.g. if totalCount is equal to 100 teams and the perpage parameter is set to 10 then there are 10 pages of teams.
// in:query
// required:false
// default: 1000
PerPage int `json:"perpage"`
Name string `json:"name"`
// If set it will return results where the query value is contained in the name field. Query values with spaces need to be URL encoded.
// required:false
Query string `json:"query"`
}
// swagger:parameters createTeam
type CreateTeamParam struct {
type CreateTeamParams struct {
// in:body
// required:true
Body models.CreateTeamCommand `json:"body"`
}
// swagger:parameters updateTeam
type UpdateTeamParam struct {
type UpdateTeamParams struct {
// in:body
// required:true
Body models.UpdateTeamCommand `json:"body"`
// in:path
// required:true
TeamID string `json:"team_id"`
}
// swagger:parameters addTeamMemberTeam
type AddTeamMemberParam struct {
// swagger:parameters addTeamMember
type AddTeamMemberParams struct {
// in:body
// required:true
Body models.AddTeamMemberCommand `json:"body"`
// in:path
// required:true
TeamID string `json:"team_id"`
}
// swagger:parameters updateTeamMember
@ -154,6 +221,12 @@ type UpdateTeamMember struct {
// in:body
// required:true
Body models.UpdateTeamMemberCommand `json:"body"`
// in:path
// required:true
TeamID string `json:"team_id"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:response searchTeamsResponse

View File

@ -148,7 +148,7 @@ import "github.com/grafana/grafana/pkg/models"
// 403: forbiddenError
// 500: internalServerError
// swagger:route POST /user/revoke-auth-token signed_in_user revokeSignedINAuthTokenCmd
// swagger:route POST /user/revoke-auth-token signed_in_user revokeSignedInAuthToken
//
// Revoke an auth token of the actual User.
//
@ -161,28 +161,57 @@ import "github.com/grafana/grafana/pkg/models"
// 403: forbiddenError
// 500: internalServerError
// swagger:parameters starDashboard unstarDashboard
type DashboardIDParam struct {
// swagger:parameters updateSignedInUser
type UpdateSignedInUserParams struct {
// To change the email, name, login, theme, provide another one.
// in:body
// required:true
Body models.UpdateUserCommand `json:"body"`
}
// swagger:parameters userSetUsingOrg
type UserSetUsingOrgParams struct {
// in:path
// required:true
OrgID int64 `json:"org_id"`
}
// swagger:parameters starDashboard
type StarDashboardParams struct {
// in:path
// required:true
DashboardID string `json:"dashboard_id"`
}
// swagger:parameters unstarDashboard
type UnstarDashboardParams struct {
// in:path
// required:true
DashboardID string `json:"dashboard_id"`
}
// swagger:parameters setHelpFlag
type FlagIDParam struct {
type SetHelpFlagParams struct {
// in:path
// required:true
FlagID string `json:"flag_id"`
}
// swagger:parameters updateUser changeUserPassword
type ChangeUserPasswordParam struct {
// swagger:parameters changeUserPassword
type ChangeUserPasswordParams struct {
// To change the email, name, login, theme, provide another one.
// in:body
// required:true
Body models.ChangeUserPasswordCommand `json:"body"`
}
// swagger:parameters revokeSignedInAuthToken
type RevokeSignedINAuthTokenCmdParams struct {
// in:body
// required:true
Body models.RevokeAuthTokenCmd `json:"body"`
}
// swagger:response helpFlagResponse
type HelpFlagResponse struct {
// The response message

View File

@ -121,33 +121,44 @@ type SearchUsersWithPagingParams struct {
Query string `json:"query"`
}
// swagger:parameters getUserByID updateUser getUserOrgList getUserTeams
// swagger:parameters setPassword setPermissions deleteUser getAuthTokens logoutUser revokeAuthToken
// swagger:parameters syncLDAPUser disableUser enableUser getUserQuota updateUserQuota
// swagger:parameters updateOrgUser deleteOrgUser adminUpdateOrgUser adminDeleteOrgUser
// swagger:parameters updateTeamMember removeTeamMember
// swagger:parameters listUserRoles addUserRole
// swagger:parameters listUserRoles addUserRole removeUserRole setUserRoles listUserRoles
type UserIDParam struct {
// swagger:parameters getUserByID
type GetUserByIDParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters getUserOrgList
type GetUserOrgListParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters getUserTeams
type GetUserTeamsParams struct {
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:parameters getUserByLoginOrEmail
type GetUserByLoginOrEmailParam struct {
type GetUserByLoginOrEmailParams struct {
// loginOrEmail of the user
// in:query
// required:true
LoginOrEmail string `json:"loginOrEmail"`
}
// swagger:parameters updateUser updateSignedInUser
type UpdateUserParam struct {
// swagger:parameters updateUser
type UpdateUserParams struct {
// To change the email, name, login, theme, provide another one.
// in:body
// required:true
Body models.UpdateUserCommand `json:"body"`
// in:path
// required:true
UserID int64 `json:"user_id"`
}
// swagger:response searchUsersResponse

File diff suppressed because it is too large Load Diff

View File

@ -75,12 +75,6 @@
"summary": "Remove a built-in role assignment.",
"operationId": "removeBuiltinRole",
"parameters": [
{
"type": "string",
"name": "roleUID",
"in": "path",
"required": true
},
{
"type": "string",
"name": "builtinRole",
@ -92,6 +86,12 @@
"description": "A flag indicating if the assignment is global or not. If set to false, the default org ID of the authenticated user will be used from the request to remove assignment.",
"name": "global",
"in": "query"
},
{
"type": "string",
"name": "roleUID",
"in": "path",
"required": true
}
],
"responses": {
@ -142,7 +142,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SetUserRolesCommand"
"$ref": "#/definitions/CreateRoleWithPermissionsCommand"
}
}
],
@ -194,12 +194,6 @@
"summary": "Update a custom role.",
"operationId": "updateRoleWithPermissions",
"parameters": [
{
"type": "string",
"name": "roleUID",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -207,6 +201,12 @@
"schema": {
"$ref": "#/definitions/UpdateRoleCommand"
}
},
{
"type": "string",
"name": "roleUID",
"in": "path",
"required": true
}
],
"responses": {
@ -346,13 +346,6 @@
"summary": "Add team role.",
"operationId": "addTeamRole",
"parameters": [
{
"type": "integer",
"format": "int64",
"name": "teamId",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -360,6 +353,13 @@
"schema": {
"$ref": "#/definitions/AddTeamRoleCommand"
}
},
{
"type": "integer",
"format": "int64",
"name": "teamId",
"in": "path",
"required": true
}
],
"responses": {
@ -421,7 +421,7 @@
}
}
},
"/access-control/users/{user_id}/roles": {
"/access-control/users/{userId}/roles": {
"get": {
"description": "Lists the roles that have been directly assigned to a given user. The list does not include built-in roles (Viewer, Editor, Admin or Grafana Admin), and it does not include roles that have been inherited from a team.\n\nYou need to have a permission with action `users.roles:list` and scope `users:id:\u003cuser ID\u003e`.",
"tags": ["access_control", "enterprise"],
@ -431,7 +431,7 @@
{
"type": "integer",
"format": "int64",
"name": "user_id",
"name": "userId",
"in": "path",
"required": true
}
@ -457,10 +457,18 @@
"summary": "Set user role assignments.",
"operationId": "setUserRoles",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SetUserRolesCommand"
}
},
{
"type": "integer",
"format": "int64",
"name": "user_id",
"name": "userId",
"in": "path",
"required": true
}
@ -500,7 +508,7 @@
{
"type": "integer",
"format": "int64",
"name": "user_id",
"name": "userId",
"in": "path",
"required": true
}
@ -521,29 +529,29 @@
}
}
},
"/access-control/users/{user_id}/roles/{roleUID}": {
"/access-control/users/{userId}/roles/{roleUID}": {
"delete": {
"description": "Revoke a role from a user. For bulk updates consider Set user role assignments.\n\nYou need to have a permission with action `users.roles:remove` and scope `permissions:type:delegate`. `permissions:type:delegate` scope ensures that users can only unassign roles which have same, or a subset of permissions which the user has. For example, if a user does not have required permissions for creating users, they wont be able to unassign a role which will allow to do that. This is done to prevent escalation of privileges.",
"tags": ["access_control", "enterprise"],
"summary": "Remove a user role assignment.",
"operationId": "removeUserRole",
"parameters": [
{
"type": "string",
"name": "roleUID",
"in": "path",
"required": true
},
{
"type": "boolean",
"description": "A flag indicating if the assignment is global or not. If set to false, the default org ID of the authenticated user will be used from the request to remove assignment.",
"name": "global",
"in": "query"
},
{
"type": "string",
"name": "roleUID",
"in": "path",
"required": true
},
{
"type": "integer",
"format": "int64",
"name": "user_id",
"name": "userId",
"in": "path",
"required": true
}
@ -1333,6 +1341,13 @@
"in": "path",
"required": true
},
{
"type": "integer",
"format": "int64",
"name": "user_id",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -1340,13 +1355,6 @@
"schema": {
"$ref": "#/definitions/UpdateUserQuotaCmd"
}
},
{
"type": "integer",
"format": "int64",
"name": "user_id",
"in": "path",
"required": true
}
],
"responses": {
@ -1569,14 +1577,8 @@
"description": "Updates an existing notification channel identified by uid.",
"tags": ["legacy_alerts_notification_channels"],
"summary": "Update notification channel by UID.",
"operationId": "updateAlertNotificationChannelBYUID",
"operationId": "updateAlertNotificationChannelByUID",
"parameters": [
{
"type": "string",
"name": "notification_channel_uid",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -1584,6 +1586,12 @@
"schema": {
"$ref": "#/definitions/UpdateAlertNotificationWithUidCommand"
}
},
{
"type": "string",
"name": "notification_channel_uid",
"in": "path",
"required": true
}
],
"responses": {
@ -1675,13 +1683,6 @@
"summary": "Update notification channel by ID.",
"operationId": "updateAlertNotificationChannel",
"parameters": [
{
"type": "integer",
"format": "int64",
"name": "notification_channel_id",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -1689,6 +1690,13 @@
"schema": {
"$ref": "#/definitions/UpdateAlertNotificationCommand"
}
},
{
"type": "integer",
"format": "int64",
"name": "notification_channel_id",
"in": "path",
"required": true
}
],
"responses": {
@ -2946,12 +2954,6 @@
"summary": "Updates permissions for a dashboard.",
"operationId": "postDashboardPermissionsWithUid",
"parameters": [
{
"type": "string",
"name": "uid",
"in": "path",
"required": true
},
{
"name": "Body",
"in": "body",
@ -2959,6 +2961,12 @@
"schema": {
"$ref": "#/definitions/UpdateDashboardAclCommand"
}
},
{
"type": "string",
"name": "uid",
"in": "path",
"required": true
}
],
"responses": {
@ -3268,13 +3276,13 @@
"parameters": [
{
"type": "string",
"name": "uid",
"name": "datasource_proxy_route",
"in": "path",
"required": true
},
{
"type": "string",
"name": "datasource_proxy_route",
"name": "uid",
"in": "path",
"required": true
}
@ -3306,15 +3314,23 @@
"summary": "Data source proxy POST calls.",
"operationId": "datasourceProxyPOSTByUIDcalls",
"parameters": [
{
"name": "DatasourceProxyParam",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"type": "string",
"name": "uid",
"name": "datasource_proxy_route",
"in": "path",
"required": true
},
{
"type": "string",
"name": "datasource_proxy_route",
"name": "uid",
"in": "path",
"required": true
}
@ -3394,13 +3410,13 @@
"parameters": [
{
"type": "string",
"name": "id",
"name": "datasource_proxy_route",
"in": "path",
"required": true
},
{
"type": "string",
"name": "datasource_proxy_route",
"name": "id",
"in": "path",
"required": true
}
@ -3434,10 +3450,12 @@
"deprecated": true,
"parameters": [
{
"type": "string",
"name": "id",
"in": "path",
"required": true
"name": "DatasourceProxyParam",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
},
{
"type": "string",
@ -3446,12 +3464,10 @@
"required": true
},
{
"name": "DatasourceProxyParam",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
"type": "string",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
@ -3561,12 +3577,6 @@
"summary": "Update an existing data source.",
"operationId": "updateDatasourceByUID",
"parameters": [
{
"type": "string",
"name": "uid",
"in": "path",
"required": true
},
{
"name": "Body",
"in": "body",
@ -3574,6 +3584,12 @@
"schema": {
"$ref": "#/definitions/UpdateDataSourceCommand"
}
},
{
"type": "string",
"name": "uid",
"in": "path",
"required": true
}
],
"responses": {
@ -3883,12 +3899,6 @@
"operationId": "updateDatasourceByID",
"deprecated": true,
"parameters": [
{
"type": "string",
"name": "id",
"in": "path",
"required": true
},
{
"name": "Body",
"in": "body",
@ -3896,6 +3906,12 @@
"schema": {
"$ref": "#/definitions/UpdateDataSourceCommand"
}
},
{
"type": "string",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
@ -4324,6 +4340,12 @@
"summary": "Updates permissions for a folder. This operation will remove existing permissions if theyre not included in the request.",
"operationId": "updateFolderPermissions",
"parameters": [
{
"type": "string",
"name": "folder_uid",
"in": "path",
"required": true
},
{
"name": "Body",
"in": "body",
@ -4331,12 +4353,6 @@
"schema": {
"$ref": "#/definitions/UpdateDashboardAclCommand"
}
},
{
"type": "string",
"name": "folder_uid",
"in": "path",
"required": true
}
],
"responses": {
@ -4569,12 +4585,6 @@
"summary": "Update library element.",
"operationId": "updateLibraryElement",
"parameters": [
{
"type": "string",
"name": "library_element_uid",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -4582,6 +4592,12 @@
"schema": {
"$ref": "#/definitions/PatchLibraryElementCommand"
}
},
{
"type": "string",
"name": "library_element_uid",
"in": "path",
"required": true
}
],
"responses": {
@ -5588,6 +5604,14 @@
"summary": "Update user quota.",
"operationId": "updateOrgQuota",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/UpdateOrgQuotaCmd"
}
},
{
"type": "string",
"name": "quota_target",
@ -5600,14 +5624,6 @@
"name": "org_id",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/UpdateOrgQuotaCmd"
}
}
],
"responses": {
@ -6572,13 +6588,6 @@
"summary": "Update a report.",
"operationId": "updateReport",
"parameters": [
{
"type": "integer",
"format": "int64",
"name": "reportID",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -6586,6 +6595,13 @@
"schema": {
"$ref": "#/definitions/CreateOrUpdateConfigCmd"
}
},
{
"type": "integer",
"format": "int64",
"name": "reportID",
"in": "path",
"required": true
}
],
"responses": {
@ -7135,14 +7151,14 @@
{
"type": "integer",
"format": "int64",
"name": "groupId",
"name": "teamId",
"in": "path",
"required": true
},
{
"type": "integer",
"format": "int64",
"name": "teamId",
"name": "groupId",
"in": "path",
"required": true
}
@ -7205,12 +7221,6 @@
"summary": "Update Team.",
"operationId": "updateTeam",
"parameters": [
{
"type": "string",
"name": "team_id",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -7218,6 +7228,12 @@
"schema": {
"$ref": "#/definitions/UpdateTeamCommand"
}
},
{
"type": "string",
"name": "team_id",
"in": "path",
"required": true
}
],
"responses": {
@ -7308,6 +7324,14 @@
"summary": "Add Team Member.",
"operationId": "addTeamMember",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/AddTeamMemberCommand"
}
},
{
"type": "string",
"name": "team_id",
@ -7340,12 +7364,6 @@
"summary": "Update Team Member.",
"operationId": "updateTeamMember",
"parameters": [
{
"type": "string",
"name": "team_id",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
@ -7354,6 +7372,12 @@
"$ref": "#/definitions/UpdateTeamMemberCommand"
}
},
{
"type": "string",
"name": "team_id",
"in": "path",
"required": true
},
{
"type": "integer",
"format": "int64",
@ -7779,7 +7803,7 @@
"description": "Revokes the given auth token (device) for the actual user. User of issued auth token (device) will no longer be logged in and will be required to authenticate again upon next activity.",
"tags": ["signed_in_user"],
"summary": "Revoke an auth token of the actual User.",
"operationId": "revokeSignedINAuthTokenCmd",
"operationId": "revokeSignedInAuthToken",
"parameters": [
{
"name": "body",
@ -8064,13 +8088,6 @@
"summary": "Update user.",
"operationId": "updateUser",
"parameters": [
{
"type": "integer",
"format": "int64",
"name": "user_id",
"in": "path",
"required": true
},
{
"description": "To change the email, name, login, theme, provide another one.",
"name": "body",
@ -8079,6 +8096,13 @@
"schema": {
"$ref": "#/definitions/UpdateUserCommand"
}
},
{
"type": "integer",
"format": "int64",
"name": "user_id",
"in": "path",
"required": true
}
],
"responses": {
@ -9441,6 +9465,9 @@
"provisionedExternalId": {
"type": "string"
},
"publicDashboardUid": {
"type": "string"
},
"slug": {
"type": "string"
},