2021-11-11 15:10:24 +00:00
|
|
|
package serviceaccounts
|
|
|
|
|
|
2021-12-14 14:39:25 +01:00
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2022-08-04 14:19:09 +02:00
|
|
|
"github.com/grafana/grafana/pkg/services/apikey"
|
2022-08-10 11:56:48 +02:00
|
|
|
"github.com/grafana/grafana/pkg/services/user"
|
2021-12-14 14:39:25 +01:00
|
|
|
)
|
2021-11-11 15:10:24 +00:00
|
|
|
|
2022-02-08 14:31:34 +01:00
|
|
|
// this should reflect the api
|
2021-11-11 15:10:24 +00:00
|
|
|
type Service interface {
|
2022-07-07 17:32:56 +01:00
|
|
|
CreateServiceAccount(ctx context.Context, orgID int64, saForm *CreateServiceAccountForm) (*ServiceAccountDTO, error)
|
2021-11-11 15:10:24 +00:00
|
|
|
DeleteServiceAccount(ctx context.Context, orgID, serviceAccountID int64) error
|
2022-04-12 19:34:04 +02:00
|
|
|
RetrieveServiceAccountIdByName(ctx context.Context, orgID int64, name string) (int64, error)
|
2021-11-11 15:10:24 +00:00
|
|
|
}
|
2022-01-05 15:32:38 +01:00
|
|
|
|
2021-11-11 15:10:24 +00:00
|
|
|
type Store interface {
|
2022-07-07 17:32:56 +01:00
|
|
|
CreateServiceAccount(ctx context.Context, orgID int64, saForm *CreateServiceAccountForm) (*ServiceAccountDTO, error)
|
2022-03-18 15:50:34 +01:00
|
|
|
SearchOrgServiceAccounts(ctx context.Context, orgID int64, query string, filter ServiceAccountFilter, page int, limit int,
|
2022-08-10 11:56:48 +02:00
|
|
|
signedInUser *user.SignedInUser) (*SearchServiceAccountsResult, error)
|
2022-03-14 17:24:07 +00:00
|
|
|
UpdateServiceAccount(ctx context.Context, orgID, serviceAccountID int64,
|
|
|
|
|
saForm *UpdateServiceAccountForm) (*ServiceAccountProfileDTO, error)
|
2022-02-08 14:31:34 +01:00
|
|
|
RetrieveServiceAccount(ctx context.Context, orgID, serviceAccountID int64) (*ServiceAccountProfileDTO, error)
|
2022-04-12 19:34:04 +02:00
|
|
|
RetrieveServiceAccountIdByName(ctx context.Context, orgID int64, name string) (int64, error)
|
2021-11-11 15:10:24 +00:00
|
|
|
DeleteServiceAccount(ctx context.Context, orgID, serviceAccountID int64) error
|
2022-06-15 15:59:40 +03:00
|
|
|
GetAPIKeysMigrationStatus(ctx context.Context, orgID int64) (*APIKeysMigrationStatus, error)
|
|
|
|
|
HideApiKeysTab(ctx context.Context, orgID int64) error
|
|
|
|
|
MigrateApiKeysToServiceAccounts(ctx context.Context, orgID int64) error
|
|
|
|
|
MigrateApiKey(ctx context.Context, orgID int64, keyId int64) error
|
2022-07-22 10:35:01 +02:00
|
|
|
RevertApiKey(ctx context.Context, saId int64, keyId int64) error
|
2022-08-04 14:19:09 +02:00
|
|
|
ListTokens(ctx context.Context, orgID int64, serviceAccount int64) ([]*apikey.APIKey, error)
|
2022-02-28 10:30:45 +00:00
|
|
|
DeleteServiceAccountToken(ctx context.Context, orgID, serviceAccountID, tokenID int64) error
|
2022-04-13 17:11:03 +01:00
|
|
|
AddServiceAccountToken(ctx context.Context, serviceAccountID int64, cmd *AddServiceAccountTokenCommand) error
|
2022-03-16 15:54:34 +00:00
|
|
|
GetUsageMetrics(ctx context.Context) (map[string]interface{}, error)
|
2022-07-07 14:03:16 +00:00
|
|
|
RunMetricsCollection(ctx context.Context) error
|
2021-11-11 15:10:24 +00:00
|
|
|
}
|