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